ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 05 Feb 2015 09:50:39 +0100I don't know why Sage return 0 for integrate(sin(2*x).abs(),(x,0,pi)) when its value is 2https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-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=Integrate[Abs[Sin[2*x]]%2C{x%2C0%2CPi}]
Neither Sympy nor Maxima can't compute this.Sun, 14 Dec 2014 16:25:05 +0100https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/Answer by kcrisman for <p>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</p>
<p>Mathematica can do It without any problem <a href="http://www.wolframalpha.com/input/?i=Integrate[Abs[Sin[2*x]],%7Bx,0,Pi%7D]">http://www.wolframalpha.com/input/?i=...</a></p>
<p>Neither Sympy nor Maxima can't compute this.</p>
https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/?answer=25281#post-id-25281Interestingly,
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](http://trac.sagemath.org/ticket/17511) but there are lots of places this question has recurred.Mon, 15 Dec 2014 17:10:25 +0100https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/?answer=25281#post-id-25281Answer by tmonteil for <p>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</p>
<p>Mathematica can do It without any problem <a href="http://www.wolframalpha.com/input/?i=Integrate[Abs[Sin[2*x]],%7Bx,0,Pi%7D]">http://www.wolframalpha.com/input/?i=...</a></p>
<p>Neither Sympy nor Maxima can't compute this.</p>
https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/?answer=25271#post-id-25271They are indeed some issues with integrals involving absolute values, see [a list here](http://trac.sagemath.org/ticket/12731) At least in your case no wrong answer is returned.
Sun, 14 Dec 2014 20:59:11 +0100https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/?answer=25271#post-id-25271Comment by slelievre for <p>They are indeed some issues with integrals involving absolute values, see <a href="http://trac.sagemath.org/ticket/12731">a list here</a> At least in your case no wrong answer is returned.</p>
https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/?comment=25731#post-id-25731@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.Thu, 05 Feb 2015 09:50:39 +0100https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/?comment=25731#post-id-25731Answer by marguin for <p>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</p>
<p>Mathematica can do It without any problem <a href="http://www.wolframalpha.com/input/?i=Integrate[Abs[Sin[2*x]],%7Bx,0,Pi%7D]">http://www.wolframalpha.com/input/?i=...</a></p>
<p>Neither Sympy nor Maxima can't compute this.</p>
https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/?answer=25695#post-id-25695With Sage-4.7, integrate(abs(sin(t)),t,0,pi) returns 2 as expected. Tue, 03 Feb 2015 15:41:30 +0100https://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/?answer=25695#post-id-25695