Ask Your Question
1

How to fix Runtime Error while doing integration?

asked 2016-04-01 09:43:10 +0100

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 14:53:20 +0100 )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 16:43:26 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-04-01 15:51:30 +0100

vdelecroix gravatar image

updated 2016-04-01 15:53:43 +0100

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 16:02:13 +0100 )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 16:34:52 +0100 )edit

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

vdelecroix gravatar imagevdelecroix ( 2016-04-02 00:50:35 +0100 )edit

keepfloat:true strikes again

kcrisman gravatar imagekcrisman ( 2016-04-05 03:05:20 +0100 )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 09:39:28 +0100

Seen: 872 times

Last updated: Apr 01 '16