/* spence.c
*
* Dilogarithm
*
*
*
* SYNOPSIS :
*
* double x , y , spence ( ) ;
*
* y = spence ( x ) ;
*
*
*
* DESCRIPTION :
*
* Computes the integral
*
* x
* -
* | | log t
* spence ( x ) = - | - - - - - dt
* | | t - 1
* -
* 1
*
* for x > = 0 . A rational approximation gives the integral in
* the interval ( 0 . 5 , 1 . 5 ) . Transformation formulas for 1 / x
* and 1 - x are employed outside the basic expansion range .
*
*
*
* ACCURACY :
*
* Relative error :
* arithmetic domain # trials peak rms
* IEEE 0 , 4 30000 3 . 9 e - 15 5 . 4 e - 16
* DEC 0 , 4 3000 2 . 5 e - 16 4 . 5 e - 17
*
*
*/
/* spence.c */
/*
Cephes Math Library Release 2 . 8 : June , 2000
Copyright 1985 , 1987 , 1989 , 2000 by Stephen L . Moshier
*/
#include "mconf.h"
#ifdef UNK
static double A[8 ] = {
4 .65128586073990045278 E-5 ,
7 .31589045238094711071 E-3 ,
1 .33847639578309018650 E-1 ,
8 .79691311754530315341 E-1 ,
2 .71149851196553469920 E0,
4 .25697156008121755724 E0,
3 .29771340985225106936 E0,
1 .00000000000000000126 E0,
};
static double B[8 ] = {
6 .90990488912553276999 E-4 ,
2 .54043763932544379113 E-2 ,
2 .82974860602568089943 E-1 ,
1 .41172597751831069617 E0,
3 .63800533345137075418 E0,
5 .03278880143316990390 E0,
3 .54771340985225096217 E0,
9 .99999999999999998740 E-1 ,
};
#endif
#ifdef DEC
static unsigned short A[32 ] = {
0034503 ,0013315 ,0034120 ,0157771 ,
0036357 ,0135043 ,0016766 ,0150637 ,
0037411 ,0007533 ,0005212 ,0161475 ,
0040141 ,0031563 ,0023217 ,0120331 ,
0040455 ,0104461 ,0007002 ,0155522 ,
0040610 ,0034434 ,0065721 ,0120465 ,
0040523 ,0006674 ,0105671 ,0054427 ,
0040200 ,0000000 ,0000000 ,0000000 ,
};
static unsigned short B[32 ] = {
0035465 ,0021626 ,0032367 ,0144157 ,
0036720 ,0016326 ,0134431 ,0000406 ,
0037620 ,0161024 ,0133701 ,0120766 ,
0040264 ,0131557 ,0152055 ,0064512 ,
0040550 ,0152424 ,0051166 ,0034272 ,
0040641 ,0006233 ,0014672 ,0111572 ,
0040543 ,0006674 ,0105671 ,0054425 ,
0040200 ,0000000 ,0000000 ,0000000 ,
};
#endif
#ifdef IBMPC
static unsigned short A[32 ] = {
0 x1bff,0 xa70a,0 x62d9,0 x3f08,
0 xda34,0 x63be,0 xf744,0 x3f7d,
0 x5c68,0 x6151,0 x21eb,0 x3fc1,
0 xf41b,0 x64d1,0 x266e,0 x3fec,
0 x5b6a,0 x21c0,0 xb126,0 x4005,
0 x3427,0 x8d7a,0 x0723,0 x4011,
0 x2b23,0 x9177,0 x61b7,0 x400a,
0 x0000,0 x0000,0 x0000,0 x3ff0,
};
static unsigned short B[32 ] = {
0 xf90e,0 xc69e,0 xa472,0 x3f46,
0 x2021,0 xd723,0 x039a,0 x3f9a,
0 x343f,0 x96f8,0 x1c42,0 x3fd2,
0 xad29,0 xfa85,0 x966d,0 x3ff6,
0 xc717,0 x8a4e,0 x1aa2,0 x400d,
0 x526f,0 x6337,0 x2193,0 x4014,
0 x2b23,0 x9177,0 x61b7,0 x400c,
0 x0000,0 x0000,0 x0000,0 x3ff0,
};
#endif
#ifdef MIEEE
static unsigned short A[32 ] = {
0 x3f08,0 x62d9,0 xa70a,0 x1bff,
0 x3f7d,0 xf744,0 x63be,0 xda34,
0 x3fc1,0 x21eb,0 x6151,0 x5c68,
0 x3fec,0 x266e,0 x64d1,0 xf41b,
0 x4005,0 xb126,0 x21c0,0 x5b6a,
0 x4011,0 x0723,0 x8d7a,0 x3427,
0 x400a,0 x61b7,0 x9177,0 x2b23,
0 x3ff0,0 x0000,0 x0000,0 x0000,
};
static unsigned short B[32 ] = {
0 x3f46,0 xa472,0 xc69e,0 xf90e,
0 x3f9a,0 x039a,0 xd723,0 x2021,
0 x3fd2,0 x1c42,0 x96f8,0 x343f,
0 x3ff6,0 x966d,0 xfa85,0 xad29,
0 x400d,0 x1aa2,0 x8a4e,0 xc717,
0 x4014,0 x2193,0 x6337,0 x526f,
0 x400c,0 x61b7,0 x9177,0 x2b23,
0 x3ff0,0 x0000,0 x0000,0 x0000,
};
#endif
#ifdef ANSIPROT
extern double fabs ( double );
extern double log ( double );
extern double polevl ( double , void *, int );
#else
double fabs(), log(), polevl();
#endif
extern double PI, MACHEP;
double spence(x)
double x;
{
double w, y, z;
int flag;
if ( x < 0 .0 )
{
mtherr( "spence" , DOMAIN );
return (0 .0 );
}
if ( x == 1 .0 )
return ( 0 .0 );
if ( x == 0 .0 )
return ( PI*PI/6 .0 );
flag = 0 ;
if ( x > 2 .0 )
{
x = 1 .0 /x;
flag |= 2 ;
}
if ( x > 1 .5 )
{
w = (1 .0 /x) - 1 .0 ;
flag |= 2 ;
}
else if ( x < 0 .5 )
{
w = -x;
flag |= 1 ;
}
else
w = x - 1 .0 ;
y = -w * polevl( w, A, 7 ) / polevl( w, B, 7 );
if ( flag & 1 )
y = (PI * PI)/6 .0 - log(x) * log(1 .0 -x) - y;
if ( flag & 2 )
{
z = log(x);
y = -0 .5 * z * z - y;
}
return ( y );
}
Messung V0.5 in Prozent C=99 H=100 G=99
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-17)
¤
*© Formatika GbR, Deutschland