TITLE: Finding the volume of a cube using spherical coordinates
QUESTION [6 upvotes]: Calculate the volume of a cube having edge length $a$ by integrating in spherical coordinates.
Suppose that the cube have all the edges on the positive semi-axis. Let us divide it by the plane passing through the points $(0;0;0),(0;0;a),(a;a;0)$. We get two equivalent prism; now we divide the section again by the plane passing through the points $(a;0;a),(0;0;0),(a;a;a)$; So one may write:$$\frac{1}{2}V=(\int_{0}^{\pi/4}\,d\phi\int_{0}^{\pi/4}\,d\theta\int_{0}^{\frac{a}{\cos\phi}}r^2\sin\phi\,dr\quad+\quad\int_{\pi/4}^{\pi/2}\,d\phi\int_{0}^{\pi/4}\,d\theta\int_{0}^{\frac{a}{\sin\phi\cos\theta}}r^2\sin\phi\,dr)$$
So one should expect $V=a^3$ but the latter expression gives a different result. What is the correct way to calculate $V$ and why doesn't my reasoning work?

REPLY [3 votes]: Your limits of the integration for $\phi$ are wrong, because for a cube $\phi = \phi(\theta)$ in your notation. The integrals with correct limits are
$$
\begin{align}
\frac{1}{2}V&=\int_{0}^{\pi/4}\int_{0}^{\arctan(\frac{a}{\cos \theta})}\int_{0}^{\frac{a}{\cos\phi}}r^2\sin\phi\,dr\,d\phi\,d\theta \\
&+ 
\int_{\pi/4}^{\pi/2}\int_{\arctan(\frac{a}{\cos \theta})}^{\pi/2}\int_{0}^{\frac{a}{\sin\phi\cos\theta}}r^2\sin\phi\,dr\,d\phi\,d\theta \\
&= \frac{a^3}{6} + \frac{a^3}{3} = \frac{a^3}{2}
\end{align}
$$
Solving the integrals is a bit tedious, but straightforward. For doing the integration it is helpful to note that
$$
\int\left(\frac{1}{\cos(\phi)}\right)^2\,d\phi = \tan \phi + C
$$
and
$$
\int \left(\frac{1}{\cos(\phi)}\right)^3\sin\phi\,d\phi = \int\left(\frac{1}{\cos(\phi)}\right)^2\tan\phi\,d\phi = \frac{1}{2}(\tan \phi)^2 + C
$$