Compute the hyperbolic cosine of a single-precision floating-point number.
var coshf = require( '@stdlib/math/base/special/coshf' );Computes the hyperbolic cosine of a single-precision floating-point number x.
var v = coshf( 0.0 );
// returns 1.0
v = coshf( 2.0 );
// returns ~3.762
v = coshf( -2.0 );
// returns ~3.762
v = coshf( 90.0 );
// returns +Infinity
v = coshf( NaN );
// returns NaNvar uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var coshf = require( '@stdlib/math/base/special/coshf' );
var opts = {
'dtype': 'float32'
};
var x = uniform( 100, -5.0, 5.0, opts );
logEachMap( 'coshf(%f) = %f', x, coshf );#include "stdlib/math/base/special/coshf.h"Computes the hyperbolic cosine of a single-precision floating-point number.
float out = stdlib_base_coshf( 2.0f );
// returns ~3.762f
out = stdlib_base_coshf( -2.0f );
// returns ~3.762fThe function accepts the following arguments:
- x:
[in] floatinput value.
float stdlib_base_coshf( const float x );#include "stdlib/math/base/special/coshf.h"
#include <stdio.h>
int main( void ) {
const float x[] = { -5.0f, -3.89f, -2.78f, -1.67f, -0.56f, 0.56f, 1.67f, 2.78f, 3.89f, 5.0f };
float v;
int i;
for ( i = 0; i < 10; i++ ) {
v = stdlib_base_coshf( x[ i ] );
printf( "coshf(%f) = %f\n", x[ i ], v );
}
}