\section{Spherical Coordinates}


\subsection{A Geometric Perspective} 

Let $P$ be some point in $\mathbb{R}^3$, and let $S$ be the (unique) sphere in $\mathbb{R}^3$ containing $P$ and centered at the origin.  Let $\mathbf{P}$ denote the vector from the origin to $P$.  A bit of geometry shows that the location of $P$ in three dimensional space is uniquely determined by three parameters:


\begin{figure}[h]
\centering
\includegraphics[width=.7\linewidth]{55fig1.png}
\caption{The point $P$ and sphere $S$.}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=.4\linewidth]{55fig2.png}
\caption{A cross-section.}
\end{figure}





\smallskip

\begin{itemize}
\item The radius $R > 0$ of the sphere $S$;

\smallskip

\item The angle $0 \leq \theta < 2 \pi$ made by the projection of $\mathbf{P}$ onto the $xy$-plane and the unit vector $\mathbf{i}$; 

\smallskip

\item The angle $0 \leq \phi \leq \pi$ made by $\mathbf{P}$ and the unit vector $\mathbf{k}$.

\end{itemize}

\noindent 
This is illustrated above. To help elucidate the role of the variable $\phi$, we have also included a cross-section of the sphere, which is taken in the plane passing through the $z$-axis and containing the point $P$. As an example, if $\phi = 0$, then $P$ lies on the positive $z$ axis; for $\phi=\pi/2$, $P$ lies in the $xy$-plane; and if $\phi = \pi$, then $P$ lies on the negative $z$-axis. We do not consider values of $\phi$ that are greater than $\pi$. For example, if $P$ corresponds to some values of $(R,\theta,\pi)$, then its antipodal point $-P$ corresponds to $(R,\theta+\pi, \pi-\phi)$ (rather than $(R,\theta,\phi+\pi)$).




In particular, we see that the parameters $(R, \theta, \phi)$ give us a set of coordinates in $\mathbb{R}^3$.  We call them \textbf{spherical coordinates}.  

\medskip
\noindent
\fbox{
%\vspace{.4cm}

\begin{minipage}{\textwidth}
\begin{center}
\medskip

\textbf{Change of Variables: Euclidean to Spherical Coordinates}
\end{center}

We have $R = \sqrt{x^2 + y^2 + z^2}$, and 
\begin{eqnarray*}
\begin{cases} x = R \cos \theta \sin \phi & \qquad\qquad R>0\\ 
y = R \sin \theta \sin \phi &\qquad \qquad 0\leq\theta\leq 2\pi\\ 
z = R \cos \phi & \qquad\qquad 0\leq\phi\leq \pi. \end{cases}  
\end{eqnarray*}

\smallskip


\end{minipage}

}

The easiest way to derive the conversion formulae above is to use 
cylindrical coordinates $(r, \theta, z)$ as an intermediate step. In the right triangle adjacent to the $z$-axis in the figure above, the hypothenuse has length $R$, the side adjacent to the angle $\phi$ has length $z$, and the side opposite to it has length $r$. Therefore
$$
r=R\sin\phi,\ \ z=R\cos\phi, \ \ R=\sqrt{r^2+z^2}.
$$
Combining this with $x=r\cos\theta$, $y=r\sin\theta$, we get 
our conversion formulae.





\medskip

\subsection{Jacobian and Volume Elements}

For a general change of variables $(x,y,z)\to (u,v,w)$ in 3D, the volume element is
$$
dV=dxdydz=\left| \frac{\partial (x,y,z)}{\partial (u,v,w)} \right|\, dudvdw
$$
where
$$
\frac{\partial (x,y,z)}{\partial (u,v,w)}=\left|\begin{matrix} x_u& x_v& x_w\\
y_u& y_v& y_w\\ z_u& z_v& z_w
\end{matrix}\right|.
$$
This can be proved the same way as for changes of variables in 2 dimensions, but using the formula for the volume of a parallelepiped (triple product) instead of the area of a parallelogram. In the special case of spherical coordinates, we have
$$
\frac{\partial (x,y,z)}{\partial (R, \theta, \phi)} = - R^2 \sin \phi;
$$
this is proved in most multivariable calculus textbooks, or you can do it yourself by evaluating the determinant and using that $\sin^2 t + \cos^2 t =1$. Taking the absolute value to get the \underline{positive} volume element, we get the formula 
$$
\boxed{
\textrm{(Jacobian)} \ \ \ \  \left| \frac{\partial (x,y,z)}{\partial (R, \theta, \phi)} \right|
= R^2 \sin \phi.
}
$$

