Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
2

Bug in integration of sqrt functions?

asked 11 years ago

Shashank gravatar image

I have been experiencing a problem integrating a function with several terms. I have managed to narrow it down to a problem with integration.

When I type the following command I get 1 as I should

integrate(cos(x),x,0,pi/2)

However, when I write the same integral in the form

integrate((sqrt(1-sin(x)*sin(x))),x,0,pi/2)

I get an error "RuntimeError: ECL says: Error executing code in Maxima: atanh: argument 1 isn't in the domain of atanh."

I guess it is a result of the fact that

integrate((sqrt(1-sin(x)*sin(x))),x,0,pi/2)

gives tan(x)/(tan(x)2+1) and sage is trying to substitute x=π/2 without trying to simplify the expression first or taking the limit of x to π/2. Is there a way to avoid this problem when the function I wrote is a part of a bigger function and I can't simplify by hand.

Both integrals are identical and I don't understand why I am getting an error in one case. Is this a bug or am I doing something wrong?

Preview: (hide)

Comments

This has been reported upstream - http://www.math.utexas.edu/pipermail/maxima/2013/034222.html - thanks, Dima!

kcrisman gravatar imagekcrisman ( 11 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 11 years ago

dazedANDconfused gravatar image

I don't think I can answer your questions but maybe we can solve the problem: "Is there a way to avoid this problem when the function I wrote is a part of a bigger function and I can't simplify by hand.". For trig functions there is a simplification command, simplify_trig(), see here, that solves this particular problem but maybe a combination of commands that simplify might be what you need. The command integrate((tan(x)/(sqrt((tan(x)^2+1)))).simplify_trig(),(x,0,pi/2)) will evaluate to 1.

The function (sqrt(1-sin(x)*sin(x)) is really the absolute value of cosine (certainly over 0 to π/2 they're the same); maybe that's why we get the strange antiderivative. I tried integrate(abs(cos(x)),(x,0,pi)) in a sage notebook and got -1 which is definitely wrong. I couldn't get an answer in the Sage Cell server. The Fundamental Theorem of Calculus expects the antiderivative to be defined on the closed interval [0,π/2], but tan(x)/(tan(x)2+1) isn't defined when x is a multiple of π/2. You'll find Sage gives the same error message if you integrate from 0 to π. In summary, tan(x)/(tan(x)2+1) looks incorrect to me because the domain is not all real numbers but maybe using the simplify commands will let you get your work done.

Preview: (hide)
link

Comments

I know about simplify_trig() command. However, it is inconvenient when you are multiple calculations in a loop and there are several terms. My point was that you should not have to simplify and then take the limits.

Shashank gravatar imageShashank ( 11 years ago )

The above abs(cos(x)) error was already reported at Trac 11483 (currently Trac is down, but you can Google for it). Hopefully Trac 13973 will fix this for good.

kcrisman gravatar imagekcrisman ( 11 years ago )

Thanks a lot. It seems it will be fixed in 5.13. Is there a release schedule for this and future versions?

Shashank gravatar imageShashank ( 11 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

Stats

Asked: 11 years ago

Seen: 823 times

Last updated: Oct 09 '13