# I don't know why Sage return 0 for integrate(sin(2*x).abs(),(x,0,pi)) when its value is 2

When I try integrate(sin(x).abs(),(x,0,pi)) the program return the same thing. The numerical integration is correct, the program return (1.9999999999999998, 2.220446049250313e-14). I don't know if it is a bug or what. Any help? I have tried sage 6.2, 6.3, 6.4.1

Mathematica can do It without any problem http://www.wolframalpha.com/input/?i=...

Neither Sympy nor Maxima can't compute this.

edit retag close merge delete

Sort by » oldest newest most voted

They are indeed some issues with integrals involving absolute values, see a list here At least in your case no wrong answer is returned.

more

@tmonteil: The question's title suggests that a wrong answer is indeed returned, even if the text of the question counterbalances that by the fact that numerical integration is correct.

Interestingly,

sage: integrate(abs(sin(x)),x)
-(2*arctan(sin(x)/(cos(x) + 1))*sin(x)/(cos(x) + 1) - log(2))*sgn(1/(cos(x) + 1))*sgn(sin(x)) - log(2*sin(x)^2/(cos(x) + 1)^2 + 2)*sgn(1/(cos(x) + 1))*sgn(sin(x)) + log(sin(x)^2/(cos(x) + 1)^2 + 1)*sgn(1/(cos(x) + 1))*sgn(sin(x)) + 2*(sin(x)/((sin(x)^2/(cos(x) + 1)^2 + 1)*(cos(x) + 1)) + arctan(sin(x)/(cos(x) + 1)))*abs(sin(x))/abs(cos(x) + 1)


Not that this is all that useful, because if we call this f then f(pi) has division by zero error, and based on comments elsewhere it is probably wrong in any case. I have to admit I am surprised this isn't doable, though. See this ticket 17511 but there are lots of places this question has recurred.

more

With Sage-4.7, integrate(abs(sin(t)),t,0,pi) returns 2 as expected.

more