Ask Your Question
1

Integral not being computed correctly

asked 2014-12-11 22:12:23 +0200

petoknm gravatar image

updated 2014-12-12 10:57:58 +0200

Hello I'm trying to compute this triple integral

assume(H>0);
integrate(1,z,sqrt(x^2+y^2),H+sqrt(3)*y/3);
integrate(%,y,-sqrt(H^2*(3-sqrt(3))^2/4-x^2),sqrt(H^2*(3-sqrt(3))^2/4-x^2));
integrate(%,x,-H*(3-sqrt(3))/2,H*(3-sqrt(3))/2);

And there is a variable H. So I want the final result to be a function of H. But I get a different answer from sage and Mathematica. I hope the integrals are the same. What am I doing wrong? The sage output produces complex solutions because of the argument of inverse sine being larger than 1 while the Mathematica output is nice real solution. Which one is correct?

This is the sage output

image description

This is the Mathematica output

image description

edit retag flag offensive close merge delete

Comments

to be precise, it's not Sage that computes it there, it's Maxima. (these %i and %o prompts are from Maxima).

Dima gravatar imageDima ( 2014-12-12 12:47:40 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-12-12 14:54:40 +0200

you can certainly compare the numeric outputs for constants: in maxima you do

 assume(H>0);
 integrate(1,z,sqrt(x^2+y^2),H+sqrt(3)*y/3);
 integrate(%,y,-sqrt(H^2*(3-sqrt(3))^2/4-x^2),sqrt(H^2*(3-sqrt(3))^2/4-x^2));
 r:integrate(%,x,-H*(3-sqrt(3))/2,H*(3-sqrt(3))/2);
 expand(ev(subst([H=1],r),numer));

and you get 0.729009112317963 - 13.831305954985441e-9 %i, while the Mathematica's constant term is

 ev(-(-3+sqrt(3))*%pi/4,numer);

is 0.9958449670166816. So it's really different answers, and probably Maxima is wrong, as the imaginary term looks suspiciously large.

The only way to find out for sure is to compute this by some other means...

edit flag offensive delete link more
0

answered 2014-12-12 04:06:45 +0200

kcrisman gravatar image

The complex pieces cancel, I believe.

sage: f=integrate(integrate(integrate(1,z,sqrt(x^2+y^2),H+sqrt(3)*y/3),y,-sqrt(H^2*(3-sqrt(3))^2/4-x^2),sqrt(H^2*(3-sqrt(3))^2/4-x^2)),x,-H*(3-sqrt(3))/2,H*(3-sqrt(3))/2)
sage: f.subs(H=1)
1/4*sqrt(2)*(((3*sqrt(3)) - 6)*sqrt(-3*sqrt(3) + 6)*arcsin(1/2*sqrt(2)*sqrt(-3*sqrt(3) + 6)*(5*sqrt(3) - 9)/(12*sqrt(3) - 21)) + I*((3*sqrt(3)) - 6)*sqrt(sqrt(3) - 2)*arcsin(1/2*sqrt(2)*sqrt(-3*sqrt(3) + 6)*(5*sqrt(3) - 9)/(12*sqrt(3) - 21)) - ((3*sqrt(3))*(2*sqrt(2)) - 12*sqrt(2))*arcsin(1/2*sqrt(2)*sqrt(-3*sqrt(3) + 6)*(5*sqrt(3) - 9)/(12*sqrt(3) - 21)))
sage: f.subs(H=1).n()
1.09351366847695 - 1.41499750148729e-17*I
sage: f.subs(H=2).n()
8.74810934781556 - 1.13199800118983e-16*I

As you can see, the problem is that Sage gets something that isn't simplifying enough to get rid of vanishingly small imaginary parts when numerically evaluated, though

sage: plot(lambda x: f.subs(H=x).n().real(),(x,0,5))

probably gives what you want.

However, in general simplification is a computationally hard problem. You might have to 'unsimplify' before a good simplification is possible.

sage: f.expand().canonicalize_radical()
-3/4*(sqrt(3)*sqrt(2) - sqrt(2))*H^3*sqrt(sqrt(3) - 2)*arcsinh((3*sqrt(3) - 5)*sqrt(sqrt(3) - 2)/(4*sqrt(3)*sqrt(2) - 7*sqrt(2))) - 1/4*H^3*(-12*I*sqrt(3) + 24*I)*arcsinh((3*sqrt(3) - 5)*sqrt(sqrt(3) - 2)/(4*sqrt(3)*sqrt(2) - 7*sqrt(2)))

Unfortunately, due to the 'canonical' nature of this simplification, this gives quite different answers, presumably wrong, which the documentation for canonicalize_radical points out.

This all doesn't answer the question of what the right answer is, but I can't see your picture in any case, and hopefully it does help some.

edit flag offensive delete link more

Comments

I have corrected the image hosting... And they both have H^3 term but the constants in front of it are different...

petoknm gravatar imagepetoknm ( 2014-12-12 11:04:09 +0200 )edit

how do you know that Mathematica's answer is correct?

Dima gravatar imageDima ( 2014-12-12 13:32:41 +0200 )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

2 followers

Stats

Asked: 2014-12-11 22:12:23 +0200

Seen: 548 times

Last updated: Dec 12 '14