#include #include #include typedef double _Complex C; typedef double R; static R sq(R x){return x*x;} static C csq(C x){return x*x;} static R m2(C x){return sq(creal(x)) + sq(cimag(x));} static int t(C x){return fabs(creal(x)) < 1.e-16 && fabs(cimag(x)) < 1.e-16;} static R const pi = 3.141592653589793238, p2 = pi*pi; static void pc(C a){printf("%19.16f + %19.16fi\n", creal(a), cimag(a));} int wrk, wrkD; C dilog(C z){R r = m2(z); if(r > 1) {C r = 1/z; return - dilog(r) - p2/6 - 0.5*csq(clog(-r));} if(creal(z) > 0.6) return - dilog(1-z) + p2/6 - (z==1?0:clog(1-z)*clog(z)); if(r > 0.4) if(creal(z) < 0.15) return -dilog(z/(z-1))-0.5*csq(clog(1-z)); else return 0.5*dilog(z*z) - dilog(-z); if(m2(z + 0.268) < 0.0049){C s = 0; C w = z; R a = 1, b = 3; while(1) {C T = w/a; s += T; ++wrk; if(t(T)) break; w *= z; a += b; b += 2;} return s;} {C z2=z*z, s = z + 1.4375*z2 + 0.75*(1-z2)*clog(1-z), f = z*z2; R J=6, K=18, L=18; while(1){C a = f/(J*J); s+=a; ++wrk; if(t(a)) break; f *= z; J+=K; K+=L; L+=6;} return 4*s/(1+4*z+z2);}} C dilogD(C z){long double _Complex s = 0; C w = z; R a = 1, b = 3; if(m2(z)>1) {C r = 1/z; return - dilogD(r) - p2/6 - 0.5*csq(clog(-r));} while(1) {C T = w/a; s += T; ++wrkD; if(t(T)) break; w *= z; a += b; b += 2;} return s;} void pr(R a, char * m){printf("%19.16f %s\n", a, m);} void tst(C z, R v, char * m){pc(z); pr(v, m); wrkD=0; pc(dilogD(z)); wrk=0; pc(dilog(z)); printf("w=%9d %4d\n", wrkD, wrk);} C c(R x, R y){C a; __real__ a = x; __imag__ a = y; return a;} int main(){if (1) { // Ad-hoc tests R r5 = sqrt(5), v = sq(log((1+r5)/2)); printf("Three functional equations corroborated:\n"); {C z = -1.27-0.93i; tst(1/z, 0, "rel1"); pc(-dilog(z) - p2/6 - 0.5*csq(clog(-z)));} {C z = 0.162+0.13i; tst(1-z, 0, "rel2"); pc(-dilog(z) + p2/6 - clog(z)*clog(1-z));} {C z = -0.9+0.12i; tst(z, 0, "xx"); pc(-dilogD(z/(z-1))-0.5*csq(clog(1-z)));} printf("Mostly known values for increasing argments on the real line:\n"); tst(-(r5+1)/2, -p2/10 - v, "-(r5+1)/2"); tst(-(r5+1)/2, -p2/15 + sq(log((r5-1)/2))/2, "-(r5+1)/2 W"); tst(-(r5+1)/2, -p2/10 + v/2, "-(r5+1)/2 W"); // note to Zagier tst(-1, -p2/12., "-1"); tst((1-r5)/2, -p2/15 + v/2, "(1-r5)/2"); tst(-0.269, 0, "-0.269"); tst(-0.268, 0, "-0.268"); tst(0, 0, "0"); tst((3-r5)/2, p2/15 - v, "(3-r5)/2"); tst(0.5, p2/12 - sq(log(2))/2., "1/2"); tst((r5-1)/2, p2/10 - v, "(r5-1)/2"); tst(0.89999, 0, "0.89999"); tst(0.90001, 0, "0.90001"); tst(0.99999, 0, ".99999"); // only three digits!! tst(1, p2/6, "1"); // note peculiar error in 8th digit. tst((r5+1)/2, (11*p2)/15 - v/2, "(r5+1)/2 W"); // note to W polylog tst(2, 0, "2"); tst((r5+3)/2, -(11*p2)/15 - v, "(r5+3)/2 W"); // note to W polylog printf("Some ad-hoc probes\n"); printf("Li2(2) = \n"); pc(dilog(2)); pc(p2/4+(0.+1i)*pi*log(2)); tst(c( 0.5, sqrt(3)/2), 0, "c(0.5, sqrt(3)/2)"); tst(c(-0.5, sqrt(3)/2), 0, "c(-0.5, sqrt(3)/2)"); tst(csqrt(c(0.5, sqrt(3)/2)), 0, "csqrt(c(0.5, sqrt(3)/2))"); tst(0+0.5i, 0, "0+0.5i"); tst(0+1.i, 0, "0+1.i"); tst(0.23-0.4i, 0, "0.23-0.4i"); tst(2.+3i, 0, "2.+3i"); tst(0.5+0.8660254037844386i, 0, "0.5+0.8660254037844386i"); tst(0.999+0.001i, 0, "0.999+0.001i"); tst(0.999-0.001i, 0, "0.999-0.001i"); tst(1.001+0.001i, 0, "1.001+0.001i"); tst(1.001-0.001i, 0, "1.001-0.001i"); tst(0.11+0.9i, 0, "0.11+0.9i");} else {C pa; int tc = 0, tw=0; R x = -1.01; while(x < 1.011) {R y = -0.02; while (y < 1.011){ wrk = 0; dilog(c(x, y)); if(wrk > tc) {pa = c(x, y); tc = wrk;} tw += wrk; y += 0.001;} x += 0.001;} printf("Max count, tw = %d, %5.2f\n", tc, tw/2083651.); pc(pa);} return 0;} /* Three functional equations corroborated: -0.5125514569376060 + 0.3753329566550972i 0.0000000000000000 rel1 -0.4783427691711131 + 0.3007754948400878i -0.4783427691711135 + 0.3007754948400879i w= 63 19 -0.4783427691711135 + 0.3007754948400879i 0.8380000000000000 + -0.1300000000000000i 0.0000000000000000 rel2 1.1180086749729419 + -0.2718669089150707i 1.1180086749729423 + -0.2718669089150709i w= 162 12 1.1180086749729423 + -0.2718669089150709i -0.9000000000000000 + 0.1200000000000000i 0.0000000000000000 xx -0.7536563997933813 + 0.0855363530169917i -0.7536563997933812 + 0.0855363530169917i w= 265 23 -0.7536563997933813 + 0.0855363530169917i Mostly known values for increasing argments on the real line: -1.6180339887498949 + 0.0000000000000000i -1.2185252606861301 -(r5+1)/2 -1.2185252606861301 + -0.0000000000000000i -1.2185252606861305 + 0.0000000000000000i w= 60 32 -1.6180339887498949 + 0.0000000000000000i -0.5421912164506933 -(r5+1)/2 W -1.2185252606861301 + -0.0000000000000000i -1.2185252606861305 + 0.0000000000000000i w= 60 32 -1.6180339887498949 + 0.0000000000000000i -0.8711780298203387 -(r5+1)/2 W -1.2185252606861301 + -0.0000000000000000i -1.2185252606861305 + 0.0000000000000000i w= 60 32 -1.0000000000000000 + 0.0000000000000000i -0.8224670334241132 -1 -0.8224670334241133 + 0.0000000000000000i -0.8224670334241131 + -0.0000000000000000i w=100000001 24 -0.6180339887498949 + 0.0000000000000000i -0.5421912164506932 (1-r5)/2 -0.5421912164506933 + 0.0000000000000000i -0.5421912164506930 + -0.0000000000000000i w= 60 32 -0.2690000000000000 + 0.0000000000000000i 0.0000000000000000 -0.269 -0.2527928250522439 + 0.0000000000000000i -0.2527928250522439 + 0.0000000000000000i w= 24 24 -0.2680000000000000 + 0.0000000000000000i 0.0000000000000000 -0.268 -0.2519070332294852 + 0.0000000000000000i -0.2519070332294851 + 0.0000000000000000i w= 24 24 0.0000000000000000 + 0.0000000000000000i 0.0000000000000000 0 0.0000000000000000 + 0.0000000000000000i 0.0000000000000000 + 0.0000000000000000i w= 1 1 0.3819660112501051 + 0.0000000000000000i 0.4264088061620961 (3-r5)/2 0.4264088061620961 + 0.0000000000000000i 0.4264088061620960 + 0.0000000000000000i w= 32 18 0.5000000000000000 + 0.0000000000000000i 0.5822405264650126 1/2 0.5822405264650125 + 0.0000000000000000i 0.5822405264650123 + 0.0000000000000000i w= 43 24 0.6180339887498949 + 0.0000000000000000i 0.7553956195317414 (r5-1)/2 0.7553956195317414 + 0.0000000000000000i 0.7553956195317415 + 0.0000000000000000i w= 60 18 0.8999900000000000 + 0.0000000000000000i 0.0000000000000000 0.89999 1.2996891391395520 + 0.0000000000000000i 1.2996891391395529 + 0.0000000000000000i w= 246 9 0.9000100000000000 + 0.0000000000000000i 0.0000000000000000 0.90001 1.2997403076972049 + 0.0000000000000000i 1.2997403076972058 + 0.0000000000000000i w= 246 9 0.9999900000000000 + 0.0000000000000000i 0.0000000000000000 .99999 1.6448089369845762 + 0.0000000000000000i 1.6448089369929271 + 0.0000000000000000i w= 934565 1 1.0000000000000000 + 0.0000000000000000i 1.6449340668482264 1 1.6449340568482267 + 0.0000000000000000i 1.6449340668482264 + 0.0000000000000000i w=100000001 1 1.6180339887498949 + 0.0000000000000000i 7.1219274838435984 (r5+1)/2 W 2.4186901038761142 + -1.5117715344277867i 2.4186901038761137 + -1.5117715344277867i w= 60 18 2.0000000000000000 + 0.0000000000000000i 0.0000000000000000 2 2.4674011002723399 + -2.1775860903036022i 2.4674011002723399 + -2.1775860903036022i w= 43 24 2.6180339887498949 + 0.0000000000000000i -7.4692747147093899 (r5+3)/2 W 2.4003296863799677 + -3.0235430688555738i 2.4003296863799677 + -3.0235430688555738i w= 32 18 Some ad-hoc probes Li2(2) = 2.4674011002723399 + -2.1775860903036022i 2.4674011002723395 + 2.1775860903036022i 0.5000000000000000 + 0.8660254037844386i 0.0000000000000000 c(0.5, sqrt(3)/2) 0.2741556778080378 + 1.0149416064096535i 0.2741556778080378 + 1.0149416064096535i w= 93060487 58 -0.5000000000000000 + 0.8660254037844386i 0.0000000000000000 c(-0.5, sqrt(3)/2) -0.5483113556160755 + 0.6766277376064358i -0.5483113556160755 + 0.6766277376064358i w= 93060487 29 0.8660254037844386 + 0.5000000000000000i 0.0000000000000000 csqrt(c(0.5, sqrt(3)/2)) 0.8910059528761225 + 0.8643791310538929i 0.8910059528761227 + 0.8643791310538929i w= 93060487 25 0.0000000000000000 + 0.5000000000000000i 0.0000000000000000 0+0.5i -0.0589750744215659 + 0.4872223582945224i -0.0589750744215659 + 0.4872223582945226i w= 43 24 0.0000000000000000 + 1.0000000000000000i 0.0000000000000000 0+1.i -0.2056167583560283 + 0.9159655941772190i -0.2056167583560283 + 0.9159655941772193i w=100000001 45 0.2300000000000000 + -0.4000000000000000i 0.0000000000000000 0.23-0.4i 0.1916195524960158 + -0.4428626779408241i 0.1916195524960156 + -0.4428626779408241i w= 38 22 2.0000000000000000 + 3.0000000000000000i 0.0000000000000000 2.+3i -0.2809880553780608 + 3.0172512063694064i -0.2809880553780608 + 3.0172512063694064i w= 24 15 0.5000000000000000 + 0.8660254037844386i 0.0000000000000000 0.5+0.8660254037844386i 0.2741556778080378 + 1.0149416064096535i 0.2741556778080378 + 1.0149416064096535i w= 93060487 58 0.9990000000000000 + 0.0010000000000000i 0.0000000000000000 0.999+0.001i 1.6365867056774774 + 0.0067828498277630i 1.6365867056775252 + 0.0067828498277161i w= 17321 3 0.9990000000000000 + -0.0010000000000000i 0.0000000000000000 0.999-0.001i 1.6365867056774774 + -0.0067828498277630i 1.6365867056775252 + -0.0067828498277161i w= 17321 3 1.0009999999999999 + 0.0010000000000000i 0.0000000000000000 1.001+0.001i 1.6501414040809399 + 0.0099103180251496i 1.6501414040808937 + 0.0099103180251011i w= 17322 3 1.0009999999999999 + -0.0010000000000000i 0.0000000000000000 1.001-0.001i 1.6501414040809399 + -0.0099103180251496i 1.6501414040808937 + -0.0099103180251011i w= 17322 3 0.1100000000000000 + 0.9000000000000000i 0.0000000000000000 0.11+0.9i -0.0810971714351589 + 0.8740867676634512i -0.0810971714351590 + 0.8740867676634509i w= 262 47 */