# 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.

edit retag close merge delete

If you can't post the link you can put the question number.

( 2016-04-01 14:53:20 +0200 )edit

Excuse 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.

( 2016-04-01 16:43:26 +0200 )edit

Sort by ยป oldest newest most voted

I 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.28318530717959

more

Relations with the following tickets #18821, #15902, #14821, #13071.

( 2016-04-01 16:02:13 +0200 )edit

Thank 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.

( 2016-04-01 16:34:52 +0200 )edit

No the error you got is reproducible on the Sage version I have on my computer.

( 2016-04-02 00:50:35 +0200 )edit

keepfloat:true strikes again

( 2016-04-05 03:05:20 +0200 )edit