\medskip



In the Worked Problems Section, we use our conversion formulas to evaluate three-dimensional volume integrals as iterated integrals in the coordinate system $(R, \theta, \phi)$. 

%\pagebreak

\section*{Worked Problems}
\begin{enumerate}[1.]
\item{\it Find the volume of the region that lies above the cone $z = \sqrt{x^2 + y^2}$ and below the sphere $x^2 + y^2 + z^2 = 1$.}

\begin{figure}[h]
\centering
\includegraphics[width = .5\linewidth]{55fig3.pdf}
\caption{The region $D$ described above.}
\end{figure}

In spherical coordinates, the region $D$ is given by
$$
D: = \{(R,\theta, \phi) : 0 \leq R \leq 1, \,  0 \leq \theta < 2 \pi, \, 0 \leq \phi \leq \frac{\pi}{4} \},
$$
which is a much simpler representation than in Euclidean coordinates. Hence, we evaluate the volume integral as the iterated integral
$$
\iiint_{D} dV = \int_0^{\frac{\pi}{4}} d \phi  \int_{0}^{1} d R \int_0^{2 \pi} d \theta \underbrace{(R^2 \sin \phi)}_{\textrm{Jacobian}}
$$

\medskip
We calculate this iterated integral as the product of one-dimensional integrals:
\begin{eqnarray*}
\int_0^{\frac{\pi}{4}} d \phi  \int_{0}^{1} d R \int_0^{2 \pi} d \theta (R^2 \sin \phi) & = & \bigg( \int_0^{\frac{\pi}{4}} \sin \phi \, d \phi \bigg) \cdot \bigg( \int_0^1 R^2 dR \bigg) \cdot \bigg( \int_0^{2 \pi} d \theta \bigg) \\
\quad & = & \bigg(-\cos \phi \big\vert_{\phi = 0}^{\frac{\pi}{4}} \bigg) \cdot \bigg(\frac{R^3}{3}\big\vert_{R=0}^{1} \bigg) \cdot \bigg(\theta \big\vert_{\theta = 0}^{2 \pi} \bigg) \\
\quad & = & (1 - \frac{\sqrt{2}}{2}) \cdot (\frac{1}{3}) \cdot (2 \pi) \\
\quad & =& \frac{\pi}{3} (2 - \sqrt{2})
\end{eqnarray*}


\bigskip

\item{\it Find the average value of the function $f(x,y,z)  = z$ over the region $D$ from Worked Problem 1.}

\medskip
The average value of $f(x,y,z) = z$ over the region $D$ is defined as
$$
\bar{z} : = \frac{\iiint_{D} z \, dV}{\textrm{Volume of } D} = \frac{\iiint_{D} z dV}{\frac{\pi}{3} (2 - \sqrt{2})}
$$
Because the region $D$ has a simpler representation in spherical coordinates, we will evaluate the integral of $f$ over $D$ in spherical coordinates.  We have:
$$
\iiint_{D} z \, dV = \int_0^{\frac{\pi}{4}} d \phi  \int_{0}^{1} d R \int_0^{2 \pi} d \theta \underbrace{(R \cos \phi)}_{f(R,\theta,\phi)} \underbrace{(R^2 \sin \phi)}_{\textrm{Jacobian}}
$$

