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.Mon, 27 Apr 2015 04:16:45 +0200integral(abs(cos(x)),(x,0,pi))https://ask.sagemath.org/question/26646/integralabscosxx0pi/this is for sure 2, however it evaluates to -1 !!! Is there anything wrong with the statement itself? Any suggestion?Sun, 26 Apr 2015 19:06:05 +0200https://ask.sagemath.org/question/26646/integralabscosxx0pi/Answer by calc314 for <p>this is for sure 2, however it evaluates to -1 !!! Is there anything wrong with the statement itself? Any suggestion?</p>
https://ask.sagemath.org/question/26646/integralabscosxx0pi/?answer=26649#post-id-26649It is my understanding that Maxima has a difficult time with absolute values in integrals. You can get the answer using a numerical approximation via:
numerical_integral(abs(cos(x)),0,pi)
Or via `sympy` you can use:
import sympy
print sympy.integrals.integrate(abs(cos(x)),(x,0,pi)).n()
Sun, 26 Apr 2015 21:48:57 +0200https://ask.sagemath.org/question/26646/integralabscosxx0pi/?answer=26649#post-id-26649Comment by Vangelis for <p>It is my understanding that Maxima has a difficult time with absolute values in integrals. You can get the answer using a numerical approximation via:</p>
<pre><code>numerical_integral(abs(cos(x)),0,pi)
</code></pre>
<p>Or via <code>sympy</code> you can use:</p>
<pre><code>import sympy
print sympy.integrals.integrate(abs(cos(x)),(x,0,pi)).n()
</code></pre>
https://ask.sagemath.org/question/26646/integralabscosxx0pi/?comment=26651#post-id-26651thanks
Both of your suggestions work!!! Sun, 26 Apr 2015 23:35:43 +0200https://ask.sagemath.org/question/26646/integralabscosxx0pi/?comment=26651#post-id-26651Comment by slelievre for <p>It is my understanding that Maxima has a difficult time with absolute values in integrals. You can get the answer using a numerical approximation via:</p>
<pre><code>numerical_integral(abs(cos(x)),0,pi)
</code></pre>
<p>Or via <code>sympy</code> you can use:</p>
<pre><code>import sympy
print sympy.integrals.integrate(abs(cos(x)),(x,0,pi)).n()
</code></pre>
https://ask.sagemath.org/question/26646/integralabscosxx0pi/?comment=26653#post-id-26653@Vangelis: you can mark the answer as accepted: click the check mark on the left.Mon, 27 Apr 2015 04:16:45 +0200https://ask.sagemath.org/question/26646/integralabscosxx0pi/?comment=26653#post-id-26653