Ask Your Question
1

How to fix Runtime Error while doing integration?

asked 2016-04-01 02:43:10 -0500

tdc2bdc gravatar image

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 flag offensive close merge delete

Comments

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

slelievre gravatar imageslelievre ( 2016-04-01 07:53:20 -0500 )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.

tdc2bdc gravatar imagetdc2bdc ( 2016-04-01 09:43:26 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-04-01 08:51:30 -0500

updated 2016-04-01 08:53:43 -0500

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
edit flag offensive delete link more

Comments

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

vdelecroix gravatar imagevdelecroix ( 2016-04-01 09:02:13 -0500 )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.

tdc2bdc gravatar imagetdc2bdc ( 2016-04-01 09:34:52 -0500 )edit

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

vdelecroix gravatar imagevdelecroix ( 2016-04-01 17:50:35 -0500 )edit

keepfloat:true strikes again

kcrisman gravatar imagekcrisman ( 2016-04-04 20:05:20 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-04-01 02:39:28 -0500

Seen: 181 times

Last updated: Apr 01 '16