sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.21k stars 421 forks source link

Missing dilog(2) simplification #15504

Open ppurka opened 10 years ago

ppurka commented 10 years ago

From google spreadsheet which no one reads X-(

sage: integrate(log(1+x)/x,x)
 log(x + 1)*log(-x) + polylog(2, x + 1)
sage: integrate(log(1+x)/x,x,0,1) 
 -1/6*pi^2 + I*pi*log(2) + polylog(2, 2)

Since dilog(2) = -pi<sup>2/4+log(2)</sup>2/2-1/2*(log(2)+I*pi)^2 the result is simply pi^2/12.

CC: @sagetrac-jakobkroeker @kcrisman @rwst

Component: calculus

Issue created by migration from https://trac.sagemath.org/ticket/15504

ppurka commented 10 years ago

Description changed:

--- 
+++ 
@@ -12,3 +12,7 @@
 Both of which are wrong according to 2.728 of Gradshteyn & Ryzhik. Actually the second example is obviously wrong since the integration is a real function over a real interval.

 Should I report the error to Maxima? That seems to be the source.
+
+PS:
+1. The "I" above is not me (ppurka)
+2. I am done scrounging through the google spreadsheet for bugs, for now.
kcrisman commented 10 years ago
comment:2

(%i6) integrate(log(1+x)/x,x,0,1);
                                                      2
                                                   %pi
(%o6)                   log(- 1) log(2) + li (2) - ----
                                            2       6
(%i7) integrate(log(1+x)/x,x);
(%o7)                  log(- x) log(x + 1) + li (x + 1)
                                               2

Apparently in Maxima.

rwst commented 9 years ago
comment:6

For completeness, sympy has

In [1]: integrate(log(1+x)/x)
Out[1]: 
        ⎛      ⅈ⋅π⎞
-polylog⎝2, x⋅ℯ   ⎠

In [2]: integrate(log(1+x)/x,(x,0,1))
Out[2]: 
        ⎛    ⅈ⋅π⎞
-polylog⎝2, ℯ   ⎠

while Wolfram says integral (log(1+x))/x dx = -Li_2(-x)+constant. The sympy solution will also only be available with sympy-0.7.8 because of a missing polylog._sage_ method in earlier versions.

rwst commented 8 years ago
comment:7
sage: integrate(log(1+x)/x,x,algorithm='sympy')
-polylog(2, -x)
ea1d0bf8-c27a-4548-8cb7-de0b1d02441a commented 7 years ago
comment:8

If this answer is wrong, mark it for a stopgap or even create one

c22b6800-ec0b-4cbf-94c4-0a74aecc2093 commented 7 years ago
comment:9

as of v8.0.beta3, Maxima is correct:

sage: integrate(log(1+x)/x, x, 0, 1, algorithm='maxima')
-1/6*pi^2 + I*pi*log(2) + dilog(2)
sage: _.n()
0.822467033424113
sage: N(pi^2/12)
0.822467033424113

see W|A)

the imaginary part vanishes because of the identity dilog(2) = -pi<sup>2/4+log(2)</sup>2/2-1/2*(log(2)+I*pi)^2, which doesn't seem to be recognised.

rwst commented 7 years ago

Description changed:

--- 
+++ 
@@ -1,6 +1,4 @@
 From google spreadsheet which no one reads `X-(`
-
-A simple integration error.

sage: integrate(log(1+x)/x,x) @@ -9,10 +7,4 @@ -1/6pi^2 + Ipi*log(2) + polylog(2, 2)


-Both of which are wrong according to 2.728 of Gradshteyn & Ryzhik. Actually the second example is obviously wrong since the integration is a real function over a real interval.
-
-Should I report the error to Maxima? That seems to be the source.
-
-PS:
-1. The "I" above is not me (ppurka)
-2. I am done scrounging through the google spreadsheet for bugs, for now.
+Since `dilog(2) = -pi<sup>2/4+log(2)</sup>2/2-1/2*(log(2)+I*pi)^2` the result is simply `pi^2/12`.
rwst commented 7 years ago
comment:10

So I think we can at least relabel this. As the answer is correct it becomes a mere enhancement ticket.

kcrisman commented 7 years ago
comment:11

What does giac do, out of curiosity?

c22b6800-ec0b-4cbf-94c4-0a74aecc2093 commented 7 years ago
comment:12

Replying to @kcrisman:

What does giac do, out of curiosity?

.. it's quite fun. in that list in github i started to evaluate the integral tickets with different algorithms.