# Integral $\int_{d_1}^{d_2} \int_{-L/2}^{L/2} \int_{-L/2}^{L/2} \frac{1}{(x^2+y^2+z^2)^3} dx dy dz$

I'm trying to calculate the following integral in Mathematica, but it seems it doesn't return an analytical closed form, neither when I give numeric values for both $$d_{1,2}$$ and $$L$$.

$$∫_{d_1}^{d_2} ∫_{-L/2}^{L/2} ∫_{-L/2}^{L/2} \frac{1}{(x^2+y^2+z^2)^3} dx dy dz$$

Is there any trick that might be useful for this case?

• Can you share the Mathematica Integrate command you have tried? That way people can comment on how to possibly improve it. Jan 20 '20 at 19:05
• This is not integrable for $d_1 <0 < d_2$... Jan 20 '20 at 19:54

Given some conditions, the analytic form is found:

Assuming[L > 0 && 0 < d1 < d2,
Integrate[1/(x^2 + y^2 + z^2)^3,
{x, d1, d2}, {y, -L/2, L/2}, {z, -L/2, L/2}] // FullSimplify]


$$\frac{2 \left(\frac{\left(16 d_1^4+2 d_1^2 L^2+L^4\right) \tan ^{-1}\left(\frac{L}{\sqrt{4 d_1^2+L^2}}\right)}{d_1^3 \sqrt{4 d_1^2+L^2}}+L \left(\frac{1}{d_1}-\frac{1}{d_2}\right)+5 \sqrt{2} \tan ^{-1}\left(\frac{\sqrt{2} d_1}{L}\right)-\frac{\left(16 d_2^4+2 d_2^2 L^2+L^4\right) \tan ^{-1}\left(\frac{L}{\sqrt{4 d_2^2+L^2}}\right)}{d_2^3 \sqrt{4 d_2^2+L^2}}-5 \sqrt{2} \tan ^{-1}\left(\frac{\sqrt{2} d_2}{L}\right)\right)}{3 L^3}$$

A similar formula is achieved for $$d_1. As Henrik comments, the integral diverges if $$d_1\le0\le d_2$$.

• Thank you very much. Jan 20 '20 at 20:36
• @Roman Your computer must be a beast. I tried on my humble six core machine and no output yet. Jan 20 '20 at 21:01
• Patience is a superpower, dear @user13892. Jan 20 '20 at 21:13
• Oh good that you a have it, @Roman. I waited for 6 six seconds and for my typical applications, this uses to be a good sign for giving up! =D Have my upvote! Jan 20 '20 at 22:00
• @HenrikSchumacher The way I tried at first (analogical to this one) took 20 minutes without completion, while my (more laborious) approach took roughly 3 minutes. It seems that a memory issue affects this quite significant difference. However it needs more attention. Jan 20 '20 at 22:11

Mathematica is able to solve the indefinite integral:

ClearAll[expr];
expr[x_,y_,z_]=Integrate[1/(x^2+y^2+z^2)^3,x,y,z];


Using the indefinite integral expr found above to find the definite integral as follows:

expr[y_,z_]=expr[L/2,y,z]-expr[-L/2,y,z];
expr[z_]=expr[L/2,z]-expr[-L/2,z];
expr[Subscript[d, 2]]-expr[Subscript[d, 1]]//FullSimplify


$$\frac{2 \left(\frac{L^2 \sqrt{4 d_1^2+L^2} \tan ^{-1}\left(\frac{L}{\sqrt{4 d_1^2+L^2}}\right)}{d_1^3}+\frac{L-2 \sqrt{4 d_1^2+L^2} \tan ^{-1}\left(\frac{L}{\sqrt{4 d_1^2+L^2}}\right)}{d_1}+\frac{24 d_1 \tan ^{-1}\left(\frac{L}{\sqrt{4 d_1^2+L^2}}\right)}{\sqrt{4 d_1^2+L^2}}+\frac{L^4 \left(-\tan ^{-1}\left(\frac{L}{\sqrt{4 d_2^2+L^2}}\right)\right)-d_2^2 \left(L \sqrt{4 d_2^2+L^2}+2 \left(8 d_2^2+L^2\right) \tan ^{-1}\left(\frac{L}{\sqrt{4 d_2^2+L^2}}\right)\right)}{d_2^3 \sqrt{4 d_2^2+L^2}}+5 \sqrt{2} \left(\tan ^{-1}\left(\frac{\sqrt{2} d_1}{L}\right)-\tan ^{-1}\left(\frac{\sqrt{2} d_2}{L}\right)\right)\right)}{3 L^3}$$

Now to numerically estimate it, it must be noted that there is a very fast singularity in the middle, i.e. (x,y,z)=(0,0,0).

Plot[1/(x^2)^3,{x,-10,10}]
Plot3D[1/(x^2+y^2)^3,{x,-10,10},{y,-10,10}]


It just continues the same way in higher dimension. So as long as you avoid the point in the middle by some margin it will be able to numerically estimate its value.

NIntegrate[
1/(x^2+y^2+z^2)^3,
{x,-1,1},
{y,-1,1},
{z,0,2} (*failure expected since it touches the singularity*)
]


fails to converge and very big values overflow the machine number.

NIntegrate[
1/(x^2+y^2+z^2)^3,
{x,-1,1},
{y,-1,1},
{z,0.1,2} (*big value expected since close to singularity*)
]


522.763

NIntegrate[
1/(x^2+y^2+z^2)^3,
{x,-1,1},
{y,-1,1},
{z,1,2} (*small value expected since it has very thin tails away from origin / singularity*)
]


0.310657

INTRODUCTION

In order to compute our integral we have to provide appropriate assumptions in adequate functions and so this turns us to another issue stated by Szabolcs in his interesting discussion When and why are Assuming and Assumptions not equivalent? clarified elswhere by Daniel Lichtblau. Therefore our integral provides an important example to the mentioned issue related to advantages of Assumptions in Integrate over the construction Assuming[ ..., Integrate[...]] and vice versa. And so a straightforward and natural approach follows along this way:

Integrate[1/(x^2 + y^2 + z^2)^3, {x, -(L/2), L/2}, {y, -(L/2), L/  2},
{z, d1, d2}, Assumptions -> L > 0 && 0 < d1 < d2]


nontheless I've had to stop this computation since it hasn't been completed after 30 minutes. Therefore our modiffied approach involves a computation in a few steps.

SOLUTION

int1[L_,z_]= Integrate[ 1/(x^2 + y^2 + z^2)^3, {x, -(L/2), L/2}, {y, -(L/2), L/2},
Assumptions -> L > 0 && z > 0];
int[L_,d1_,d2_] = Integrate[ int1[L, z], {z, d1, d2},
Assumptions -> 0 < d1 < d2 && L > 0];
integral[L_, d1_, d2_] =
FullSimplify[int[L, d1, d2], Assumptions -> L > 0 && 0 < d1 < d2];


i.e.

TraditionalForm[ integral[L, d1, d2]]


It took on my laptop (i3 CPU 1.9 GHz, 4 GB RAM, Windows 10 x 64,Mathematica 11.2)

AbsoluteTiming[ int1[L,z]; int[L,d1,d2]; integral[L,d1,d2]]

{ 316.34, ...}


roughly the same as Roman's approach, which took { 322.287, ...}, howerver my solution provides an alternative approach which avoids possible issues with generic results as mentioned in introduction.

• I also tried the full integration with limits and it takes forever but instead of partial integration, I did indefinite integration and applied the simple rectangular limits manually. Jan 20 '20 at 21:04
• @user13892 My experience with indefinite integrals within Mathematica is such that I would have to check the result carefully in order to proceed further, since one has to watch for possible jumps of the integrand when crossing a branch cut. And so I prefer to deal with definite integrals. See e.g. this How to calculate contour integrals with Mathematica? Jan 20 '20 at 21:17