<s>[INST] numerical calculation of 3d integral $\iiint_{[-1,1]^3} \frac{dx dy dz}{r^2} $ I have to calculate the integral
$$I=\iiint_{[-1,1]^3} \frac{dx dy dz}{r^2} $$
where $r^2 = x^2 + y^2 + z^2 $.
My strategy is to split the integral domain into two parts: the unit sphere and the supplement domain. From the unit sphere, I get analytically $4\pi $; for the supplement, I used Monte Carlo.  The problem is that the Monte Carlo part is not very efficient, while I want to get the integral to 8 digits.
Could anyone suggest a better scheme?
 [/INST] $$\iiint_{[-1,1]^3}\frac{d\mu}{x^2+y^2+z^2} = \iint_{[-1,1]^2}\frac{2}{\sqrt{x^2+y^2}}\arctan\left(\frac{1}{\sqrt{x^2+y^2}}\right)\,dx\,dy $$
equals
$$ 8\iint_{[0,1]^2}\frac{1}{\sqrt{x^2+y^2}}\arctan\left(\frac{1}{\sqrt{x^2+y^2}}\right)\,dx\,dy $$
or
$$ 16\iint_{0\leq y\leq x\leq 1}\frac{1}{\sqrt{x^2+y^2}}\arctan\left(\frac{1}{\sqrt{x^2+y^2}}\right)\,dx\,dy \stackrel{y\mapsto tx}{=} 16\iint_{[0,1]^2}\frac{1}{\sqrt{1+ t^2}}\arctan\left(\frac{1}{x\sqrt{1+ t^2}}\right)\,dx\,dt $$
or
$$ 16\int_{0}^{1}\left(\frac{\pi}{2\sqrt{1+t^2}}-\frac{\arctan\sqrt{1+t^2}}{\sqrt{1+t^2}}+\frac{\log(2+t^2)}{2(1+t^2)}\right)\,dt $$
or
$$ 8\pi\log(1+\sqrt{2})+16\int_{0}^{1}\left(-\frac{\arctan\sqrt{1+t^2}}{\sqrt{1+t^2}}+\frac{\log(2+t^2)}{2(1+t^2)}\right)\,dt. $$
The last integral can be written in terms of polylogarithms, or just numerically evaluated through Newton-Cotes or Gaussian quadrature. The outcome, of course, is larger than $4\pi$ and it equals $\color{blue}{15.348248444887\ldots}$
</s>