sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.35k stars 462 forks source link

Wrong integrate(log(cot(x)-1),x,0,pi/4) (regression) #30389

Open edd8e884-f507-429a-b577-5d554626c0fe opened 4 years ago

edd8e884-f507-429a-b577-5d554626c0fe commented 4 years ago

Upgrading Maxima to 5.44.0 (see #30063) leads to the following regression:

sage: a = integral(log(cot(x) - 1), x, 0, pi/4); a
1/4*pi*(I*pi + log(2)) - 1/2*pi*log(2) - 1/2*I*dilog(I + 1) + 1/2*I*dilog(-I + 1) + 1/2*I*dilog(1/2*I + 1/2) - 1/2*I*dilog(-1/2*I + 1/2)

Whose numerical value is 2.467401100272339*I+0.2721982612879502 while it should be 0.2721982612879502.

This integral had previously been wrong for a different reason and had been fixed upstream in https://sourceforge.net/p/maxima/bugs/2501/; the doctest was added in #13733.

The bug is doctested and marked as # known bug in src/sage/symbolic/integration/integral.py (once #30063 is merged).

The bug is reported upstream as https://sourceforge.net/p/maxima/bugs/3649/

Upstream: Reported upstream. Developers acknowledge bug.

CC: @kiwifb

Component: symbolics

Keywords: integral, maxima

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

edd8e884-f507-429a-b577-5d554626c0fe commented 4 years ago

Upstream: Reported upstream. No feedback yet.

pjbruin commented 4 years ago
comment:2

I found this commit message in the Maxima Git log; the first integral mentioned is exactly the regression in Sage.

commit 47a6afd1d4691b83bedd197dea322dfd64f4f0f9
Author: Dan Gildea <dgildea>
Date:   Fri Dec 28 15:50:26 2018 -0500

    add series expansion for expintegral_si and gamma_incomplete

    remove fallback to unevaluated derivative - this was a mistake

    unfortunately 3 integrals from the test suite now fail, due
    to the singularity at li[2](1):
     integrate(log(cot(x) - 1), x, 0, %pi/4);           /* rtest16  524 */
     integrate(log(cos(x)), x, 0, %pi/2);                   /* rtest16  525 */
     integrate((log((2-x)/2)+log(2))/(1-x), x, 0, 1);   /* rtestint 232 */
    marked as expected failures.

    Fixes #3484
pjbruin commented 4 years ago
comment:3

Similar bug (numerical integral of sin(x)/x is off by π): #11164

pjbruin commented 4 years ago

Changed upstream from Reported upstream. No feedback yet. to Reported upstream. Developers acknowledge bug.

pjbruin commented 4 years ago

Description changed:

--- 
+++ 
@@ -7,6 +7,8 @@

 Whose numerical value is `2.467401100272339*I+0.2721982612879502` while it should be `0.2721982612879502`.

+This integral had previously been wrong for a different reason and had been fixed upstream in [https://sourceforge.net/p/maxima/bugs/2501/](https://sourceforge.net/p/maxima/bugs/2501/); the doctest was added in #13733.
+
 The bug is doctested and marked as `# known bug` in `src/sage/symbolic/integration/integral.py` (once #30063 is merged).

 The bug is reported upstream as https://sourceforge.net/p/maxima/bugs/3649/
fchapoton commented 3 years ago

Changed keywords from none to integral, maxima

mkoeppe commented 3 years ago
comment:8

Moving to 9.4, as 9.3 has been released.