Evaluate the natural logarithm of
1+xas a single‐precision floating-point number.
var log1pf = require( '@stdlib/math/base/special/log1pf' );Evaluates the natural logarithm of 1+x as a single‐precision floating-point number.
var v = log1pf( 4.0 );
// returns ~1.609
v = log1pf( -1.0 );
// returns -Infinity
v = log1pf( Infinity );
// returns Infinity
v = log1pf( 0.0 );
// returns 0.0
v = log1pf( -0.0 );
// returns -0.0
v = log1pf( NaN );
// returns NaNFor x < -1, the function returns NaN, as the natural logarithm is not defined for negative numbers.
var v = log1pf( -2.0 );
// returns NaNvar uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var log1pf = require( '@stdlib/math/base/special/log1pf' );
var opts = {
'dtype': 'float32'
};
var x = uniform( 100, 0.0, 100.0, opts );
logEachMap( 'log1pf(%0.4f) = %0.4f', x, log1pf );#include "stdlib/math/base/special/log1pf.h"Evaluates the natural logarithm of 1+x as a single‐precision floating-point number.
float out = stdlib_base_log1pf( 4.0f );
// returns ~1.609f
out = stdlib_base_log1pf( -1.0f );
// returns -InfinityThe function accepts the following arguments:
- x:
[in] floatinput value.
float stdlib_base_log1pf( const float x );#include "stdlib/math/base/special/log1pf.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 ) * 100.0f;
v = stdlib_base_log1pf( x );
printf( "log1pf(%f) = %f\n", x, v );
}
}