\medskip
Again, calculating this as a product of one-dimensional integrals gives
\begin{eqnarray*}
\iiint_{D} z \, dV & = & \bigg(\int_0^{\frac{\pi}{4}} \sin \phi \cos \phi d \phi \bigg) \cdot \bigg(\int_0^1 R^2 d R \bigg) \cdot \bigg(\int_0^{2 \pi} d\theta \bigg) \\
\quad & = & \frac{2 \pi}{4} \int_0^{\frac{\pi}{4}} \sin \phi \cos \phi \,  d \phi
\end{eqnarray*}
Now, using the identity $\sin \phi \cos \phi = \frac{1}{2} \sin (2 \phi)$, we have
$$
\iiint_{D} z \, dV = \frac{\pi}{4} \int_0^{\frac{\pi}{4}} \sin (2 \phi) \, d \phi = - \frac{\pi}{8} \cos (2 \phi) \big\vert_{\phi = 0}^{\frac{\pi}{4}} = \frac{\pi}{8}
$$
Thus
$$
\bar{z} : = \frac{\iiint_{D} z \, dV}{\textrm{Volume of } D} = \frac{\frac{\pi}{8}}{\frac{\pi}{3} (2 - \sqrt{2})} = \frac{3}{8(2 - \sqrt{2})} \approx 0.64
$$

\bigskip

\item{\it Evaluate the integral of $f(x,y,z) = x^2 + y^2$ over the region $B$ if $B$ is the top half of the ball of radius $a$ centered at the origin.}

\medskip
The region $B$ has a very simple representation in spherical coordinates:
$$
B : = \{(R, \theta, \phi) : 0 \leq R \leq a, \, 0 \leq \theta < 2 \pi, 0 \leq \phi \leq \pi/2 \}.
$$
In spherical coordinates, we have
$$
f(x,y,z) = f(x(R,\theta, \phi), y(R,\theta, \phi)) = R^2 \sin^2 \phi.
$$
One way of deriving this with less calculation is noticing that $x^2 + y^2 = r^2$ in cylindrical coordinates, and then $r = R \sin \phi$ in spherical coordinates.  Either way, our volume integral is given by the iterated integral
$$
\iiint_{B} (x^2 + y^2) \, dV = \int_0^{2 \pi} d \theta \int_0^{\pi/2} d \phi \int_0^{a} d R \underbrace{(R^2 \sin^2 \phi)}_{f(R,\theta, \phi)} \underbrace{(R^2 \sin \phi)}_{\textrm{Jacobian}}
$$

\medskip
Again, this is a product of one-dimensional integrals:
\begin{eqnarray*}
\iiint_{B} (x^2 + y^2) \, dV & = & \bigg(\int_0^{2 \pi} d \theta \bigg) \cdot \bigg(\int_0^a R^4 d R \bigg) \cdot \bigg(\int_0^{\pi/2} \sin^3 \phi \,  d \phi \bigg) \\
\quad & = & \frac{2 \pi a^5}{5} \int_0^{\pi/2} \sin^3 \phi \, d \phi
\end{eqnarray*}
To evaluate the final integral in the variable $\phi$, recall that $\sin^3 (\phi) = (1 - \cos^2 \phi)\sin \phi$, so that
\begin{eqnarray*}
\int_0^{\pi/2} \sin^3 \phi \, d \phi & = & \int_0^{\pi/2} - \cos^2 \phi \sin \phi \, d \phi + \int_0^{\pi/2} \sin \phi \, d \phi \\
\quad & = & \bigg( \frac{\cos^3 \phi}{3} \big\vert_{\phi = 0}^{\pi/2} \bigg) - \bigg( \cos \phi \big\vert_{\phi = 0}^{\pi/2}\bigg) \\
\quad & = & -\frac{1}{3} - (-1) \\
\quad & = & \frac{2}{3}
\end{eqnarray*}
So, combining our previous calculations shows that
$$
\iiint_{B} (x^2 + y^2) \, dV  = \frac{4 \pi a^5}{15}
$$

%\vfill
%
%\pagebreak

\bigskip

\item{\it Convert the integral
$$
I = \int_{-2}^{2} \int_{-\sqrt{4 - x^2}}^{\sqrt{4-x^2}} \int_0^{\sqrt{x^2 + y^2}} f(x,y,z) dz dy dx
$$
to (a) cylindrical and (b) spherical coordinates.
}


\begin{figure}[h]
\centering
\includegraphics[width = .4\linewidth]{55fig4.pdf}
\caption{The region $D$ of integration in Worked Problem 4, first given in Euclidean coordinates, is the region below the cone and above the $xy$-plane.}
\end{figure}


