# Evaluating $\int_{0}^{1} \int_{0}^{1} \int_{0}^{1} \sqrt{{x^2+y^2+z^2}} dx dy dz$ by converting to spherical coordinates

I would like to know how to evaluate the following triple integral with the help of spherical coordinates

$$\int_{0}^{1} \int_{0}^{1} \int_{0}^{1} \sqrt{{x^2+y^2+z^2}} dx dy dz$$

The relations between Cartesian coordinates and spherical ones are given by

{\begin{aligned}x&=r\,\sin \theta \,\cos \varphi \\y&=r\,\sin \theta \,\sin \varphi \\z&=r\,\cos \theta \end{aligned}}}

I know that a function is generally integrated over $$\mathbb{R}^3$$ by the following triple integral

$$\ \int \limits _{\varphi =0}^{2\pi }\ \int \limits _{\theta =0}^{\pi }\ \int \limits _{r=0}^{\infty }f(r,\theta ,\varphi )r^{2}\sin \theta \,\mathrm {d} r\,\mathrm {d} \theta \,\mathrm {d} \varphi .}$$

I found a numerical solution with Wolfram Alpha (0.960592), I tried to change the bounds of integration from Cartesian to spherical but I got a different numerical value.

Could someone please give a detailed solution showing how to change the limits of integration?

Thanks.

• You are trying to integrate over a cube using spherical coordinates – Yuriy S Aug 26 at 21:30
• I thought it is not difficult in spherical coordinates because $r={\sqrt {x^{2}+y^{2}+z^{2}}}$. But I'm not sure about the new bounds of integration. – fsrong70 Aug 26 at 21:37
• How would you describe a cube in spherical coordinates? Let's answer a more simple question: how do you describe a square in polar coordinates? – Yuriy S Aug 26 at 21:38
• @YuriyS so it would be better to solve it in Cartesian coordinates? Are cylindrical coordinates useful here perhaps or not? – fsrong70 Aug 26 at 21:43
• I would integrate w.r.t. one coordinate in Cartesian and then maybe go to polar, since it's easier to deal with a square in polar than cube in spherical – Yuriy S Aug 26 at 21:44

You can split up the cube into $$6$$ tetrahedral chunks, so the integral is the total of the integrals over each tetrahedron, which are easier to set up. One such chunk involves the tetrahedron with vertices $$(0,0,0),(1,0,0),(1,1,0),(1,1,1)$$:

$$\int_0^{\pi/4}\int_{\tan^{-1}(\csc\theta)}^{\pi/2}\int_0^{\sec\theta\csc\varphi}\rho^3\sin\varphi\,\mathrm d\rho\,\mathrm d\varphi\,\mathrm d\theta=\frac{6\sqrt3-\pi+6\ln(7+4\sqrt3)}{144}\approx0.1600976746$$

The remaining integrals' bounds in spherical coordinates are

$$\int_0^{\pi/4}\int_{\tan^{-1}(\sec\theta)}^{\tan^{-1}(\csc\theta)}\int_0^{\sec\theta\csc\varphi}$$

(tetrahedron with vertices $$(0,0,0),(1,0,0),(1,0,1),(1,1,1)$$)

$$\int_0^{\pi/4}\int_0^{\tan^{-1}(\sec\theta)}\int_0^{\sec\varphi}$$

(tetrahedron with vertices $$(0,0,0),(0,0,1),(1,0,1),(1,1,1)$$)

$$\int_{\pi/4}^{\pi/2}\int_{\tan^{-1}(\sec\theta)}^{\pi/2}\int_0^{\csc\theta\csc\varphi}$$

(tetrahedron with vertices $$(0,0,0),(0,1,0),(1,1,0),(1,1,1)$$)

$$\int_{\pi/4}^{\pi/2}\int_{\tan^{-1}(\csc\theta)}^{\tan^{-1}(\sec\theta)}\int_0^{\csc\theta\csc\varphi}$$

(tetrahedron with vertices $$(0,0,0),(0,1,0),(0,1,1),(1,1,1)$$)

$$\int_{\pi/4}^{\pi/2}\int_0^{\tan^{-1}(\csc\theta)}\int_0^{\sec\varphi}$$

(tetrahedron with vertices $$(0,0,0),(0,0,1),(1,1,0),(1,1,1)$$)

