Tutorials › Calculus III › Divergence in Spherical Coordinates

Curl and Divergence · Tutorial 916 of 999

Divergence in Spherical Coordinates

Derive and apply the divergence formula for spherical components, including radial fields and fields whose components depend on the angles.

Advanced 10 min read

What You'll Learn

  • State the spherical-coordinate convention and its radial and angular scale factors.
  • Derive the divergence formula by comparing net flux through a small spherical wedge with its volume.
  • Simplify divergence for a radially symmetric vector field.
  • Compute divergence when spherical components depend on the polar or azimuthal angle.
  • Check spherical-coordinate results by converting the fields to Cartesian components.
  • Recognize why treating spherical components like Cartesian components gives an incorrect result.

Why Spherical Coordinates Change the Calculation

Divergence measures the local net outward flux of a vector field per unit volume. In Cartesian coordinates, the small volume used for this comparison has constant side lengths as it moves through space. In spherical coordinates, the lengths and areas associated with angular changes depend on the distance from the origin and on the polar angle.

Those changing lengths are captured by the coordinate scale factors. Once the factors are included, the divergence formula accounts for how much field crosses each face of a small spherical volume, including how the face areas change from one side to the other.

Coordinates, Components, and Scale Factors

Use spherical coordinates \((r,\theta,\phi)\), where \(r\) is the distance from the origin, \(\theta\) is the polar angle measured from the positive \(z\)-axis, and \(\phi\) is the azimuthal angle measured from the positive \(x\)-axis in the \(xy\)-plane. Thus \(r>0\), \(0<\theta<\pi\), and \(\phi\) is taken modulo \(2\pi\) on a regular coordinate region.

Write a vector field using its components along the spherical unit vectors: \(\mathbf{F}=F_r\mathbf{e}_r+F_\theta\mathbf{e}_\theta+F_\phi\mathbf{e}_\phi\). These are components along unit directions, not components along coordinate curves of unit length. An angular change \(d\theta\) corresponds to a physical length \(r\,d\theta\), while an angular change \(d\phi\) corresponds to \(r\sin\theta\,d\phi\).

Definition: For a differentiable vector field on a regular spherical-coordinate region, its spherical components \(F_r,F_\theta,F_\phi\) are the coefficients of the orthonormal unit vectors \(\mathbf{e}_r,\mathbf{e}_\theta,\mathbf{e}_\phi\). The corresponding scale factors are \(h_r=1\), \(h_\theta=r\), and \(h_\phi=r\sin\theta\).

The scale factors give the side lengths of a small spherical coordinate box: \(dr\) in the radial direction, \(r\,d\theta\) in the polar direction, and \(r\sin\theta\,d\phi\) in the azimuthal direction. In particular, its volume to leading order is \(r^2\sin\theta\,dr\,d\theta\,d\phi\).

The Divergence Formula

Theorem: On a region where spherical coordinates are regular, if the components of \(\mathbf{F}\) have continuous first partial derivatives, then $$ \nabla\cdot\mathbf{F} = \frac{1}{r^2\sin\theta} \left[ \frac{\partial}{\partial r}\left(r^2\sin\theta\,F_r\right) + \frac{\partial}{\partial\theta}\left(r\sin\theta\,F_\theta\right) + \frac{\partial}{\partial\phi}\left(rF_\phi\right) \right]. $$

Because \(r\) does not depend on \(\theta\) or \(\phi\), and \(\sin\theta\) does not depend on \(r\) or \(\phi\), the same formula can be written as

$$ \nabla\cdot\mathbf{F} = \frac{1}{r^2}\frac{\partial}{\partial r}(r^2F_r) + \frac{1}{r\sin\theta}\frac{\partial}{\partial\theta}(\sin\theta\,F_\theta) + \frac{1}{r\sin\theta}\frac{\partial F_\phi}{\partial\phi}. $$

The first form displays the flux contributions before division by the local volume. The second form is often convenient for calculation. Both require the same regularity assumptions and apply where the coordinates are regular; the displayed denominators should not be evaluated directly at \(r=0\) or \(\sin\theta=0\).

Why the Formula Works: A Small-Volume Derivation

Consider a small coordinate box with sides \(dr,d\theta,d\phi\), located near \((r,\theta,\phi)\). Its leading-order volume is \(r^2\sin\theta\,dr\,d\theta\,d\phi\). Divergence is the limiting net outward flux divided by volume, so we add the flux differences across each pair of opposite faces.

