Ask Your Question

Revision history [back]

Integrate() Error

For: SageMath version 9.0, Release Date: 2020-01-01 When integrating this:

t = var('t'); f(t) = (sin(2*t)*sin(t))/(cos(t)+3)
a_2 = integrate(f, t, 0, pi)*2/(2*pi)
a_2

Output:

-17

I get -17 ?!

If I just replace sin(2t) with its identity 2sin(t)*cos(t), and integrate again:

t = var('t'); f(t) = (2*sin(t)*cos(t)*sin(t))/(cos(t)+3)
a_2 = integrate(f, t, 0, pi)*2/(2*pi)
a_2

Output:

   -(470832*sqrt(2) - 665857)/(13860*sqrt(2) - 19601)

This last value is the correct one. Simplifying this expression (which I don't know how to do in Sage), you have:

(12*sqrt(2)-17)

It seems like the first result, wrongly reporting -17, somehow is missing the 12*sqrt(2) part of it.