Skip to content

Latest commit

 

History

History
220 lines (135 loc) · 4.63 KB

File metadata and controls

220 lines (135 loc) · 4.63 KB

ahavercosf

Compute the inverse half-value versed cosine of a single-precision floating point number.

The inverse half-value versed cosine is defined as

$$\mathop{\mathrm{ahavercos}}(\theta) = 2 \cdot \arccos(\sqrt{\theta})$$

Usage

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

ahavercosf( x )

Computes the inverse half-value versed cosine of a single-precision floating point number (in radians).

var v = ahavercosf( 0.0 );
// returns ~3.1416

v = ahavercosf( 1.0 );
// returns 0.0

v = ahavercosf( 0.5 );
// returns ~1.5708

If x < 0, x > 1, or x is NaN, the function returns NaN.

var v = ahavercosf( 1.5 );
// returns NaN

v = ahavercosf( -3.14 );
// returns NaN

v = ahavercosf( NaN );
// returns NaN

Examples

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

var x = uniform( 100, 0.0, 1.0, {
    'dtype': 'float32'
});

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

C APIs

Usage

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

stdlib_base_ahavercosf( x )

Computes the inverse half-value versed cosine of a single-precision floating-point number (in radians).

float out = stdlib_base_ahavercosf( 0.0f );
// returns ~3.1416f

If x < 0, x > 1, or x is NaN, the function returns NaN.

float out = stdlib_base_ahavercosf( -3.14f );
// returns NaN

The function accepts the following arguments:

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

Examples

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

int main( void ) {
    const float x[] = { -2.0f, -1.6f, -1.2f, -0.8f, -0.4f, 0.4f, 0.8f, 1.2f, 1.6f, 2.0f };

    float v;
    int i;
    for ( i = 0; i < 10; i++ ) {
        v = stdlib_base_ahavercosf( x[ i ] );
        printf( "ahavercosf(%f) = %f\n", x[ i ], v );
    }
}