The divergence theorem

Theorem statement

Definition 1. If $v:\R^3 \to \R^3$ is a $C^1$, vector field we define the divergence of $v$ by \begin{equation} \dv v = \sum_{i = 1}^3 \partial_i v_i. \end{equation}

Remark 2. The divergence is often denoted by $\operatorname{div}(v)$, and measures the infinitesimal outward flux of a vector field at a given point. Indeed, suppose $v$ represents the velocity field of a fluid and consider a small imaginary cube placed in the fluid. The difference in the horizontal components of the velocity on the right and left will contribute towards the horizontal outward flux, and is captured by the $\partial_1 v_1$ term. Similarly the $\partial_2 v_2$ and $\partial_3 v_3$ terms capture the outward fluxes parallel to the $x_2$ and $x_3$ axes respectively.

Regions of high divergence are associated with sources (e.g. where a fluid is being pumped in), and regions of high negative divergence are associated with sinks (e.g. where a fluid drains out).

Theorem 3 (Divergence theorem).

Let $U \subseteq \R^3$ be a bounded domain whose boundary is a (piecewise) $C^1$ surface denoted by $\partial U$. If $v:U \to \R^3$ is a vector field, then \begin{equation} \int_U (\dv v) \, dV = \oint_{\partial U} v \cdot \hat n \, dS, \end{equation} where $\hat n$ is the outward pointing unit normal vector.

Remark 4. Let $B_R = B(0, R)$, and suppose $v(x)$ represents the instantaneous velocity of a fluid at point $x$, and consider the volume averaged fluid flux out of $\partial B_R$: \begin{equation} \frac{1}{\vol(B_R)} \int_{\partial B_R} v \cdot \hat n \, dS \,. \end{equation} By the divergence theorem \begin{equation} \lim_{R \to 0} \frac{1}{\vol(B_R)} \int_{\partial B_R} v \cdot \hat n \, dS = \lim_{R \to 0} \frac{1}{\vol(B_R)} \int_{B_R} \dv v \, dV = \dv v(x_0) \,. \end{equation} In other words, the volume averaged flux of $v$ through a sphere of radius $R$ approaches $\dv v$ as the radius ${R \to 0}$. In this sense, $\dv v$ measures the (infinitesimal, volume averaged) outward flux of a vector field.

Remark 5. If $V \subseteq \R^2$, $U = V \times [a, b]$ is a cylinder, and $v:\R^3 \to \R^3$ is a vector field that doesn’t depend on $x_3$, then the divergence theorem reduces to the two dimensional version (which is essentially just Greens theorem).

Transformation of surface integrals

As before the proof reduces to checking the theorem on a cube, and coordinate changing. The coordinate change identity for surface integrals, however, is a bit more involved. To get started, here’s an identity we need.

Proposition 6. Suppose $(\Sigma_1, \hat n_1)$, $(\Sigma_2, \hat n_2)$ are are two oriented surfaces in $\R^3$, $U_1 \supseteq \Sigma_1$ is open, and $\varphi \colon U \to \R^3$ is an injective $C^2$ function such that $\varphi(\Sigma_1) = \Sigma_2$, $D\varphi \hat n_1 \cdot \hat n_2 \circ \varphi > 0$ and $\det(D \varphi) > 0$. Then for every continuous function $F \colon \Sigma_2 \to \R^3$ we have \begin{equation}\label{e:sint-transform}\tag{T} \int_{\Sigma_2} F \cdot \hat n_2 \, dS = \int_{\Sigma_1} \paren[\big]{\adj(D \varphi) F \circ \varphi} \cdot \hat n_1 \, dS \,, \end{equation} where $\adj(D\varphi)$ is the adjugate of $D\varphi$.

Lemma 7. If $u, v \in \R^3$, and $A \colon \R^3 \to \R^3$ is linear, then \begin{equation} (Au) \times (Av) = \cof(A) (u \times v)\,, \end{equation} where $\cof(A)$ is the cofactor matrix of $A$.

Proof sketch. Suppose first $A$ is invertible. For any $w \in \R^3$ we note \begin{align} Au \times Av \cdot w &= \det \begin{pmatrix} \uparrow & \uparrow & \uparrow \\ Au & Av & A (A^{-1} w) \\ \downarrow & \downarrow & \downarrow \end{pmatrix} =\det(A) \det \begin{pmatrix} \uparrow & \uparrow & \uparrow \\ u & v & A^{-1} w \\ \downarrow & \downarrow & \downarrow \end{pmatrix} \\ &= u \times v \cdot \adj(A) w = \cof(A) (u \times v) \cdot w \,. \end{align}

