Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/asec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!--

@license Apache-2.0

Copyright (c) 2022 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# asec

> Compute the [inverse (arc) secant][arcsecant] of a number.

<section class="usage">

## Usage

```javascript
var asec = require( '@stdlib/math/base/special/asec' );
```

#### asec( x )

Computes the [inverse (arc) secant][arcsecant] of `x`.

```javascript
var v = asec( 1.0 );
// returns 0.0

v = asec( 2.0 );
// returns ~1.0472

v = asec( NaN );
// returns NaN
```

The domain of `x` is restricted to the intervals `[-inf, -1]` and `[1, inf]`. For `x` outside of these intervals, the function returns `NaN`.

```javascript
var v = asec( -0.5 );
// returns NaN

v = asec( 0.5 );
// returns NaN
```

</section>

<!-- /.usage -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var linspace = require( '@stdlib/array/base/linspace' );
var asec = require( '@stdlib/math/base/special/asec' );

var x = linspace( 1.0, 10.0, 100 );

var i;
for ( i = 0; i < x.length; i++ ) {
console.log( asec( x[ i ] ) );
}
```

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[arcsecant]: https://en.wikipedia.org/wiki/Inverse_trigonometric_functions

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var asec = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var y;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = asec( ( randu()*1000.0 ) + 1.0 );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
28 changes: 28 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/asec/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

{{alias}}( x )
Computes the inverse (arc) secant of a number.

If `x > -1` and `x < 1`, the function returns `NaN`.

Parameters
----------
x: number
Input value.

Returns
-------
y: number
Inverse (arc) secant.

Examples
--------
> var y = {{alias}}( 1.0 )
0.0
> y = {{alias}}( 2.0 )
~1.0472
> y = {{alias}}( NaN )
NaN

See Also
--------

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 2.0

/**
* Computes the inverse (arc) secant of a number.
*
* @param x - input value
* @returns inverse (arc) secant
*
* @example
* var v = asec( 1.0 );
* // returns 0.0
*
* @example
* var v = asec( 2.0 );
* // returns ~1.0472
*
* @example
* var v = asec( NaN );
* // returns NaN
*/
declare function asec( x: number ): number;


// EXPORTS //

export = asec;
44 changes: 44 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/asec/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import asec = require( './index' );


// TESTS //

// The function returns a number...
{
asec( 8 ); // $ExpectType number
}

// The compiler throws an error if the function is provided a value other than a number...
{
asec( true ); // $ExpectError
asec( false ); // $ExpectError
asec( null ); // $ExpectError
asec( undefined ); // $ExpectError
asec( '5' ); // $ExpectError
asec( [] ); // $ExpectError
asec( {} ); // $ExpectError
asec( ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided insufficient arguments...
{
asec(); // $ExpectError
}
29 changes: 29 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/asec/examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var linspace = require( '@stdlib/array/base/linspace' );
var asec = require( './../lib' );

var x = linspace( 1.0, 10.0, 100 );

var i;
for ( i = 0; i < x.length; i++ ) {
console.log( 'asec( %d ) = %d', x[ i ], asec( x[ i ] ) );
}
46 changes: 46 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/asec/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2022 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/**
* Compute the inverse (arc) secant of a number.
*
* @module @stdlib/math/base/special/asec
*
* @example
* var asec = require( '@stdlib/math/base/special/asec' );
*
* var v = asec( 1.0 );
* // returns 0.0
*
* v = asec( 2.0 );
* // returns ~1.0472
*
* v = asec( NaN );
* // returns NaN
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
Loading