Spence's function, also known as the dilogarithm.
The dilogarithm is defined as
or also alternatively as
var spence = require( '@stdlib/math/base/special/spence' );
Evaluates Spence's function, which is alternatively known as the dilogarithm.
var v = spence( 3.0 );
// returns ~-1.437
v = spence( 0.0 );
// returns ~1.645
v = spence( NaN );
// returns NaN
For negative numbers, the dilogarithm is not defined.
var v = spence( -4.0 );
// returns NaN
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var spence = require( '@stdlib/math/base/special/spence' );
var opts = {
'dtype': 'float64'
};
var x = uniform( 100, 0.0, 100.0, opts );
logEachMap( 'spence( %0.4f ) = %0.4f', x, spence );
#include "stdlib/math/base/special/spence.h"
Evaluates Spence's function, which is alternatively known as the dilogarithm.
double out = stdlib_base_spence( 3.0 );
// returns ~-1.437
out = stdlib_base_spence( 0.0 );
// returns ~1.645
The function accepts the following arguments:
- x:
[in] double
input value.
double stdlib_base_spence( const double x );
#include "stdlib/math/base/special/spence.h"
#include <stdio.h>
int main( void ) {
const double x[] = { 3.0, 9.0, 0.0, -10.0 };
double y;
int i;
for ( i = 0; i < 4; i++ ) {
y = stdlib_base_spence( x[ i ] );
printf( "spence(%lf) = %lf\n", x[ i ], y );
}
}