As it turns out, the integrals over each chunk all have the same value. (I only found this out by computing each integral; there is probably some argument to be made about the integrand's symmetry within the cube.) Then the value of the original integral is

$$\frac{6\sqrt3-\pi+6\ln(7+4\sqrt3)}{24}\approx0.9605919565$$

Substitute:

$$z=\sqrt{x^2+y^2} t$$

$$I=\int_{0}^{1} \int_{0}^{1} \int_{0}^{1/\sqrt{x^2+y^2}} (x^2+y^2) \sqrt{{1+t^2}} dt dy dx$$

Integrating w.r.t. $$t$$:

$$I=\frac{1}{2} \int_{0}^{1} \int_{0}^{1} (x^2+y^2) \left(\frac{1}{\sqrt{x^2+y^2}}\sqrt{1+\frac{1}{x^2+y^2}}+\sinh^{-1} \frac{1}{\sqrt{x^2+y^2}} \right) dy dx$$

Using the symmetry:

$$I= \int_{0}^{1} \int_{0}^{x} (x^2+y^2) \left(\frac{1}{\sqrt{x^2+y^2}}\sqrt{1+\frac{1}{x^2+y^2}}+\sinh^{-1} \frac{1}{\sqrt{x^2+y^2}} \right) dy dx$$

Now we can use polar coordinates:

$$x=r \cos \phi$$

$$y=r \sin \phi$$

$$0<\sin \phi<\cos \phi, \qquad 0<\phi< \frac{\pi}{4}$$

$$0

$$I= \int_{0}^{\frac{\pi}{4}} \int_{0}^{\frac{1}{\cos \phi}} r^3 \left(\frac{1}{r}\sqrt{1+\frac{1}{r^2}}+\sinh^{-1} \frac{1}{r} \right) dr d \phi$$

$$I= \int_{0}^{\frac{\pi}{4}} \int_{0}^{\frac{1}{\cos \phi}} \left(r\sqrt{r^2+1}+r^3 \sinh^{-1} \frac{1}{r} \right) dr d \phi$$

We have:

$$\int_{0}^{\frac{1}{\cos \phi}} r\sqrt{r^2+1} dr= \frac{1}{3} \left(\frac{1}{\cos^2 \phi}+1 \right)^{3/2}-\frac{1}{3}$$

$$\int_{0}^{\frac{1}{\cos \phi}} r^3 \sinh^{-1} \frac{1}{r} dr= \frac{1}{4 \cos^4 \phi} \sinh^{-1} \cos \phi+ \frac{1-2 \cos^2 \phi}{12 \cos^3 \phi} \sqrt{1+\cos^2 \phi}+\frac16$$

So we have a complicated expression:

$$I= \frac{\pi}{24}+ \frac13 \int_{0}^{\frac{\pi}{4}} \left(\left(\frac{1}{\cos^2 \phi}+1 \right)^{3/2}-1 \right) d \phi+ \\+ \frac{1}{4} \int_{0}^{\frac{\pi}{4}} \left( \frac{1}{\cos \phi}\sinh^{-1} \cos \phi+ \frac{1}{3} (1-2 \cos^2 \phi)\sqrt{1+\cos^2 \phi} \right) \frac{d \phi}{\cos^3 \phi}$$

These are elliptic kind of integrals, though some of them might be elementary. Substitution $$\cos \phi=s$$ seems prudent here.

I hope this might be helpful.

Maybe using spherical coordinates from the start is better, but I haven't figured out the correct bounds yet either.

• The relation $\operatorname{div}(r\vec{r})=4r$ and Ostrogradsky theorem can reduce the triple integral to three similar double integrals, i.e. $$\frac34\iint_{[0,1]^2}\sqrt{x^2+y^2+1}\,dxdy.$$ – A.Γ. Aug 26 at 22:18
• @A.Γ., maybe this comment should be under the original post? But great idea, yes, I forgot about this useful theorem – Yuriy S Aug 26 at 22:23
• The comment was for you as you seemed to be attracted to the problem. – A.Γ. Aug 26 at 22:28
• @A.Γ., and I'm grateful, since frankly, I forgot that this theorem is useful beyond introductory electrostatics courses I had years ago. There are some problems of mine which I now know how to simplify thanks to you – Yuriy S Aug 26 at 22:35