Opened 10 years ago

Closed 5 years ago

Incorrect integral in Maxima

Reported by: Owned by: kcrisman burcin trivial sage-6.4 calculus Peter Bruin Ralf Stephan, Frédéric Chapoton N/A 59bb147

Description

```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.

comment:1 Changed 9 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 9 years ago by kcrisman

See #13973 for where we might fix this.

comment:3 Changed 9 years ago by jdemeyer

• Milestone changed from sage-5.11 to sage-5.12

comment:4 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

comment:5 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

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

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

comment:8 follow-up: ↓ 12 Changed 8 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 8 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4

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

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

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

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 5 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?

I vote yes.

comment:15 Changed 5 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 5 years ago by pbruin

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

comment:17 Changed 5 years ago by rws

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

comment:18 Changed 5 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 5 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**********************************************************************
6781   1 of 125 in sage.symbolic.integration.integral.integrate
6782    [168 tests, 1 failure, 16.86 s]
```

comment:20 Changed 5 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 5 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 5 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

comment:23 Changed 22 months ago by tmonteil

• Commit 59bb147f4c66f3f519d0d388c0b86e40f407e047 deleted

Follow-up: a bug with this integral reappared in recent Maxima release, see #30063

Note: See TracTickets for help on using tickets.