Green's theorem in flux form says that the flow out of a plane region equals the total divergence inside. The divergence theorem is the same statement in space: the flux out of a closed surface equals the triple integral of the divergence over the solid inside. Sources inside produce the net outflow.
Key idea
Divergence theorem. Let $E$ be a solid region whose boundary $S$ is a closed, piecewise smooth surface with outward orientation. If $\mathbf{F}$ has continuous partial derivatives on an open region containing $E$, then
$$\iint_S \mathbf{F} \cdot d\mathbf{S} = \iiint_E \nabla \cdot \mathbf{F}\,dV.$$
Why it works
A small box $[x, x + \Delta x] \times [y, y + \Delta y] \times [z, z + \Delta z]$: the right face (normal $\mathbf{i}$) and the left face (normal $-\mathbf{i}$) together give about $$[P(x + \Delta x, y, z) - P(x, y, z)]\,\Delta y\,\Delta z \approx P_x\,\Delta V.$$ The other two pairs of faces give $Q_y\,\Delta V$ and $R_z\,\Delta V$. So the outward flux of a small box is about $(\nabla \cdot \mathbf{F})\,\Delta V$.
Many boxes: fill $E$ with small boxes and add their fluxes. Each inside face is shared by two boxes with opposite outward normals, so it cancels. What is left is the flux through the outer surface, and the sum of $(\nabla \cdot \mathbf{F})\,\Delta V$ is a Riemann sum for the triple integral.
Many boxes: fill $E$ with small boxes and add their fluxes. Each inside face is shared by two boxes with opposite outward normals, so it cancels. What is left is the flux through the outer surface, and the sum of $(\nabla \cdot \mathbf{F})\,\Delta V$ is a Riemann sum for the triple integral.
Worked examples
Worked example: A sphere
Find the outward flux of $\mathbf{F} = \langle x^3, y^3, z^3 \rangle$ through the sphere of radius $a$.
- $\nabla \cdot \mathbf{F} = 3x^2 + 3y^2 + 3z^2 = 3\rho^2$.
- $$\iiint_E 3\rho^2\,dV = \int_0^{2\pi} \int_0^\pi \int_0^a 3\rho^2 \cdot \rho^2\sin\varphi\,d\rho\,d\varphi\,d\theta = 2\pi \cdot 2 \cdot \frac{3a^5}{5} = \frac{12\pi a^5}{5}.$$
Answer: $\frac{12\pi a^5}{5}$
Worked example: A box
Find the outward flux of $\mathbf{F} = \langle xy, yz, zx \rangle$ through the surface of $[0, 1] \times [0, 2] \times [0, 3]$.
- $\nabla \cdot \mathbf{F} = y + z + x$.
- $\iiint (x + y + z)\,dV$ is the volume times the average value of $x + y + z$. Each coordinate averages to the middle of its interval, so this is ${}6\left(\frac{1}{2} + 1 + \frac{3}{2}\right) = 18$.
- Computing six separate surface integrals would give the same ${}18$, with much more work.
Answer: ${}18$
Worked example: A cylinder
Find the outward flux of $\mathbf{F} = \langle x, y, z^2 \rangle$ through the closed cylinder $x^2 + y^2 \le 4$, ${}0 \le z \le 3$ (side, top and bottom).
- $\nabla \cdot \mathbf{F} = 2 + 2z$.
- $$\iiint (2 + 2z)\,dV = (\text{area of the base}) \int_0^3 (2 + 2z)\,dz = 4\pi \cdot (6 + 9) = 60\pi.$$
Answer: ${}60\pi$
Common mistake
Using it on a surface that is not closed. The theorem needs the whole boundary of a solid. The upper hemisphere alone, or a cylinder without its top and bottom, encloses nothing, and $\iiint \nabla \cdot \mathbf{F}\,dV$ over "the inside" is not its flux. Close the surface first (add the base disk or the lids), apply the theorem, then subtract the flux through the added pieces, as in using the divergence theorem.