Revision history [back]

A slight complement to Nasser's aswer :

Contemplate :

sage: graphics_array(([f(t).demoivre(force=True).simplify_full().integrate(t, algorithm=u).plot((0,2*pi), title=u) for u in ("maxima", "giac", "fricas", "mathematica_free")]),ncols=2)


(sympy fails to integrate the expression).

maxima problems with various trig integrals have been documented for a long time... giac, fricas and mathematica give different expressions of similar functions (up to a constant), but proving the identities isn't trivlal (long algebrico/trigonometric massage ahead...).

But note :

sage: table([[u, f(t).demoivre(force=True).simplify_full().integrate(t, algorithm=u)] for u in ("maxima", "giac", "fricas", "mathematica_free")], header_row=["Algorithm", "Antiderivative"])
Algorithm          Antiderivative
+------------------+---------------------------------------------------+
maxima             -4/sqrt(sin(t)^2/(cos(t) + 1)^2 + 1)
giac               -4*cos(1/2*t)*sgn(sin(1/2*t)) + 4*sgn(sin(1/2*t))
fricas             -2*(cos(t) + 1)*sqrt(-2*cos(t) + 2)/sin(t)
mathematica_free   -2*sqrt(-2*cos(t) + 2)*cot(1/2*t)


ALL those "CAS primitives" are periodic of period $2\pi$, whereas the function $\displaystyle\int_0^t f(t)\,dt$ is not ($f$ is positive except for a null-measure set ($t=2k\pi,\ k\in\mathbb{Z}$) where it is zero, therefore its integral is increasing). Computing the integral by taking limits of the primitive at bounds is wrong.

This happens to be plotted in the above figure for the fricas and mathematica cases. This (and the fact that it is not plotted for giac) is pure numerical happenstance...

Morality : never trust a CAS result without checking it...

HTH,

A slight complement to Nasser's aswer answer :

Contemplate :

sage: graphics_array(([f(t).demoivre(force=True).simplify_full().integrate(t, algorithm=u).plot((0,2*pi), title=u) for u in ("maxima", "giac", "fricas", "mathematica_free")]),ncols=2)


(sympy fails to integrate the expression).

maxima problems with various trig integrals have been documented for a long time... giac, fricas and mathematica give different expressions of similar functions (up to a constant), but proving the identities isn't trivlal (long algebrico/trigonometric massage ahead...).

But note :

sage: table([[u, f(t).demoivre(force=True).simplify_full().integrate(t, algorithm=u)] for u in ("maxima", "giac", "fricas", "mathematica_free")], header_row=["Algorithm", "Antiderivative"])
Algorithm          Antiderivative
+------------------+---------------------------------------------------+
maxima             -4/sqrt(sin(t)^2/(cos(t) + 1)^2 + 1)
giac               -4*cos(1/2*t)*sgn(sin(1/2*t)) + 4*sgn(sin(1/2*t))
fricas             -2*(cos(t) + 1)*sqrt(-2*cos(t) + 2)/sin(t)
mathematica_free   -2*sqrt(-2*cos(t) + 2)*cot(1/2*t)


ALL those "CAS primitives" are periodic of period $2\pi$, whereas the function $\displaystyle\int_0^t f(t)\,dt$ is not ($f$ is positive except for a null-measure set ($t=2k\pi,\ k\in\mathbb{Z}$) where it is zero, therefore its integral is increasing). Computing the integral by taking limits of the primitive at bounds is wrong.

This happens to be plotted in the above figure for the fricas and mathematica cases. This (and the fact that it is not plotted for giac) is pure numerical happenstance...

Morality : never trust a CAS result without checking it...

HTH,