Proof of Proposition 6. Let $\sigma \colon U \to \Sigma_1$ be a parametrization of $(\Sigma_1, \hat n_2)$. Using the previous lemma, we verify $\sigma \circ \varphi$ is a parametrization of $(\Sigma_2, \hat n_2)$ and so (by the previous lemma again) \begin{align} \int_{\Sigma_2} F \cdot \hat n_2 \, dS &= \int_{U} F \circ \varphi \circ \sigma \cdot \partial_1 (\varphi \circ \sigma) \times \partial_2 (\varphi \circ \sigma) \, dS \\ &= \int_{\Sigma_1} F \circ \varphi \cdot \paren[\big]{ \cof(D \varphi_\sigma) (\partial_1 \sigma \times \partial_2 \sigma) } \, dS\,, \end{align} which proves \eqref{e:sint-transform} as desired.

Proof of the divergence theorem

The strategy is the same as the proof of Green’s theorem. Under a diffeomorphism, surface integrals transform according to \eqref{e:sint-transform}. We claim that the divergence of the corresponding function transforms exactly like volume integrals (i.e. with an extra determinant Jacobian factor). This is our first lemma.

Lemma 8. If $\varphi \colon \R^3 \to \R^3$ is $C^2$, and $v \colon \R^3 \to \R^3$ is $C^1$, then \begin{equation} \dv \paren[\big]{ \adj(D\varphi) \, v \circ \varphi } = \det(D\varphi) \, (\dv v) \circ \varphi\,. \end{equation}

Proof. This can directly be brute force derived using the product rule, chain rule and Clairaut’s theorem. However, the calculation is a little tedious if done directly. Here’s a slightly more conceptual way of doing it. It’s probably not any shorter, but you may find it easier to internalize. For convenience let $\adj(D\varphi) = (a_{i,j})$. By the product rule \begin{equation}\label{e:adj1}\tag{A} \dv \paren[\big]{ \adj(D\varphi) \, v \circ \varphi } = \sum_{i,j} \partial_i a_{i,j} v_j \circ \varphi + \sum_{i,j} a_{i,j} \partial_i (v_j \circ \varphi)\,. \end{equation} We claim the first sum on the right vanishes, and the second sum gives us what we want.

Let’s study the second term first. By the chain rule, \begin{equation} \sum_{i,j} a_{i,j} \partial_i (v_j \circ \varphi) = \sum_{i,j,k} a_{i,j} (\partial_k v_j) \circ \varphi \, \partial_i \varphi_k = \sum_{j, k} b_{k,j} (\partial_k v_j) \circ \varphi\,, \end{equation} where \begin{equation} b_{k,j} \defeq \sum_i a_{i,j} \partial_i \varphi_k = (D\varphi)_{k,i} \adj(D\varphi)_{i,j}\,. \end{equation} This is simply the $k, j$-th entry of the matrix product $D\varphi \adj(D\varphi)$, and hence $b_{k,j} = \det(D\varphi)$ if $k = j$ and is $0$ otherwise. This immediately shows \begin{equation} \sum_{i,j} a_{i,j} \partial_i (v_j \circ \varphi) = \det(D\varphi) (\dv v) \circ \varphi\,, \end{equation} as desired.

Now let’s study the first sum on the right of \eqref{e:adj1}. Note, by the formula for the adjugate, \begin{equation} \adj(D\varphi) = \begin{pmatrix} \uparrow & \uparrow & \uparrow\\ \grad \varphi_2 \times \grad \varphi_3 & \grad \varphi_3 \times \grad \varphi_1 & \grad \varphi_1 \times \grad \varphi_2 \\ \downarrow & \downarrow & \downarrow \end{pmatrix} \end{equation} By the vector calculus identities \begin{equation} \curl \grad f = 0 \qquad\text{and}\qquad \dv( G \times H ) = (\curl G) \cdot H - G \cdot (\curl H)\,, \end{equation} we see that each column of $\adj(D\varphi)$ has divergence $0$. (If you’re not familiar with these identities, they can be quickly checked using Clairaut’s theorem and the product rule.) This means for any $j$, \begin{equation} \sum_i \partial_i a_{i,j} v_j \circ \varphi = \dv\paren[\big]{ \adj(D\varphi) e_j } v_j \circ \varphi = 0\,, \end{equation} as desired. This finishes the proof.

That somewhat hairy calculation behind us, the proof of the divergence theorem is now quick.

Lemma 9. The divergence theorem holds if $U = (0, 1)^3$.

Proof sketch. This is just Fubini’s theorem and the fundamental theorem of calculus.

Lemma 10. Let $S = (0, 1)^3$. The divergence theorem holds on a domain $U$ if there exists a $C^2$ coordinate transformation $\varphi \colon S \to U$ such that $\varphi$ maps $\partial S$ to $\partial U$, and $\det(D \varphi) > 0$.

