spence

Spence’s function, also known as the dilogarithm.

The dilogarithm is defined as

upper L i 2 left-parenthesis z right-parenthesis equals minus integral Subscript 0 Superscript z Baseline StartFraction ln left-parenthesis 1 minus u right-parenthesis Over u EndFraction d u comma z element-of double-struck upper C

or also alternatively as

integral Subscript 1 Superscript v Baseline StartFraction ln t Over 1 minus t EndFraction d t equals upper L i 2 left-parenthesis 1 minus v right-parenthesis period

Usage

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

spence( x )

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

Examples

var randu = require( '@stdlib/random/base/randu' );
var spence = require( '@stdlib/math/base/special/spence' );

var x;
var i;

for ( i = 0; i < 100; i++ ) {
    x = randu() * 100.0;
    console.log( 'spence( %d ) = %d', x, spence( x ) );
}
Did you find this page helpful?