rtoy / maxima

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

Incorrect integral of rational expression of trigonometric function #592

Open rtoy opened 1 month ago

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-03 02:04:15 Created by mforets on 2017-03-19 14:00:03 Original: https://sourceforge.net/p/maxima/bugs/3295


integrate((2*cos(2*%pi*x) - cos(4*%pi*x)) / (5 - 4*cos(2*%pi*x)), x, 0, 1);

returns 23/24 (tested in maxima-online.org), but the result should be 1/4.

See also: https://trac.sagemath.org/ticket/17968

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-03 02:04:16 Created by mforets on 2017-03-19 14:02:00 Original: https://sourceforge.net/p/maxima/bugs/3295/#5d84


ooops.. posted the wrong link! See also: https://trac.sagemath.org/ticket/21440

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-03 02:04:19 Created by tomasriker on 2017-03-19 21:04:06 Original: https://sourceforge.net/p/maxima/bugs/3295/#c269


Maxima's antiderivative has a discontinuity at x=1/2, which it doesn't detect, so it just does F(1)-F(0). I believe that's where the error comes from.

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-03 02:04:23 Created by robert_dodier on 2017-03-20 04:48:48 Original: https://sourceforge.net/p/maxima/bugs/3295/#c269/f06e


I dunno if ignoring the discontinuity is the only problem here. integrate(..., x, 0, 1/2) returns 23/24 which seems to be incorrect (should be 1/8 I guess).

integrate(..., x) returns an antiderivative and then ev(%, x = 1/2 - foo) - ev(%, x = 0) followed by limit(%, foo, 0, plus) yields 1/8. I don't know where it goes wrong.

rtoy commented 1 month ago

Imported from SourceForge on 2024-07-03 02:04:26 Created by numzero on 2017-06-13 17:44:09 Original: https://sourceforge.net/p/maxima/bugs/3295/#9485


The same problem here:

integrate(
(1 / %pi) * sqrt(r) * (1 - r) *
(cos(2 * psi) - 1) *
(
    (cos((phi + psi)/2)) / (1 - 2*r*cos(phi + psi) + r^2) +
    (cos((phi - psi)/2)) / (1 - 2*r*cos(phi - psi) + r^2)
)
, psi, 0, %pi
);

Numerical solution seems to be right (it is calculated at r=0.99; at r=1.00 it should be cos(2 * phi) - 1), but symbolic one is radically different. Note that it is calculated using ldefint; integrate yields similarly looking non-smooth function (full of atan(tan(phi)))

Attachments: