First time here? Check out the FAQ!

Ask Your Question
1

How to fix Runtime Error while doing integration?

asked 8 years ago

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.

Preview: (hide)

Comments

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

slelievre gravatar imageslelievre ( 8 years ago )

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 ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

vdelecroix gravatar image

updated 8 years ago

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
Preview: (hide)
link

Comments

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

vdelecroix gravatar imagevdelecroix ( 8 years ago )

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 ( 8 years ago )

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

vdelecroix gravatar imagevdelecroix ( 8 years ago )

keepfloat:true strikes again

kcrisman gravatar imagekcrisman ( 8 years ago )

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: 8 years ago

Seen: 910 times

Last updated: Apr 01 '16