Skip to content

Commit e525deb

Browse files
committed
fix: use correct inverse coversed cosine formula
1 parent 62bde63 commit e525deb

File tree

21 files changed

+70
-123
lines changed

21 files changed

+70
-123
lines changed

lib/node_modules/@stdlib/math/base/special/acovercos/README.md

+12-17
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,12 @@ limitations under the License.
2626

2727
The [inverse coversed cosine][inverse-coversed-cosine] is defined as
2828

29-
<!-- <equation class="equation" label="eq:arccovercosine" align="center" raw="\operatorname{acovercos}(\theta) = \arcsin(1+\theta)" alt="Inverse coversed cosine."> -->
29+
<!-- <equation class="equation" label="eq:arccovercosine" align="center" raw="\operatorname{acovercos}(\theta) = \arcsin(\theta-1)" alt="Inverse coversed cosine."> -->
3030

3131
```math
32-
\mathop{\mathrm{acovercos}}(\theta) = \arcsin(1+\theta)
32+
\mathop{\mathrm{acovercos}}(\theta) = \arcsin(\theta-1)
3333
```
3434

35-
<!-- <div class="equation" align="center" data-raw-text="\operatorname{acovercos}(\theta) = \arcsin(1+\theta)" data-equation="eq:arccovercosine">
36-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/acovercos/docs/img/equation_arccovercosine.svg" alt="Inverse coversed cosine.">
37-
<br>
38-
</div> -->
39-
4035
<!-- </equation> -->
4136

4237
</section>
@@ -57,22 +52,22 @@ Computes the [inverse coversed cosine][inverse-coversed-cosine].
5752

5853
```javascript
5954
var v = acovercos( 0.0 );
60-
// returns ~1.5708
55+
// returns ~-1.5708
6156

62-
v = acovercos( -3.141592653589793/2.0 );
63-
// returns ~-0.6075
57+
v = acovercos( 3.141592653589793/2.0 );
58+
// returns ~0.6075
6459

65-
v = acovercos( -3.141592653589793/6.0 );
66-
// returns ~0.4966
60+
v = acovercos( 3.141592653589793/6.0 );
61+
// returns ~-0.4966
6762
```
6863

69-
If `x < -2`, `x > 0`, or `x` is `NaN`, the function returns `NaN`.
64+
If `x < 0`, `x > 2`, or `x` is `NaN`, the function returns `NaN`.
7065

