ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 04 Apr 2016 20:05:20 -0500How to fix Runtime Error while doing integration?http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/ I'm trying to evaluate:
`definite_integral(z,t,0,2*pi)`
where z is:
`z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)`
But it is throwing following error:
RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
I' new to Sage, but following through some posts at ask.sagemath (I can't post link), I feel it may be due to precision. 5 digits are OK with me.
Any fix/workaround? Thanks.Fri, 01 Apr 2016 02:39:28 -0500http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/Comment by tdc2bdc for <p>I'm trying to evaluate:</p>
<p><code>definite_integral(z,t,0,2*pi)</code></p>
<p>where z is:</p>
<p><code>z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)</code></p>
<p>But it is throwing following error:</p>
<pre><code>RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
</code></pre>
<p>I' new to Sage, but following through some posts at ask.sagemath (I can't post link), I feel it may be due to precision. 5 digits are OK with me.</p>
<p>Any fix/workaround? Thanks.</p>
http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32943#post-id-32943Excuse me for not researching deep enough. I think it was so on the basis of my experience with Wolfram Alpha's timeout error, ticket/#15902 AND 7653/setting-precision-in-sage/ . **vdelecroix**'s fix is fine for me, if it is replicated by other CAS too. Thanks a lot.Fri, 01 Apr 2016 09:43:26 -0500http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32943#post-id-32943Comment by slelievre for <p>I'm trying to evaluate:</p>
<p><code>definite_integral(z,t,0,2*pi)</code></p>
<p>where z is:</p>
<p><code>z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)</code></p>
<p>But it is throwing following error:</p>
<pre><code>RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
</code></pre>
<p>I' new to Sage, but following through some posts at ask.sagemath (I can't post link), I feel it may be due to precision. 5 digits are OK with me.</p>
<p>Any fix/workaround? Thanks.</p>
http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32938#post-id-32938If you can't post the link you can put the question number.Fri, 01 Apr 2016 07:53:20 -0500http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32938#post-id-32938Answer by vdelecroix for <p>I'm trying to evaluate:</p>
<p><code>definite_integral(z,t,0,2*pi)</code></p>
<p>where z is:</p>
<p><code>z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)</code></p>
<p>But it is throwing following error:</p>
<pre><code>RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
</code></pre>
<p>I' new to Sage, but following through some posts at ask.sagemath (I can't post link), I feel it may be due to precision. 5 digits are OK with me.</p>
<p>Any fix/workaround? Thanks.</p>
http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?answer=32939#post-id-32939I confirm the RuntimeError
sage: t = SR.var('t')
sage: z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)
sage: integral(z, 0, 2*pi)
Traceback (most recent call last):
...
RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
Though, you can use the following
sage: numerical_integral(z, 0, 2*pi)
(6.283185293615565, 2.4299802864003794e-10)
The first element of the answer is the value of the integral and the second one an estimation of the error (that you can believe in most situation).
Note that the integral is very close to two times pi
sage: (2*pi).n()
6.28318530717959Fri, 01 Apr 2016 08:51:30 -0500http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?answer=32939#post-id-32939Comment by kcrisman for <p>I confirm the RuntimeError</p>
<pre><code>sage: t = SR.var('t')
sage: z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)
sage: integral(z, 0, 2*pi)
Traceback (most recent call last):
...
RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
</code></pre>
<p>Though, you can use the following</p>
<pre><code>sage: numerical_integral(z, 0, 2*pi)
(6.283185293615565, 2.4299802864003794e-10)
</code></pre>
<p>The first element of the answer is the value of the integral and the second one an estimation of the error (that you can believe in most situation).</p>
<p>Note that the integral is very close to two times pi</p>
<pre><code>sage: (2*pi).n()
6.28318530717959
</code></pre>
http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32998#post-id-32998keepfloat:true strikes againMon, 04 Apr 2016 20:05:20 -0500http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32998#post-id-32998Comment by vdelecroix for <p>I confirm the RuntimeError</p>
<pre><code>sage: t = SR.var('t')
sage: z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)
sage: integral(z, 0, 2*pi)
Traceback (most recent call last):
...
RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
</code></pre>
<p>Though, you can use the following</p>
<pre><code>sage: numerical_integral(z, 0, 2*pi)
(6.283185293615565, 2.4299802864003794e-10)
</code></pre>
<p>The first element of the answer is the value of the integral and the second one an estimation of the error (that you can believe in most situation).</p>
<p>Note that the integral is very close to two times pi</p>
<pre><code>sage: (2*pi).n()
6.28318530717959
</code></pre>
http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32951#post-id-32951No the error you got is reproducible on the Sage version I have on my computer.Fri, 01 Apr 2016 17:50:35 -0500http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32951#post-id-32951Comment by tdc2bdc for <p>I confirm the RuntimeError</p>
<pre><code>sage: t = SR.var('t')
sage: z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)
sage: integral(z, 0, 2*pi)
Traceback (most recent call last):
...
RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
</code></pre>
<p>Though, you can use the following</p>
<pre><code>sage: numerical_integral(z, 0, 2*pi)
(6.283185293615565, 2.4299802864003794e-10)
</code></pre>
<p>The first element of the answer is the value of the integral and the second one an estimation of the error (that you can believe in most situation).</p>
<p>Note that the integral is very close to two times pi</p>
<pre><code>sage: (2*pi).n()
6.28318530717959
</code></pre>
http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32941#post-id-32941Thank you very much **vdelecroix** for your solution. BTW is it because I'm using Sage Cloud? I'm also trying to cross-check above solution's value with other CAS.Fri, 01 Apr 2016 09:34:52 -0500http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32941#post-id-32941Comment by vdelecroix for <p>I confirm the RuntimeError</p>
<pre><code>sage: t = SR.var('t')
sage: z = 1-exp(2.0*cos(t) - 2.0*sin(t)-0.4*sqrt(-25*(cos(t) - sin(t))^2 + 100)^2)
sage: integral(z, 0, 2*pi)
Traceback (most recent call last):
...
RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
</code></pre>
<p>Though, you can use the following</p>
<pre><code>sage: numerical_integral(z, 0, 2*pi)
(6.283185293615565, 2.4299802864003794e-10)
</code></pre>
<p>The first element of the answer is the value of the integral and the second one an estimation of the error (that you can believe in most situation).</p>
<p>Note that the integral is very close to two times pi</p>
<pre><code>sage: (2*pi).n()
6.28318530717959
</code></pre>
http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32940#post-id-32940Relations with the following tickets [#18821](http://trac.sagemath.org/ticket/18821), [#15902](http://trac.sagemath.org/ticket/15902), [#14821](http://trac.sagemath.org/ticket/14821), [#13071](http://trac.sagemath.org/ticket/13071).Fri, 01 Apr 2016 09:02:13 -0500http://ask.sagemath.org/question/32934/how-to-fix-runtime-error-while-doing-integration/?comment=32940#post-id-32940