Subject: double integrals seem to give different answers
From: Dieter Kaiser
Date: Sun, 22 Nov 2009 01:57:59 +0100
Am Freitag, den 20.11.2009, 21:36 -0500 schrieb G. Jay Kerns:
> Dear Maxima list,
>
> Let
>
> f(x,y,z) := exp((x^2 + y^2 +z^2)^(3/2));
>
> x: rho * sin(phi) * cos(theta);
> y: rho * sin(phi) * sin(theta);
> z: rho * cos(phi);
> J: rho^2 * sin(phi);
>
> Then the following double integrals give different answers... why?
>
> integrate(integrate(f(x,y,z) * J, rho,0,1), theta,0,2*%pi);
>
> integrate(integrate(trigsimp(f(x,y,z)) * J, rho,0,1), theta,0,2*%pi);
>
> (The second one is the correct answer). By the way, the inner
> integrals give the same answer although the first one without trigsimp
> is long and complicated.
>
> It would seem the moral of the story is, "Do as much simplification as
> possible before calling integrate." Is this true, or is there a more
> general principle that I am missing?
>
> I would appreciate any insight.
I think you have found a further example for a bug we already know, see
Bug Id: 2880797 "bad answer in integrate(sqrt(sin(t)^2+cos(t)^2),t,0,2*%
pi)".
The routine atan-poles in sin.lisp does not count the multiplicities of
the poles correctly. (Another bug concerning the boundaries of the
integration interval has been corrected.)
A trace of the code shows, that for the second example atan-poles is not
called and the result is correct.
A further hint that the routine atan-poles is the origin of the problem
is, that with triginverses:all, you get a correct result too. For this
case atan(tan(x)) expressions are simplified and the routine atan-poles
is no longer called.
A possible correction might be to do the simplification of atan(tan(x))
--> x in the routine INTSUBS to avoid a call of ATAN-POLES.
Dieter Kaiser