1
Radial faces.
The area of a face at radius \(r\) is \(r^2\sin\theta\,d\theta\,d\phi\). The outward flux difference between the faces at \(r+dr\) and \(r\), to first order, is \(\frac{\partial}{\partial r}(r^2\sin\theta F_r)\,dr\,d\theta\,d\phi\).
2
Polar faces.
A face at angle \(\theta\) has area \(r\sin\theta\,dr\,d\phi\). The difference of outward fluxes across the two polar faces is \(\frac{\partial}{\partial\theta}(r\sin\theta F_\theta)\,d\theta\,dr\,d\phi\), to first order.
3
Azimuthal faces.
A face at angle \(\phi\) has area \(r\,dr\,d\theta\). The outward flux difference across the two azimuthal faces is \(\frac{\partial}{\partial\phi}(rF_\phi)\,d\phi\,dr\,d\theta\), to first order.
4
Divide by volume.
Add the three first-order flux differences and divide by \(r^2\sin\theta\,dr\,d\theta\,d\phi\). In the limit as the box shrinks, the result is exactly the stated formula.

The factors inside the derivatives arise because the face areas vary across the box. This is why a formula that differentiates each spherical component as if it were a Cartesian component misses part of the local flux.

Radially Symmetric Fields

A radially symmetric vector field has the form \(\mathbf{F}=f(r)\mathbf{e}_r\), where \(f\) is differentiable. Its angular components vanish, so the general formula reduces to a one-variable expression.

$$ \nabla\cdot\bigl(f(r)\mathbf{e}_r\bigr) = \frac{1}{r^2}\frac{d}{dr}\bigl(r^2f(r)\bigr), \qquad r>0. $$

