Skip to content

Latest commit

 

History

History
200 lines (122 loc) · 4.44 KB

File metadata and controls

200 lines (122 loc) · 4.44 KB

log1pmxf

Evaluate ln(1+x) - x for a single-precision floating-point number.

Usage

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

log1pmxf( x )

Evaluates ln(1+x) - x for a single-precision floating-point number.

var v = log1pmxf( 1.1 );
// returns ~-0.358

v = log1pmxf( 0.99 );
// returns ~-0.302

v = log1pmxf( -0.99 );
// returns ~-3.615

v = log1pmxf( -1.1 );
// returns NaN

v = log1pmxf( NaN );
// returns NaN

Examples

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

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

logEachMap( 'log1pmxf(%f) = %f', x, log1pmxf );

C APIs

Usage

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

stdlib_base_log1pmxf( x )

Evaluates ln(1+x) - x for a single-precision floating-point number.

float out = stdlib_base_log1pmxf( 1.1f );
// returns ~-0.358f

The function accepts the following arguments:

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

Examples

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

int main( void ) {
    float x;
    float v;
    int i;

    for ( i = 0; i < 100; i++ ) {
        x = ( (float)rand() / (float)RAND_MAX ) * 10.0f;
        v = stdlib_base_log1pmxf( x );
        printf( "log1pmxf(%f) = %f\n", x, v );
    }
}

See Also