Skip to content

Latest commit

 

History

History

README.md

Cotangent

Evaluate the cotangent of a single-precision floating-point number (in radians).

Usage

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

cotf( x )

Evaluates the cotangent of a single-precision floating-point number (in radians).

var v = cotf( 0.0 );
// returns Infinity

v = cotf( 3.141592653589793/2.0 );
// returns ~0.0

v = cotf( -3.141592653589793/4.0 );
// returns ~-1.0

v = cotf( 3.141592653589793/4.0 );
// returns ~1.0

v = cotf( NaN );
// returns NaN

Examples

var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var PI = require( '@stdlib/constants/float64/pi' );
var cotf = require( '@stdlib/math/base/special/cotf' );

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

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

C APIs

Usage

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

stdlib_base_cotf( x )

Evaluates the cotangent of a single-precision floating-point number (in radians).

float out = stdlib_base_cotf( 0.0f );
// returns Infinity

out = stdlib_base_cotf( 3.141592653589793f / 2.0f );
// returns ~0.0f

The function accepts the following arguments:

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

Examples

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

int main( void ) {
    const float x[] = { 0.523f, 0.785f, 1.047f, 3.14f };

    float y;
    int i;
    for ( i = 0; i < 4; i++ ) {
        y = stdlib_base_cotf( x[ i ] );
        printf( "cotf(%f) = %f\n", x[ i ], y );
    }
}