This expression involves both the change in the radial component and the growth of the area of a sphere as its radius increases. It is therefore not generally just \(f'(r)\).

Worked Example: The Position Vector Field

Let \(\mathbf{F}=r\mathbf{e}_r\), for \(r>0\). Its spherical components are \(F_r=r\), \(F_\theta=0\), and \(F_\phi=0\). Using the radial form,

$$ \nabla\cdot\mathbf{F} = \frac{1}{r^2}\frac{d}{dr}(r^2\cdot r) = \frac{1}{r^2}\frac{d}{dr}(r^3) = \frac{3r^2}{r^2} = 3. $$

To check, \(r\mathbf{e}_r=(x,y,z)\), so Cartesian differentiation gives \(\nabla\cdot\mathbf{F}=\partial x/\partial x+\partial y/\partial y+\partial z/\partial z=1+1+1=3\). The two calculations agree.

Worked Example: A Radial Inverse-Square Field

Consider \(\mathbf{F}=\frac{1}{r^2}\mathbf{e}_r\), defined for \(r>0\). Here \(f(r)=r^{-2}\), so

$$ \nabla\cdot\mathbf{F} = \frac{1}{r^2}\frac{d}{dr}\left(r^2\frac{1}{r^2}\right) = \frac{1}{r^2}\frac{d}{dr}(1) = 0, \qquad r>0. $$

The check is direct: the radial flux factor \(r^2F_r\) is the constant \(1\), whose derivative is zero. This computation is only on the stated domain \(r>0\); the field is not defined at the origin, so this calculation makes no claim about divergence there.

Fields with Angular Dependence

When a spherical component depends on \(\theta\) or \(\phi\), its angular derivative contributes to divergence. The next examples show that angular dependence can either produce a nonzero contribution or cancel another term.

Worked Example: A Field with Polar-Angle Dependence

Let \(\mathbf{F}=z\mathbf{k}\), where \(\mathbf{k}\) is the unit vector in the positive \(z\)-direction. Since \(z=r\cos\theta\), projection onto the spherical unit vectors gives \(F_r=r\cos^2\theta\), \(F_\theta=-r\sin\theta\cos\theta\), and \(F_\phi=0\). Apply the formula term by term:

$$ \begin{aligned} \nabla\cdot\mathbf{F} &= \frac{1}{r^2\sin\theta} \left[ \frac{\partial}{\partial r}(r^3\sin\theta\cos^2\theta) + \frac{\partial}{\partial\theta}(-r^2\sin^2\theta\cos\theta) \right]\\ &= \frac{1}{r^2\sin\theta} \left[ 3r^2\sin\theta\cos^2\theta -r^2(2\sin\theta\cos^2\theta-\sin^3\theta) \right]\\ &= \frac{r^2\sin\theta(\cos^2\theta+\sin^2\theta)} {r^2\sin\theta} =1. \end{aligned} $$

For a check, the original Cartesian field is \((0,0,z)\). Its divergence is \(0+0+1=1\), as found in spherical coordinates. In particular, the polar-angle derivative is needed: the radial term alone would give \(3\cos^2\theta\), not the full answer.

Worked Example: An Azimuth-Dependent Azimuthal Component

On a region with \(r>0\) and \(0<\theta<\pi\), let the only nonzero spherical component be \(F_\phi=r\sin\theta\cos\phi\). The radial and polar terms vanish. The remaining term is

$$ \nabla\cdot\mathbf{F} = \frac{1}{r^2\sin\theta} \frac{\partial}{\partial\phi}(r^2\sin\theta\cos\phi) = \frac{-r^2\sin\theta\sin\phi}{r^2\sin\theta} = -\sin\phi. $$

Check independently in Cartesian coordinates. Set \(\rho=r\sin\theta\), so \(x=\rho\cos\phi\), \(y=\rho\sin\phi\), and \(\mathbf{e}_\phi=(-\sin\phi,\cos\phi,0)\). Then \(F_\phi=r\sin\theta\cos\phi=x\), and

$$ \mathbf{F} = (-x\sin\phi,\;x\cos\phi,\;0) = \left(-\frac{xy}{\rho},\frac{x^2}{\rho},0\right). $$

Because \(\rho=\sqrt{x^2+y^2}\), differentiation gives

$$ \frac{\partial}{\partial x}\left(-\frac{xy}{\rho}\right) = -\frac{y}{\rho}+\frac{x^2y}{\rho^3}, \qquad \frac{\partial}{\partial y}\left(\frac{x^2}{\rho}\right) = -\frac{x^2y}{\rho^3}. $$

Adding these terms yields \(\nabla\cdot\mathbf{F}=-y/\rho=-\sin\phi\), which verifies the spherical result.

A Common Error: Omitting the Scale Factors

A frequent mistake is to differentiate \(F_r,F_\theta,F_\phi\) as though they were Cartesian components, without accounting for the changing spherical face areas. For example, using only \(\partial F_r/\partial r\) on \(\mathbf{F}=r\mathbf{e}_r\) gives \(1\). That is not the spherical divergence: it omits the outward flux increase caused by the growing area of spheres.

The correct calculation includes the radial area factor:

$$ \frac{1}{r^2}\frac{d}{dr}(r^2F_r) = \frac{1}{r^2}\frac{d}{dr}(r^3) = 3. $$

A useful check is to confirm that the \(r^2\) and \(\sin\theta\) factors are placed inside the appropriate derivatives in the full formula. The derivative with respect to \(\phi\) acts on \(rF_\phi\); it does not introduce an extra \(\sin\theta\) in that numerator.

Using the Formula Reliably

For a field with spherical components, a careful calculation follows a consistent sequence:

  1. Write the field as \(F_r\mathbf{e}_r+F_\theta\mathbf{e}_\theta+F_\phi\mathbf{e}_\phi\), using the stated angle convention.
  2. Identify which components depend on \(r\), \(\theta\), or \(\phi\).
  3. Substitute into the full divergence formula, preserving its scale factors.
  4. Differentiate each term with respect to its indicated variable, then simplify.
  5. Where practical, check the result by expressing the field in Cartesian components and differentiating.

The formula matters whenever spherical geometry makes the field or the region easier to describe than in Cartesian coordinates. Radially symmetric fields are a particularly clear case: one derivative of \(r^2f(r)\) captures how radial strength and spherical area combine. For fields with angular variation, the additional terms record the flux changes across the angular faces.

Check Your Understanding

Use the spherical divergence formula and show the intermediate steps in each calculation.

  1. For \(\mathbf{F}=r^2\mathbf{e}_r\), compute the divergence for \(r>0\), then check using Cartesian components.
  2. For \(\mathbf{F}=r\cos\theta\,\mathbf{e}_r\), compute the divergence and identify which variables its components depend on.
  3. If \(F_\theta=r\sin\theta\) and the other spherical components vanish, what is \(\nabla\cdot\mathbf{F}\)?
  4. If \(F_\phi=r\sin\theta\sin\phi\) and the other components vanish, compute the divergence, including the azimuthal derivative.
  5. Why does the radial term involve the derivative of \(r^2F_r\), rather than just the derivative of \(F_r\)?