Skip to content

Latest commit

 

History

History
182 lines (111 loc) · 3.42 KB

File metadata and controls

182 lines (111 loc) · 3.42 KB

sechf

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

Usage

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

sechf( x )

Computes the hyperbolic secant of a single-precision floating-point number.

var v = sechf( 0.0 );
// returns 1.0

v = sechf( 2.0 );
// returns ~0.2658

v = sechf( -2.0 );
// returns ~0.2658

v = sechf( NaN );
// returns NaN

Examples

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

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

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

C APIs

Usage

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

stdlib_base_sechf( x )

Computes the hyperbolic secant of a single-precision floating-point number.

float out = stdlib_base_sechf( 2.0f );
// returns ~0.2658f

out = stdlib_base_sechf( -2.0f );
// returns ~0.2658f

The function accepts the following arguments:

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

Examples

#include "stdlib/math/base/special/sechf.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_sechf( x[ i ] );
        printf( "sechf(%f) = %f\n", x[ i ], v );
    }
}