Skip to content

Latest commit

 

History

History
216 lines (132 loc) · 4.01 KB

File metadata and controls

216 lines (132 loc) · 4.01 KB

atanhf

Compute the hyperbolic arctangent of a single‐precision floating-point number.

Usage

var atanhf = require( '@stdlib/math/base/special/fast/atanhf' );

atanhf( x )

Computes the hyperbolic arctangent of a single‐precision floating-point number (in radians).

var v = atanhf( 0.0 );
// returns 0.0

v = atanhf( -0.0 );
// returns -0.0

v = atanhf( 0.5 );
// returns ~0.549

v = atanhf( 0.9 );
// returns ~1.472

v = atanhf( 1.0 );
// returns Infinity

v = atanhf( -1.0 );
// returns -Infinity

The domain of x is restricted to [-1,1]. If |x| > 1, the function returns NaN.

var v = atanhf( -3.14 );
// returns NaN

Notes

  • For small x, the function will underflow.

    var v = atanhf( 1.0e-17 );
    // returns 0.0
    // (expected 1.0e-17)

Examples

var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var atanhf = require( '@stdlib/math/base/special/fast/atanhf' );

var opts = {
    'dtype': 'float32'
};
var x = uniform( 103, -1.0, 1.0, opts );

logEachMap( 'atanhf(%0.4f) = %0.4f', x, atanhf );

C APIs

Usage

#include "stdlib/math/base/special/fast/atanhf.h"

stdlib_base_fast_atanhf( x )

Computes the hyperbolic arctangent of a single-precision floating-point number (in radians).

float out = stdlib_base_fast_atanhf( 0.0f );
// returns 0.0f

out = stdlib_base_fast_atanhf( -0.0f );
// returns -0.0f

The function accepts the following arguments:

  • x: [in] float input value.
float stdlib_base_fast_atanhf( const float x );

Examples

#include "stdlib/math/base/special/fast/atanhf.h"
#include <stdio.h>

int main( void ) {
    const float x[] = { -1.0f, -0.78f, -0.56f, -0.33f, -0.11f, 0.11f, 0.33f, 0.56f, 0.78f, 1.0f };

    float v;
    int i;
    for ( i = 0; i < 10; i++ ) {
        v = stdlib_base_fast_atanhf( x[ i ] );
        printf( "atanh(%f) = %f\n", x[ i ], v );
    }
}