\begin{figure}[h]
\centering
\includegraphics[width = .4\linewidth]{55fig5.pdf}
\caption{A cross section of the region in Worked Problem 4 shows the dependence of $R$ upon the angular parameter $\phi$.}
\end{figure}
\end{enumerate}





\medskip

The first step is to identify the region of integration $D$. For the $z$ variable, we see that $0 \leq z \leq \sqrt{x^2 + y^2}$, which means that $z$ is bounded by the $xy$-plane (below) and the cone $z = \sqrt{x^2+y^2}$ (above). For the $y$ variable, we know that $-\sqrt{4 - x^2} \leq y \leq \sqrt{4-x^2}$ means that the $(x,y)$ variables together form a circular disc.  Putting this information together, we see that $D$ is the region inside a circular cylinder and outside of a cone.

\medskip
(a) In cylindrical coordinates, we have
$$
I = \int_0^2 dr \int_0^{2 \pi} d \theta \int_0^r dz\, f(r \cos \theta, r \sin \theta, z) \cdot r
$$

(b) In spherical coordinates, we have the restrictions $0 \leq \theta < 2 \pi$ and $\frac{\pi}{4} \leq \phi \leq \frac{\pi}{2}$.  Now, if $\phi$ is given,  then our $R$ variable is bounded below by zero.  The upper bound satisfies the equation $R(\phi) = \frac{2}{\sin \phi}$.  This can be inferred from Figure 4 below. As such, we have
$$
I = \int_0^{2 \pi} d \theta \int_{\frac{\pi}{4}}^{\frac{\pi}{2}} d \phi \int_0^{\frac{2}{\sin \phi}} dR \, f(R \cos \theta \sin \phi, R \sin \theta \sin \phi, R \cos \phi) R^2 \sin \phi.
$$




\section*{Practice Problems}
\begin{enumerate}[1.]
\item 
{A surface in ${\mathbb R}^3$ has the equation $x^2+y^2=z^2-4$. 
Convert the equation of this surface to cylindrical and spherical coordinates.}

\bigskip

\item 
{A surface in ${\mathbb R}^3$ has the equation $R^2-4R\sin\phi+3=0$
in spherical coordinates. Find its equation in cylindrical coordinates.  }


\bigskip

\item {Evaluate the integral
$\displaystyle \iiint_D \frac{\cos(x^2+y^2+z^2)}{\sqrt{x^2+y^2+z^2}}\, dV,$
 where $D$ is the region that lies above the cone
$z=\sqrt{x^2+y^2}$ and inside the sphere $x^2+y^2+z^2=4$.}

\bigskip

\item{Write the following integrals as iterated integrals in your choice of coordinates (rectangular $(x,y,z)$, 
cylindrical $(r,\theta,z)$, or spherical $(R,\theta,\phi)$). You do not need to evaluate the integrals.

\medskip

(a)
$ \iiint_D (x+y) \, dV$, where $D$ is the region bounded by the planes $y=x$, $y=4x$,
$x=2$, $z=0$, and $z=x$.

\medskip

(b)
$\iiint_D z^2 \, dV$, where $D$ is the spatial region outside the cone $z=\sqrt{x^2+y^2}$,
inside the cylinder $x^2+y^2=4$, and above the $xy$-plane. }


\bigskip

\item{Write out the integral
$\iiint_W x^2\,dV$
as an iterated integral in cylindrical coordinates, if $W$ is the three-dimensional
solid inside
the cylinder $x^2+y^2=1$, bounded from below by the cone $z=\sqrt{x^2+y^2}$ and
from above by the sphere $x^2+y^2+z^2=4$.  (You do not need to evaluate the integral.)}

\bigskip

\item{Find the mass of the solid bounded from below by the cone 
$\phi=\pi/3$ and from above by the sphere $R=2$, if the density at a point 
with spherical coordinates $(R,\theta,\phi)$ is $R$.  (Evaluate the integral.)
}


\bigskip

\item{Use the change of variables $x=u^2$, $y=v^2$, $z=w^2$ to evaluate
the volume of the region bounded by the coordinate planes and the 
surface $\sqrt{x}+\sqrt{y}+\sqrt{z}=1$.}

\end{enumerate}