Proof sketch. By Lemma 8, \begin{align} \int_{\partial U} v \cdot \hat n \, dS &= \int_{\partial S} \adj(D\varphi) v \circ \varphi \cdot \hat n \, dS = \int_{\partial S} \dv(\adj(D\varphi) v \circ \varphi) \, dV \\ &= \int_{\partial S} \det(D \varphi) \dv v \circ \varphi \, dV = \int_{U} \dv v \, dV \end{align}

Proof sketch of Theorem 3. Break up $U$ into smaller domains where the previous lemma applies. (If you have to introduce internal boundaries, the surface integral along them will cancel as it appears twice with opposite orientations.)

Gauss’s gravitational law

Proposition 11 (Gauss’s gravitational law). Let $g:\R^3 \to \R^3$ be the gravitational field of a mass distribution (i.e. $g(x)$ is the force experienced by a point mass located at $x$). If $\Sigma$ is any closed ($C^1$) surface, then \begin{equation} \oint_\Sigma g \cdot \hat n \, dS = - 4 \pi G M, \end{equation} where $M$ is the mass enclosed by the region $M$. Here $G$ is the gravitational constant, and $\hat n$ is the outward pointing unit normal vector.

Proof sketch. The crux of the matter is the following calculation. Given a fixed $y \in \R^3$, define the vector field $F$ by \begin{equation} F(x) = \frac{x-y}{\abs{x - y}^3}. \end{equation} Then \begin{equation}\label{eqnGauss1}\tag{G} \oint_\Sigma F \cdot \hat n \, dS = \begin{cases} 4\pi & \text{if } y \text{ is in the region enclosed by } \Sigma\,,\\ 0 & \text{otherwise} \,. \end{cases} \end{equation} (This is the three dimensional analog of the winding number of the boundary we did earlier.)

For simplicity, we subsequently assume $y = 0$. To prove \eqref{eqnGauss1}, observe \begin{equation} \dv F = 0, \end{equation} when $x \neq 0$. Let $U$ be the region enclosed by $\Sigma$. If $0 \not\in U$, then the divergence theorem will apply to in the region $U$ and we have \begin{equation} \oint_\Sigma F \cdot \hat n \, dS = \int_U \dv F \, dV = 0. \end{equation}

On the other hand, if $0 \in U$, the divergence theorem will not directly apply, since $F \not \in C^1(U)$. To circumvent this, let $\epsilon > 0$ and $U’ = U - B(0, \epsilon)$, and $\Sigma’$ be the boundary of $U’$. Since $0 \not \in U’$, $F$ is $C^1$ on all of $U’$ and the divergence theorem gives \begin{equation} 0 = \int_{U’} \dv F \, dV = \int_{\partial U’} F \cdot \hat n \, dS, \end{equation} and hence \begin{equation} \oint_{\Sigma} F \cdot \hat n \, dS = -\oint_{\partial B(0, \epsilon)} F \cdot \hat n \, dS = \oint_{\partial B(0, \epsilon)} \frac{1}{\epsilon^2} \, dS = -4\pi, \end{equation} as claimed. (Above the normal vector on $\partial B(0, \epsilon)$ points outward with respect to the domain $U’$, and inward with respect to the ball $B(0, \epsilon)$.)

Now, in the general case, suppose the mass distribution has density $\rho$. Then the gravitational field $g(x)$ will be the super-position of the gravitational fields at $x$ due to a point mass of size $\rho(y) \, dV$ placed at $y$. Namely, this means \begin{equation} g(x) = -G \int_{\R^3} \frac{\rho(y) (x - y)}{\abs{x - y}^3} \, dV(y). \end{equation} Now using Fubini’s theorem, \begin{multline} \int_\Sigma g(x) \cdot \hat n(x) \, dS(x) = -G \int_{y \in \R^3} \rho(y) \int_{x \in \Sigma} \frac{x -y}{\abs{x - y}^3} \cdot \hat n(x) \, dS(x) \, dV(y) \\ = -4 \pi G \int_{y \in U} \rho(y) \, dV(y) = -4 \pi GM, \end{multline} where the second last equality followed from \eqref{eqnGauss1}.

Mean value property

We saw before that a Harmonic function on $\R^2$ satisfies the mean value property. The same is true in $\R^3$. The only change we need to make is to use the 3D divergence theorem instead of the 2D one, and replace $\ln \abs{x}$ with $1/\abs{x}$.

Theorem 12 (Mean value property). Let $R > 0$, $a \in \R^3$ and $u \colon \overline{B(a, R)} \to \R$ be a harmonic function. Show that \begin{equation} u(a) = \frac{1}{4\pi R^2} \int_{\partial B(a, R)} u \, d S \,. \end{equation}

