@stdlib/math-base-special-log1pf
v0.1.1
Published
Evaluate the natural logarithm of 1+x as a single-precision floating-point number.
Readme
log1pf
Evaluate the natural logarithm of
1+xas a single‐precision floating-point number.
Installation
npm install @stdlib/math-base-special-log1pfUsage
var log1pf = require( '@stdlib/math-base-special-log1pf' );log1pf( x )
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 NaNExamples
var 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 );C APIs
Usage
#include "stdlib/math/base/special/log1pf.h"stdlib_base_log1pf( x )
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 );Examples
#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 );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
Copyright
Copyright © 2016-2026. The Stdlib Authors.
