Skip to content

Latest commit

 

History

History
189 lines (115 loc) · 3.5 KB

File metadata and controls

189 lines (115 loc) · 3.5 KB

coshf

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

Usage

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

coshf( x )

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 NaN

Examples

var 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 );

C APIs

Usage

#include "stdlib/math/base/special/coshf.h"

stdlib_base_coshf( x )

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.762f

The function accepts the following arguments:

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

Examples

#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 );
    }
}