# Order of integration changes output of indefinite multiple integral in Mathematica 7

I'm trying to integrate a form-factor used in the calculation of radiation between two rectangles in perpendicular planes. While the integral is usually done over fixed limits, I am trying to do the indefinite multiple integral. When I change the order of integration the results differ in one term.

Because the result gets used in a summation that is essentially evaluating the integral at the end points representing the rectangle limits, the extra terms do not matter i.e. they end up cancelling out. But I'm bothered that they are being generated to begin with and that they differ when I change the order of integration.

In order to make sure that the difference is not because of the possibility of imaginary numbers or zeros, cropping up, I set assumptions that limit the variables to all be finite positive numbers. I'm guessing the differences are because of the log's or arctan's that crop up during the integration, but I can't figure out why.

In the example below the two integrals differ in the term x^2 , 2yw-y^2

The effects are not from FullSimplify as that just collects terms - it doesn't combine log or arctan terms.

Can anyone explain the results I get? I'm running Mathematica 7.0 Thanks in advance! (sorry I can't post an image but I'm a new user so it's not allowed)

Fperp = FullSimplify[
1/Pi Integrate[(x*z)/(x^2 + z^2 + (y - w)^2)^2, x, y, z, w,
Assumptions -> {x > 0 && w > y0 & z > 0 && y > 0 &&
x <= Infinity && y < Infinity && z < Infinity &&
w < Infinity}]]

(* ===>  (x^2 + 4 (w - y) Sqrt[x^2 + z^2]
ArcTan[(w - y)/Sqrt[x^2 + z^2]] + (-x^2 + (w - y)^2 - z^2) Log[
x^2 + (w - y)^2 + z^2])/(8 \[Pi]) *)

Fperp2 = FullSimplify[(1/Pi)*
Integrate[(x*z)/(x^2 + z^2 + (y - w)^2)^2, w, z, y, x,
Assumptions -> {x > 0 && w > 0 && z > 0 && y > 0 &&
x < Infinity && y < Infinity && z < Infinity && w < Infinity}]]

(* ===>  (-w (w - 2 y) + 4 (w - y) Sqrt[x^2 + z^2]
ArcTan[(w - y)/Sqrt[x^2 + z^2]] + (-x^2 + (w - y)^2 - z^2) Log[
x^2 + (w - y)^2 + z^2])/(8 \[Pi]) *)

-

There is no reason why the two integrals in your problem should be the same, and they aren't. They aren't definite integrals, only anti-derivatives (indefinite integrals). That is, the only property that they must have is the following:

D[Fperp, x, y, z, w] == D[Fperp2, x, y, z, w]

(* ==> True *)


Indeed, they are antiderivatives of the same function. The reason you got antiderivatives that differ in form is that the integration algorithm generally introduces different substitutions and defines different integration constants depending on the form in which you present the integrand. That's really all that needs to be said in general - now you could still ask for the reason for the specific differences, but that would best be explained by doing the multiple integrals one at a time, and I don't think it would be easy to draw any more general statements from that.

-

one thing first, your assumptions for the first integral are not the same as the second one. You used & in one case, while in the second integral you used &&. You also had y0 instead of y I assume these are typos.

These things happen when you type everything again and again instead of simply making variables and reuse them !

term = (x*z)/(x^2 + z^2 + (y - w)^2)^2;
assumptions = {x > 0 && w > y && z > 0 && y > 0 && x <= Infinity &&
y < Infinity && z < Infinity && w < Infinity};

fperp  = Assuming[assumptions, FullSimplify[(1/Pi) Integrate[term, x, y, z, w]]];
fperp2 = Assuming[assumptions,FullSimplify[(1/Pi) Integrate[term, w, z, y, x]]];


Now

Reduce[fperp == fperp2]
(* w == y - Sqrt[-x^2 + y^2] || w == y + Sqrt[-x^2 + y^2]  *)

Simplify[fperp - fperp2]
(* (w^2 + x^2 - 2*w*y)/(8*Pi)  *)


So the integrals are the same when w^2 + x^2 is the same as 2*w*y.

The above is the condition for the 2 integrals to be the same. Now I am not a math major, (and I did not think the order of integration for indefinite integration can change the result) so I looked up wiki, and it seems there are conditions and theories that talk about this.

May be a math expert can shed more light on this.

-
The Wikipedia link is not really related to this problem at all. The problem with order of integration that it refers to relates to definite integrals whereas here we simply have indefinite integrals. – Jens Jan 3 at 6:42
@Jens, I know the main page at wiki references talks about definite integrals, but there are many links there that can be useful and might talk about indefinite integral. I just added the link as reference to start search from. If you know of a better link, please feel free to put it. Thanks, – Nasser Jan 3 at 6:45