Compute
x * ln(y+1)so that the result is0ifx = 0for single-precision floating-point numbers.
var xlog1pyf = require( '@stdlib/math/base/special/xlog1pyf' );Computes x * ln(y+1) so that the result is 0 if x = 0 for single-precision floating-point numbers x and y.
var out = xlog1pyf( 3.0, 2.0 );
// returns ~3.296
out = xlog1pyf( 1.5, 5.9 );
// returns ~2.897
out = xlog1pyf( 0.9, 1.0 );
// returns ~0.624
out = xlog1pyf( 1.0, 0.0 );
// returns 0.0
out = xlog1pyf( 0.0, -2.0 );
// returns 0.0
out = xlog1pyf( 1.5, NaN );
// returns NaN
out = xlog1pyf( 0.0, NaN );
// returns NaN
out = xlog1pyf( NaN, 2.3 );
// returns NaNvar randu = require( '@stdlib/random/base/randu' );
var xlog1pyf = require( '@stdlib/math/base/special/xlog1pyf' );
var x;
var y;
var i;
for ( i = 0; i < 100; i++ ) {
x = randu();
if ( x < 0.5 ) {
x = 0.0;
}
y = ( randu() * 20.0 ) - 5.0;
console.log( 'xlog1pyf(%d, %d) = %d', x, y, xlog1pyf( x, y ) );
}#include "stdlib/math/base/special/xlog1pyf.h"Computes x * ln(y+1) so that the result is 0 if x = 0 for single-precision floating-point numbers x and y.
float v = stdlib_base_xlog1pyf( 3.0f, 2.0f );
// returns ~3.296fThe function accepts the following arguments:
- x:
[in] floatinput value. - y:
[in] floatinput value.
float stdlib_base_xlog1pyf( const float x, const float y );#include "stdlib/math/base/special/xlog1pyf.h"
#include <stdio.h>
#include <stdlib.h>
int main( void ) {
float out;
float x;
float y;
int i;
for ( i = 0; i < 100; i++ ) {
x = ( (float)rand() / (float)RAND_MAX ) * 100.0f;
y = ( (float)rand() / (float)RAND_MAX ) * 5.0f;
out = stdlib_base_xlog1pyf( x, y );
printf( "xlog1pyf(%f, %f) = %f\n", x, y, out );
}
}@stdlib/math/base/special/log1pf: evaluate the natural logarithm of 1+x for single-precision floating-point numbers.@stdlib/math/base/special/xlog1py: computex * ln(y+1)so that the result is0ifx = 0for double-precision floating-point numbers.@stdlib/math/base/special/xlogy: computex * ln(y)so that the result is0ifx = 0for double-precision floating-point numbers.