function spence( x ) {
	var flg;
	var w;
	var y;
	var z;

	if ( isnan( x ) || x < 0.0 ) {
		return NaN;
	}
	if ( x === 1.0 ) {
		return 0.0;
	}
	if ( x === 0.0 ) {
		return PI2O6;
	}
	flg = 0;
	if ( x > 2.0 ) {
		x = 1.0 / x;
		flg |= 2;
	}
	if ( x > 1.5 ) {
		w = (1.0 / x) - 1.0;
		flg |= 2;
	} else if ( x < 0.5 ) {
		w = -x;
		flg |= 1;
	} else {
		w = x - 1.0;
	}
	y = -w * polyvalA( w ) / polyvalB( w );
	if ( flg & 1 ) {
		y = PI2O6 - ( ln( x ) * ln( 1.0-x ) ) - y;
	}
	if ( flg & 2 ) {
		z = ln( x );
		y = -( 0.5 * z * z ) - y;
	}
	return y;
}
Evaluates Spence's function, which is also known as the dilogarithm.

## Method

-   A rational approximation gives the integral in the interval (0.5, 1.5).
-   Transformation formulas for \\( \tfrac{1}{x} \\) and \\( 1 - x \\) are employed outside the basic expansion range.

## Notes

-   Relative error:

    | arithmetic | domain      | # trials | peak    | rms     |
    |:----------:|:-----------:|:--------:|:-------:|:-------:|
    | IEEE       | 0,4         | 30000    | 3.9e-15 | 5.4e-16 |

@param {NonNegativeNumber} x - input value
@returns {number} function value

@example
var v = spence( 3.0 );
// returns ~-1.437

@example
var v = spence( 0.0 );
// returns ~1.645

@example
var v = spence( -9.0 );
// returns NaN

@example
var v = spence( NaN );
// returns NaN