rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

integrate(a^2*(1-cos(t))^2*sqrt(a^2*sin(t)^2+a^2*(1-cos(t))^2), t, 0, 2*%pi) wrong result #1159

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:43:14 Created by sergniko on 2022-03-28 19:25:25 Original: https://sourceforge.net/p/maxima/bugs/3961


Maxima get this results

(%i39)  integrate(a^2*(1-cos(t))^2*sqrt(a^2*sin(t)^2+a^2*(1-cos(t))^2), t, 0, 2*%pi);
(%o39)  (188*a^3)/15

but Wolfram Alpha's answer is (256 a^3)/15 if you change upper limit to %pi

(%i40)  integrate(a^2*(1-cos(t))^2*sqrt(a^2*sin(t)^2+a^2*(1-cos(t))^2), t, 0, %pi);
(%o40)  (128*a^3)/15

or change

(%i41)  integrate(a^2*(1-cos(t))^2*sqrt(a^2*sin(t)^2+a^2*(1-cos(t))^2), t, %pi, 2*%pi);
(%o41)  (128*a^3)/15

the answer is correct.

wxMaxima version: 21.05.2_MSW using wxWidgets version: wxWidgets 3.1.4 Maxima version: 5.45.1 Maxima build date: 2021-07-04 21:51:12 Host type: x86_64-w64-mingw32 System type: Win32 6.2.9200 X86-64 Lisp implementation type: SBCL Lisp implementation version: 2.0.0 wxMaxima's idea of the directory layout is: User configuration dir: C:\Users\serg/maxima/ Help dir: C:\maxima-5.45.1\share/doc/wxmaxima

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:43:16 Created by robert_dodier on 2022-04-02 19:42:30 Original: https://sourceforge.net/p/maxima/bugs/3961/#2af3


Thanks for the report, a couple of notes. (1) Looks like the bug still happens with a = 1. I'll look for a simpler example too.

(2) Looks like integrate is calling RISCHINT to get an antiderivative, and then evaluating that. Looks like the antiderivative is invalid -- plotting the result from integrate(..., t) (i.e., indefinite integral) shows that it seems to switch from one branch of sqrt to the other at t = %pi. So that seems to be a bug in RISCHINT -- it's not noticing the issue with sqrt.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:43:20 Created by robert_dodier on 2022-04-03 04:29:35 Original: https://sourceforge.net/p/maxima/bugs/3961/#496d


A simpler example which shows the bug is just

risch (sqrt (sin(t)^2 + (1 - cos(t))^2), t);
rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:43:23 Created by robert_dodier on 2022-04-03 04:52:21 Original: https://sourceforge.net/p/maxima/bugs/3961/#dc64


For both the original example and the smaller one I found, I see that the result contains atan2(sin(t), cos(t)). I think the problem stems from that, not from RISCHINT.

Substituting atan2(sin(t), cos(t)) = t and then evaluating the result at 2*%pi and 0 yields 256/15 (with a = 1), which agrees with Mma.

Plotting atan2(sin(t), cos(t)) over 0 to 2*%pi shows a jump at t = %pi when it changes from %pi to - %pi.

Maxima assumes atan2 returns a result in the range [- %pi, %pi] instead of [0, 2*%pi]. I'm not sure what would need to change, but from what I remember, that assumption is pretty deeply ingrained.

A related issue is that RISCHINT converts trig functions to complex exponentials and then works on that. I guess we would want to verify that the complex exponential result is correct, so that it's only the final step, involving a complex exponential which ended up as atan2(sin(t), cos(t)), is problematic.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:43:27 Created by robert_dodier on 2022-04-03 22:03:20 Original: https://sourceforge.net/p/maxima/bugs/3961/#7391