7166
```javascript
72-
var v = acovercos( 1.0 );
67+
var v = acovercos( -1.0 );
7368
// returns NaN
7469

75-
v = acovercos( -3.14 );
70+
v = acovercos( 3.14 );
7671
// returns NaN
7772

7873
v = acovercos( NaN );
@@ -94,7 +89,7 @@ var uniform = require( '@stdlib/random/array/uniform' );
9489
var logEachMap = require( '@stdlib/console/log-each-map' );
9590
var acovercos = require( '@stdlib/math/base/special/acovercos' );
9691

97-
var x = uniform( 100, -2.0, 0.0, {
92+
var x = uniform( 100, 0.0, 2.0, {
9893
'dtype': 'float64'
9994
});
10095

@@ -171,7 +166,7 @@ double stdlib_base_acovercos( const double x );
171166
#include <stdio.h>
172167
173168
int main( void ) {
174-
const double x[] = { -2.0, -1.80, -1.78, -1.67, -0.56, -0.27, -1.67, -0.78, -1.89, 0.0 };
169+
const double x[] = { 0.0, 0.27, 0.56, 0.78, 1.67, 1.67, 1.78, 1.80, 1.89, 2.0 };
175170
176171
double v;
177172
int i;

lib/node_modules/@stdlib/math/base/special/acovercos/benchmark/benchmark.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37-
x = uniform( 100, -2.0, 0.0 );
37+
x = uniform( 100, 0.0, 2.0 );
3838

3939
b.tic();
4040
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/math/base/special/acovercos/benchmark/benchmark.native.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46-
x = uniform( 100, -2.0, 0.0 );
46+
x = uniform( 100, 0.0, 2.0 );
4747

4848
b.tic();
4949
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/math/base/special/acovercos/benchmark/c/benchmark.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ static double benchmark( void ) {
9696
int i;
9797

9898
for ( i = 0; i < 100; i++ ) {
99-
x[ i ] = ( -2.0*rand_double() ) + 0.0;
99+
x[ i ] = 2.0*rand_double();
100100
}
101101

102102
t = tic();
103103
for ( i = 0; i < ITERATIONS; i++ ) {
104-
y = asin( 1.0 + x[ i%100 ] );
104+
y = asin( x[ i%100 ] - 1.0 );
105105
if ( y != y ) {
106106
printf( "should not return NaN\n" );
107107
break;

lib/node_modules/@stdlib/math/base/special/acovercos/benchmark/c/native/benchmark.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static double benchmark( void ) {
9797
int i;
9898

9999
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( -2.0*rand_double() );
100+
x[ i ] = 2.0*rand_double();
101101
}
102102

103103
t = tic();

lib/node_modules/@stdlib/math/base/special/acovercos/docs/img/equation_arccovercosine.svg

-48
This file was deleted.

lib/node_modules/@stdlib/math/base/special/acovercos/docs/repl.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
{{alias}}( x )
33
Computes the inverse coversed cosine.
44

5-
The inverse coversed cosine is defined as `asin(1+x)`.
5+
The inverse coversed cosine is defined as `asin(x-1)`.
66

7-
If `x < -2`, `x > 0`, or `x` is `NaN`, the function returns `NaN`.
7+
If `x < 0`, `x > 2`, or `x` is `NaN`, the function returns `NaN`.
88

99
Parameters
1010
----------
@@ -18,10 +18,10 @@
1818

1919
Examples
2020
--------
21-
> var y = {{alias}}( -1.5 )
22-
~-0.5236
21+
> var y = {{alias}}( 1.5 )
22+
~0.5236
2323
> y = {{alias}}( -0.0 )
24-
~1.5708
24+
~-1.5708
2525

2626
See Also
2727
--------

lib/node_modules/@stdlib/math/base/special/acovercos/docs/types/index.d.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
*
2727
* @example
2828
* var v = acovercos( 0.0 );
29-
* // returns ~1.5708
29+
* // returns ~-1.5708
3030
*
3131
* @example
32-
* var v = acovercos( -3.141592653589793/2.0 );
33-
* // returns ~-0.6075
32+
* var v = acovercos( 3.141592653589793/2.0 );
33+
* // returns ~0.6075
3434
*
3535
* @example
36-
* var v = acovercos( -3.141592653589793/6.0 );
37-
* // returns ~0.4966
36+
* var v = acovercos( 3.141592653589793/6.0 );
37+
* // returns ~-0.4966
3838
*
3939
* @example
4040
* var v = acovercos( NaN );

lib/node_modules/@stdlib/math/base/special/acovercos/docs/types/test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import acovercos = require( './index' );
2323

2424
// The function returns a number...
2525
{
26-
acovercos( 8 ); // $ExpectType number
26+
acovercos( 1 ); // $ExpectType number
2727
}
2828

2929
// The compiler throws an error if the function is provided a value other than a number...

lib/node_modules/@stdlib/math/base/special/acovercos/examples/c/example.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <stdio.h>
2121

2222
int main( void ) {
23-
const double x[] = { -2.0, -1.80, -1.78, -1.67, -0.56, -0.27, -1.67, -0.78, -1.89, 0.0 };
23+
const double x[] = { 0.0, 0.27, 0.56, 0.78, 1.67, 1.67, 1.78, 1.80, 1.89, 2.0 };
2424

2525
double v;
2626
int i;

lib/node_modules/@stdlib/math/base/special/acovercos/examples/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var uniform = require( '@stdlib/random/array/uniform' );
2222
var logEachMap = require( '@stdlib/console/log-each-map' );
2323
var acovercos = require( './../lib' );
2424

25-
var x = uniform( 100, -2.0, 0.0, {
25+
var x = uniform( 100, 0.0, 2.0, {
2626
'dtype': 'float64'
2727
});
2828

lib/node_modules/@stdlib/math/base/special/acovercos/lib/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
* var acovercos = require( '@stdlib/math/base/special/acovercos' );
2828
*
2929
* var v = acovercos( 0.0 );
30-
* // returns ~1.5708
30+
* // returns ~-1.5708
3131
*
32-
* v = acovercos( -3.141592653589793/2.0 );
33-
* // returns ~-0.6075
32+
* v = acovercos( 3.141592653589793/2.0 );
33+
* // returns ~0.6075
3434
*
35-
* v = acovercos( -3.141592653589793/6.0 );
36-
* // returns ~0.4966
35+
* v = acovercos( 3.141592653589793/6.0 );
36+
* // returns ~-0.4966
3737
*
3838
* v = acovercos( NaN );
3939
* // returns NaN

lib/node_modules/@stdlib/math/base/special/acovercos/lib/main.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ var asin = require( '@stdlib/math/base/special/asin' );
3333
*
3434
* @example
3535
* var v = acovercos( 0.0 );
36-
* // returns ~1.5708
36+
* // returns ~-1.5708
3737
*
3838
* @example
39-
* var v = acovercos( -3.141592653589793/2.0 );
40-
* // returns ~-0.6075
39+
* var v = acovercos( 3.141592653589793/2.0 );
40+
* // returns ~0.6075
4141
*
4242
* @example
43-
* var v = acovercos( -3.141592653589793/6.0 );
44-
* // returns ~0.4966
43+
* var v = acovercos( 3.141592653589793/6.0 );
44+
* // returns ~-0.4966
4545
*
4646
* @example
4747
* var v = acovercos( NaN );
4848
* // returns NaN
4949
*/
5050
function acovercos( x ) {
51-
return asin( 1.0 + x );
51+
return asin( x - 1.0 );
5252
}
5353

5454

lib/node_modules/@stdlib/math/base/special/acovercos/lib/native.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ var addon = require( './../src/addon.node' );
3434
*
3535
* @example
3636
* var v = acovercos( 0.0 );
37-
* // returns ~1.5708
37+
* // returns ~-1.5708
3838
*
3939
* @example
40-
* var v = acovercos( -3.141592653589793/2.0 );
41-
* // returns ~-0.6075
40+
* var v = acovercos( 3.141592653589793/2.0 );
41+
* // returns ~0.6075
4242
*
4343
* @example
44-
* var v = acovercos( -3.141592653589793/6.0 );
45-
* // returns ~0.4966
44+
* var v = acovercos( 3.141592653589793/6.0 );
45+
* // returns ~-0.4966
4646
*
4747
* @example
4848
* var v = acovercos( NaN );

lib/node_modules/@stdlib/math/base/special/acovercos/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
*
2828
* @example
2929
* double out = stdlib_base_acovercos( 0.0 );
30-
* // returns ~1.5708
30+
* // returns ~-1.5708
3131
*/
3232
double stdlib_base_acovercos( const double x ) {
33-
return stdlib_base_asin( 1.0 + x );
33+
return stdlib_base_asin( x - 1.0 );
3434
}

lib/node_modules/@stdlib/math/base/special/acovercos/test/fixtures/julia/data.json

+1-1
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/acovercos/test/fixtures/julia/runner.jl

100644100755
+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import JSON
2020

2121
"""
22-
gen( domain, name )
22+
gen( domain, name )
2323
2424
Generate fixture data and write to file.
2525
@@ -37,7 +37,7 @@ julia> gen( x, \"data.json\" );
3737
"""
3838
function gen( domain, name )
3939
x = collect( domain );
40-
y = asin.( 1.0 .+ x );
40+
y = asin.( x .- 1.0 );
4141

4242
# Store data to be written to file as a collection:
4343
data = Dict([
@@ -62,9 +62,9 @@ file = @__FILE__;
6262
dir = dirname( file );
6363

6464
# Generate fixture data for decimal values:
65-
x = range( -2.0, stop = 0.0, length = 2003 );
65+
x = range( 0.0, stop = 2.0, length = 2003 );
6666
gen( x, "data.json" );
6767

6868
# Generate fixture data for small negative values:
69-
x = range( -1e-200, stop = -1e-208, length = 2003 );
70-
gen( x, "small_negative.json" );
69+
x = range( 1e-208, stop = 1e-200, length = 2003 );
70+
gen( x, "small_positive.json" );

lib/node_modules/@stdlib/math/base/special/acovercos/test/fixtures/julia/small_negative.json

-1
This file was deleted.

lib/node_modules/@stdlib/math/base/special/acovercos/test/fixtures/julia/small_positive.json

+1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)