Compute the hyperbolic tangent of a single-precision floating-point number.
var tanhf = require( '@stdlib/math/base/special/tanhf' );Computes the hyperbolic tangent of a single-precision floating-point number.
var v = tanhf( 0.0 );
// returns 0.0
v = tanhf( -0.0 );
// returns -0.0
v = tanhf( 2.0 );
// returns ~0.964
v = tanhf( -2.0 );
// returns ~-0.964
v = tanhf( NaN );
// returns NaNvar uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var tanhf = require( '@stdlib/math/base/special/tanhf' );
var opts = {
'dtype': 'float32'
};
var x = uniform( 100, -4.0, 4.0, opts );
logEachMap( 'tanhf(%0.4f) = %0.4f', x, tanhf );#include "stdlib/math/base/special/tanhf.h"Computes the hyperbolic tangent of a single-precision floating-point number.
float out = stdlib_base_tanhf( 2.0f );
// returns ~0.964fThe function accepts the following arguments:
- x:
[in] floatinput value.
float stdlib_base_tanhf( const float x );#include "stdlib/math/base/special/tanhf.h"
#include <stdio.h>
int main( void ) {
const float x[] = { -4.0f, -3.11f, -2.22f, -1.33f, -0.44f, 0.44f, 1.33f, 2.22f, 3.11f, 4.0f };
float v;
int i;
for ( i = 0; i < 10; i++ ) {
v = stdlib_base_tanhf( x[ i ] );
printf( "tanhf(%f) = %f\n", x[ i ], v );
}
}@stdlib/math/base/special/tanh: compute the hyperbolic tangent of a double-precision floating-point number.@stdlib/math/base/special/sinhf: compute the hyperbolic sine of a single-precision floating-point number.@stdlib/math/base/special/coshf: compute the hyperbolic cosine of a single-precision floating-point number.