Opened 7 years ago

Closed 2 years ago

#13733 closed task (fixed)

Incorrect integral in Maxima

Reported by: kcrisman Owned by: burcin
Priority: trivial Milestone: sage-6.4
Component: calculus Keywords:
Cc: Merged in:
Authors: Peter Bruin Reviewers: Ralf Stephan, Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 59bb147 (Commits) Commit: 59bb147f4c66f3f519d0d388c0b86e40f407e047
Dependencies: Stopgaps:

Description

See this ask.sagemath.org question.

sage: integral(log(cot(x)-1),x,0,pi/4)

ValueError: Integral is divergent.

But according to the poster it is pi log(2) / 8. And indeed in the most recent Maxima (5.28) we have

(%i5) display2d:false;

(%o5) false
(%i6) integrate(log(cot(x)-1),x,0,%pi/4);

Is %pi/8 an ?integer?

n;
Is %pi/4 an ?integer?

n;
Is 2*%pi an ?integer?

n;
(%o6) -(%i*(2*li[2](%i+1)-2*li[2](1-%i))+%pi*log(2))/4
 +%i*li[2]((%i+1)/2)/2-%i*li[2](-(%i-1)/2)/2

though with the interaction this is not an improvement we can immediately use.

Change History (22)

comment:1 Changed 7 years ago by kcrisman

  • Report Upstream changed from N/A to Fixed upstream, but not in a stable release.

According to the upstream report, that problem is also fixed here and there is also a commit of the integral in question as a test.

expand(integrate(log(cot(x)-1),x,0,%pi/4));
-%i*li[2](%i+1)/2+%i*li[2](%i/2+1/2)/2-%i*li[2](1/2-%i/2)/2+%i*li[2](1-%i)/2-%pi*log(2)/4$

So I guess when the next Maxima after 5.29.1 is ready and we put it in, we can try to close this report with a doctest.

comment:2 Changed 7 years ago by kcrisman

See #13973 for where we might fix this.

comment:3 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:4 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:5 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:6 follow-ups: Changed 5 years ago by pbruin

Maxima 5.33 returns the answer without asking any questions.

comment:7 in reply to: ↑ 6 Changed 5 years ago by kcrisman

Great, then all that's needed is a doctest once #13973 is ready.

Maxima 5.33 returns the answer without asking any questions.

comment:8 follow-up: Changed 5 years ago by pbruin

Unfortunately the fact that Sage loads the abs_integrate package causes this to fail when called from within Sage with the message PSLOG: internal error. So we still have to look into that.

comment:9 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:10 Changed 5 years ago by kcrisman

See also #12731.

comment:11 in reply to: ↑ 6 Changed 5 years ago by rws

Replying to pbruin:

Maxima 5.33 returns the answer without asking any questions.

Maybe but 5.35 is back to original (PSLOG: internal error).

comment:12 in reply to: ↑ 8 Changed 5 years ago by rws

Replying to pbruin:

Unfortunately the fact that Sage loads the abs_integrate package causes this to fail when called from within Sage with the message PSLOG: internal error. So we still have to look into that.

Maybe but Sage+Maxima-5.35 without abs_integrate gives -1/4*pi*log(2) - 1/2*I*polylog(2, I + 1) + 1/2*I*polylog(2, -I + 1) + 1/2*I*polylog(2, 1/2*I + 1/2) - 1/2*I*polylog(2, -1/2*I + 1/2) so this is not resolved either way.

comment:13 Changed 3 years ago by pbruin

In SageMath 7.6.beta2, the answer appears to be correct up to simplification (probably thanks to Maxima commit ce7c53f1):

sage: integral(log(cot(x)-1),x,0,pi/4)
-1/4*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)
sage: N(_)
0.272198261287950
sage: N(pi*log(2)/8)
0.272198261287950

Should we add this as a doctest and declare the bug to be fixed?

comment:14 Changed 3 years ago by kcrisman

I vote yes.

comment:15 Changed 3 years ago by pbruin

  • Authors set to Peter Bruin
  • Branch set to u/pbruin/13733-doctest_fixed_integral
  • Commit set to 325a20b12351c8af8e6e633d7e81d0fa019316ec
  • Report Upstream changed from Fixed upstream, but not in a stable release. to N/A
  • Status changed from new to needs_review

comment:16 Changed 3 years ago by pbruin

  • Priority changed from major to trivial
  • Type changed from defect to task

comment:17 Changed 3 years ago by rws

  • Reviewers set to Ralf Stephan
  • Status changed from needs_review to positive_review

comment:18 Changed 3 years ago by vbraun

  • Branch changed from u/pbruin/13733-doctest_fixed_integral to 325a20b12351c8af8e6e633d7e81d0fa019316ec
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:19 Changed 3 years ago by vbraun

  • Commit 325a20b12351c8af8e6e633d7e81d0fa019316ec deleted
  • Resolution fixed deleted
  • Status changed from closed to new

On one of the 32-bit buildbots:

sage -t --long src/sage/symbolic/integration/integral.py
6771**********************************************************************
6772File "src/sage/symbolic/integration/integral.py", line 771, in sage.symbolic.integration.integral.integrate
6773Failed example:
6774    N(a)  # long time
6775Expected:
6776    0.272198261287950
6777Got:
6778    0.272198261287950 + 5.55111512312578e-17*I
6779**********************************************************************
67801 item had failures:
6781   1 of 125 in sage.symbolic.integration.integral.integrate
6782    [168 tests, 1 failure, 16.86 s]

comment:20 Changed 3 years ago by pbruin

  • Branch changed from 325a20b12351c8af8e6e633d7e81d0fa019316ec to u/pbruin/13733-doctest_fixed_integral
  • Commit set to 59bb147f4c66f3f519d0d388c0b86e40f407e047
  • Status changed from new to needs_review

The doctest should now be more robust.

comment:21 Changed 2 years ago by chapoton

  • Reviewers changed from Ralf Stephan to Ralf Stephan, Frédéric Chapoton
  • Status changed from needs_review to positive_review

comment:22 Changed 2 years ago by vbraun

  • Branch changed from u/pbruin/13733-doctest_fixed_integral to 59bb147f4c66f3f519d0d388c0b86e40f407e047
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.