Skip to content

Latest commit

 

History

History

README.md

rcbrt

Compute the reciprocal of the principal cube root of a double-precision floating-point number.

The reciprocal of the principal cube root is defined as

$$\mathop{\mathrm{rcbrt}}(x)=\frac{1}{\sqrt[3]{x}}$$

Usage

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

rcbrt( x )

Computes the reciprocal (inverse) cube root of a double-precision floating-point number.

var v = rcbrt( 1.0 );
// returns 1.0

v = rcbrt( 8.0 );
// returns 0.5

v = rcbrt( 1000.0 );
// returns 0.1

v = rcbrt( 0.0 );
// returns Infinity

v = rcbrt( NaN );
// returns NaN

v = rcbrt( Infinity );
// returns 0.0

Examples

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

var opts = {
    'dtype': 'float64'
};
var x = discreteUniform( 100, 0, 100, opts );

logEachMap( 'rcbrt(%d) = %0.4f', x, rcbrt );

C APIs

Usage

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

stdlib_base_rcbrt( x )

Computes the reciprocal (inverse) cube root of a double-precision floating-point number.

double y = stdlib_base_rcbrt( 8.0 );
// returns 0.5

The function accepts the following arguments:

  • x: [in] double input value.
double stdlib_base_rcbrt( const double x );

Examples

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

int main( void ) {
    const double x[] = { 3.14, 9.0, 0.0, 0.0/0.0 };

    double y;
    int i;
    for ( i = 0; i < 4; i++ ) {
        y = stdlib_base_rcbrt( x[ i ] );
        printf( "rcbrt(%lf) = %lf\n", x[ i ], y );
    }
}

See Also