--- title: "Spherical coordinates" date: 2021-03-04 categories: - Mathematics - Physics layout: "concept" --- **Spherical coordinates** are an extension of polar coordinates to 3D. The position of a given point in space is described by three coordinates $(r, \theta, \varphi)$, defined as: * $r$: the **radius** or **radial distance**: distance to the origin. * $\theta$: the **elevation**, **polar angle** or **colatitude**: angle to the positive $z$-axis, or **zenith**, i.e. the "north pole". * $\varphi$: the **azimuth**, **azimuthal angle** or **longitude**: angle from the positive $x$-axis, typically in the counter-clockwise sense. Cartesian coordinates $(x, y, z)$ and the spherical system $(r, \theta, \varphi)$ are related by: $$\begin{aligned} \boxed{ \begin{aligned} x &= r \sin\theta \cos\varphi \\ y &= r \sin\theta \sin\varphi \\ z &= r \cos\theta \end{aligned} } \end{aligned}$$ Conversely, a point given in $(x, y, z)$ can be converted to $(r, \theta, \varphi)$ using these formulae: $$\begin{aligned} \boxed{ r = \sqrt{x^2 + y^2 + z^2} \qquad \theta = \arccos(z / r) \qquad \varphi = \mathtt{atan2}(y, x) } \end{aligned}$$ The spherical coordinate system is an orthogonal [curvilinear system](/know/concept/curvilinear-coordinates/), whose scale factors $h_r$, $h_\theta$ and $h_\varphi$ we want to find. To do so, we calculate the differentials of the Cartesian coordinates: $$\begin{aligned} \dd{x} &= \dd{r} \sin\theta \cos\varphi + \dd{\theta} r \cos\theta \cos\varphi - \dd{\varphi} r \sin\theta \sin\varphi \\ \dd{y} &= \dd{r} \sin\theta \sin\varphi + \dd{\theta} r \cos\theta \sin\varphi + \dd{\varphi} r \sin\theta \cos\varphi \\ \dd{z} &= \dd{r} \cos\theta - \dd{\theta} r \sin\theta \end{aligned}$$ And then we calculate the line element $\dd{\ell}^2$, skipping many terms thanks to orthogonality: $$\begin{aligned} \dd{\ell}^2 &= \:\:\:\: \dd{r}^2 \big( \sin^2(\theta) \cos^2(\varphi) + \sin^2(\theta) \sin^2(\varphi) + \cos^2(\theta) \big) \\ &\quad + \dd{\theta}^2 \big( r^2 \cos^2(\theta) \cos^2(\varphi) + r^2 \cos^2(\theta) \sin^2(\varphi) + r^2 \sin^2(\theta) \big) \\ &\quad + \dd{\varphi}^2 \big( r^2 \sin^2(\theta) \sin^2(\varphi) + r^2 \sin^2(\theta) \cos^2(\varphi) \big) \\ &= \dd{r}^2 + r^2 \: \dd{\theta}^2 + r^2 \sin^2(\theta) \: \dd{\varphi}^2 \end{aligned}$$ Finally, we can simply read off the squares of the desired scale factors $h_r^2$, $h_\theta^2$ and $h_\varphi^2$: $$\begin{aligned} \boxed{ h_r = 1 \qquad h_\theta = r \qquad h_\varphi = r \sin\theta } \end{aligned}$$ With these factors, we can easily convert things from the Cartesian system using the standard formulae for orthogonal curvilinear coordinates. The basis vectors are: $$\begin{aligned} \boxed{ \begin{aligned} \vu{e}_r &= \sin\theta \cos\varphi \:\vu{e}_x + \sin\theta \sin\varphi \:\vu{e}_y + \cos\theta \:\vu{e}_z \\ \vu{e}_\theta &= \cos\theta \cos\varphi \:\vu{e}_x + \cos\theta \sin\varphi \:\vu{e}_y - \sin\theta \:\vu{e}_z \\ \vu{e}_\varphi &= - \sin\varphi \:\vu{e}_x + \cos\varphi \:\vu{e}_y \end{aligned} } \end{aligned}$$ The basic vector operations (gradient, divergence, Laplacian and curl) are given by: $$\begin{aligned} \boxed{ \nabla f = \vu{e}_r \pdv{f}{r} + \vu{e}_\theta \frac{1}{r} \pdv{f}{\theta} + \mathbf{e}_\varphi \frac{1}{r \sin\theta} \pdv{f}{\varphi} } \end{aligned}$$ $$\begin{aligned} \boxed{ \nabla \cdot \vb{V} = \frac{1}{r^2} \pdv{(r^2 V_r)}{r} + \frac{1}{r \sin\theta} \pdv{(\sin\theta V_\theta)}{\theta} + \frac{1}{r \sin\theta} \pdv{V_\varphi}{\varphi} } \end{aligned}$$ $$\begin{aligned} \boxed{ \nabla^2 f = \frac{1}{r^2} \pdv{}{r}\Big( r^2 \pdv{f}{r} \Big) + \frac{1}{r^2 \sin\theta} \pdv{}{\theta}\Big( \sin\theta \pdv{f}{\theta} \Big) + \frac{1}{r^2 \sin^2(\theta)} \pdvn{2}{f}{\varphi} } \end{aligned}$$ $$\begin{aligned} \boxed{ \begin{aligned} \nabla \times \vb{V} &= \frac{\vu{e}_r}{r \sin\theta} \Big( \pdv{(\sin\theta V_\varphi)}{\theta} - \pdv{V_\theta}{\varphi} \Big) \\ &+ \frac{\vu{e}_\theta}{r} \Big( \frac{1}{\sin\theta} \pdv{V_r}{\varphi} - \pdv{(r V_\varphi)}{r} \Big) \\ &+ \frac{\vu{e}_\varphi}{r} \Big( \pdv{(r V_\theta)}{r} - \pdv{V_r}{\theta} \Big) \end{aligned} } \end{aligned}$$ The differential element of volume $\dd{V}$ takes the following form: $$\begin{aligned} \boxed{ \dd{V} = r^2 \sin\theta \dd{r} \dd{\theta} \dd{\varphi} } \end{aligned}$$ So, for example, an integral over all of space is converted like so: $$\begin{aligned} \iiint_{-\infty}^\infty f(x, y, z) \dd{V} = \int_0^{2\pi} \int_0^\pi \int_0^\infty f(r, \theta, \varphi) \: r^2 \sin\theta \dd{r} \dd{\theta} \dd{\varphi} \end{aligned}$$ The isosurface elements are as follows, where $S_r$ is a surface at constant $r$, etc.: $$\begin{aligned} \boxed{ \begin{aligned} \dd{S}_r = r^2 \sin\theta \dd{\theta} \dd{\varphi} \qquad \dd{S}_\theta = r \sin\theta \dd{r} \dd{\varphi} \qquad \dd{S}_\varphi = r \dd{r} \dd{\theta} \end{aligned} } \end{aligned}$$ Similarly, the normal vector element $\dd{\vu{S}}$ for an arbitrary surface is given by: $$\begin{aligned} \boxed{ \dd{\vu{S}} = \vu{e}_r \: r^2 \sin\theta \dd{\theta} \dd{\varphi} + \vu{e}_\theta \: r \sin\theta \dd{r} \dd{\varphi} + \vu{e}_\varphi \: r \dd{r} \dd{\theta} } \end{aligned}$$ And finally, the tangent vector element $\dd{\vu{\ell}}$ of a given curve is as follows: $$\begin{aligned} \boxed{ \dd{\vu{\ell}} = \vu{e}_r \: \dd{r} + \vu{e}_\theta \: r \dd{\theta} + \vu{e}_\varphi \: r \sin\theta \dd{\varphi} } \end{aligned}$$ ## References 1. M.L. Boas, *Mathematical methods in the physical sciences*, 2nd edition, Wiley.