Proof sketch. Let $N(x) = -1 / (4\pi \abs{x - a})$. (This is the three dimensional the Newton potential; the reason for the name is that $\grad N(x)$ is proportional to the gravitational force at $x$ due to a point mass at $a$.) Note $\lap N = 0$ on $\R^3 - 0$. Now for any $\epsilon > 0$, use Greens identity to show that \begin{equation} \int_{\partial B(a, R)} u \cdot \grad N \cdot \hat n \, dS = \int_{\partial B(a, \epsilon)} u \cdot \grad N \cdot \hat n \, dS \end{equation} and send $\epsilon \to 0$.

Divergence free vector fields

We saw earlier that any potential force is irrotational. Conversely, on simply connected domains any irrotational force is potential (see also the 3D version). Ignoring the physics, algebraically this means that $\curl (\grad V) = 0$, and conversely, in simply connected domains, any function for which $\curl F = 0$ must be of the form $F = -\grad V$ for some $V$.

Another vector calculus identity we saw was $\dv (\curl F) = 0$. Thus if $v = \curl F$, then we must have $\dv v = 0$. Is the converse true? That is, if $\dv v = 0$, then must there exist $F$ so that $v = \curl F$? This is also true, provided the domain satisfies certain topological restrictions. (We’re going to bypass those restrictions by assuming the domain is all of $\R^3$.)

Proposition 13. For any $C^2$ vector field $F:\R^3 \to \R^3$ we must have \begin{equation} \dv (\curl F) = 0. \end{equation} Conversely, if $v:\R^3 \to \R^3$ is a $C^1$ vector field for which $\dv v = 0$, there must exist a $C^1$ vector field $F:\R^3 \to \R^3$ such that $v = \curl F$.

Remark 14. If the vector field $v$ is only defined on a domain $U \subseteq \R^3$, then the above proposition is still true, provided the domain $U$ has “no holes”. More precisely, for any closed surface $\Sigma \subseteq U$, the entire region enclosed by $\Sigma$ must also be contained in $U$.

Proof sketch. Using Clairaut’s theorem, we can directly check $\dv (\curl F) = 0$. For the converse, suppose ${\dv v} = 0$. We need to find a $C^1$ vector field $F$ such that $\curl F = v$. Note that $\curl( F + \grad \phi) = \curl F$ for any $C^2$ function $\phi$. Set $G = F + \grad \phi$, and define \begin{equation} \phi(x) = -\int_0^{x_3} F_3(x_1, x_2, t) \, dt\,, \end{equation} and observe now that $G_3 = 0$. Thus if $v = \curl F$ for some $F$, we can always find a vector field $G$ such that $G_3 = 0$ and $v = \curl G$. Since this is simpler, we will directly construct a vector field $G$, with $G_3 = 0$, such that $\curl G = v$.

Note that if $G_3 = 0$, then \begin{equation} \curl G = \colvec{-\partial_3 G_2\\ \partial_3 G_1 \\ \partial_1 G_2 - \partial_2 G_1}\,. \end{equation} Since we want $\curl G = v$, we must have \begin{gather} G_2(x) = -\int_0^{x_3} v_1(x_1, x_2, t) \, dt + C_2(x_1, x_2)\,,\\ G_1(x) = \int_0^{x_3} v_2(x_1, x_2, t) \, dt + C_1(x_1, x_2)\,, \end{gather} where $C_1$, $C_2$ are two functions that only depend on $x_1$ and $x_2$. This shows $(\curl G) \cdot e_i = v_i$ for $i = 1, 2$, and to finish the proof we only need to verify the same identity for $i = 3$.

For this, recall $\dv v = 0$, and hence $\partial_3 v_3 = -\partial_1 v_1 - \partial_2 v_2$. Consequently, \begin{align} \curl G \cdot e_3 &= \partial_1 G_2 - \partial_2 G_1 = \int_0^{x_3} (-\partial_1 v_2 - \partial_2 v_2) \, dt + \partial_1 C_2 - \partial_2 C_1 \\ &= \int_0^{x_3} \partial_3 v_3(x_1, x_2, t) \, dt + \partial_1 C_2 - \partial_2 C_1 \\ &= v_3(x_1, x_2, x_3) - v_3(x_1, x_2, 0) + \partial_1 C_2 - \partial_2 C_1\,. \end{align} To finish the proof we only need to choose $C_1$ and $C_2$ so that \begin{equation} v_3(x_1, x_2, 0) = \partial_1 C_2 - \partial_2 C_1\,. \end{equation} This is easily arranged. Indeed, choose $C_1 = 0$ and \begin{equation} C_2(x_1, x_2) = \int_0^t v_3(t, x_2, 0) \, dt\,. \end{equation} With this choice of $G$, $C_1$ and $C_2$ we have $v = \curl G$ as desired.