07-10 — Divergence Theorem (Gauss)
Phase: 7 — Calculus IV: Vector Calculus Subject: 07-10 Prerequisites: 07-09 — Stokes' Theorem, 07-08 — Surface Integrals, 07-07 — Curl and Divergence Next subject: Phase 7 complete! Continue to Phase 8 — Linear Algebra.
Learning Objectives
By the end of this subject, you will be able to:
- State Gauss's divergence theorem and identify the relationship between the flux of a vector field through a closed surface and the integral of its divergence over the enclosed volume
- Apply the divergence theorem to convert difficult surface (flux) integrals over closed surfaces into triple integrals, and vice versa
- Compute flux through closed surfaces for vector fields with simple divergence, including electric fields (Gauss's law)
- Verify the divergence theorem for a given vector field and solid region
- Recognize when the divergence theorem applies (closed surface, outward orientation, C¹ field on the region) and handle edge cases with singularities
Core Content
1. Statement of the Divergence Theorem
⚠️ CRITICAL FOUNDATION: The Divergence Theorem ∬_S F · dS = ∭_E div F dV converts flux through a closed surface into a triple integral of divergence over the enclosed volume. It is the 3D generalization of Green's flux form and is fundamental to physics (Gauss's law, continuity equations).
Gauss's divergence theorem (also called Ostrogradsky's theorem) is the 3D analog of the flux-divergence form of Green's theorem. It relates the total flux of a vector field through a closed surface to the integral of divergence throughout the enclosed volume:
$∬_S F · dS = ∭_E div F dV $
where: - E is a bounded solid region in ℝ³ with piecewise-smooth boundary - S = ∂E is the closed surface bounding E, oriented outward - F(x, y, z) = ⟨P(x, y, z), Q(x, y, z), R(x, y, z)⟩ is a C¹ vector field on an open region containing E
Expanded form:
$∬_S (P dy dz + Q dz dx + R dx dy) = ∭_E (∂P/∂x + ∂Q/∂y + ∂R/∂z) dV $
or equivalently:
$∬_S F · n dS = ∭_E (P_x + Q_y + R_z) dV $
where n is the outward unit normal to S.
Physical interpretation: The total flux exiting a closed surface equals the total "expansion" (divergence) occurring inside the volume. If fluid flows with velocity field F: - ∬_S F · n dS = net rate of fluid flowing out through S - ∭_E div F dV = total rate at which fluid is being created (sources − sinks) inside E
The theorem says these two quantities must be equal — fluid leaving the region must have come from somewhere inside.
The "Complete Trinity" of Vector Calculus:
| Theorem | Dimension | Relates | Generalizes |
|---|---|---|---|
| FTC | 1D | ∫_a^b f'(x)dx = f(b)−f(a) | — |
| Green's (Flux) | 2D | ∮C F·n ds = ∬_D div{2D} F dA | FTC |
| Stokes' | 2D→3D | ∮_C F·dr = ∬_S (curl F)·dS | Green's (Circulation) |
| Divergence | 3D | ∬_S F·dS = ∭_E div F dV | Green's (Flux) |
All four theorems share the same pattern: integral of a derivative over a region = integral of the original function over the boundary. The dimension of the region increases from 1 to 3.
2. Orientation — Outward Normal
For the divergence theorem, S is a closed surface (bounding a solid region), and the orientation is always outward — the normal vector points away from the enclosed region.
Example: For the solid sphere x² + y² + z² ≤ R², the boundary is the sphere x² + y² + z² = R², with outward normal n = ⟨x/R, y/R, z/R⟩ (the radial outward direction).
Sign conventions: - Outward flux (divergence theorem standard): ∬_S F · n_out dS = + ∭_E div F dV - If you use inward normal: the result is −∭_E div F dV (sign flip)
Orientation component-by-component for common shapes:
| Solid Region | Outward Normals on Each Face |
|---|---|
| Cube [0,a]×[0,b]×[0,c] | ±x faces: ±⟨1,0,0⟩; ±y faces: ±⟨0,1,0⟩; ±z faces: ±⟨0,0,1⟩ |
| Cylinder x²+y² ≤ R², 0 ≤ z ≤ h | Top: ⟨0,0,1⟩; Bottom: ⟨0,0,−1⟩; Side: ⟨x/R, y/R, 0⟩ |
| Sphere x²+y²+z² ≤ R² | n = ⟨x/R, y/R, z/R⟩ (radial outward) |
3. Computing Flux with the Divergence Theorem — Main Applications
Application 1: Replace a hard surface integral with an easy triple integral.
This is the most common use case.
Example 1 — Cube: Evaluate ∬_S F · dS where F(x, y, z) = ⟨x², xy, xz⟩ and S is the surface of the unit cube [0, 1] × [0, 1] × [0, 1].
$Direct method: Compute flux through 6 faces and sum. Tedious.
Divergence method:
div F = ∂P/∂x + ∂Q/∂y + ∂R/∂z = 2x + x + x = 4x.
∬_S F · dS = ∭_E 4x dV = ∫₀¹ ∫₀¹ ∫₀¹ 4x dz dy dx
= ∫₀¹ ∫₀¹ 4x dy dx = ∫₀¹ 4x dx = [2x²]₀¹ = 2.
$
Compare with direct computation: - x = 1 face (outward = ⟨1,0,0⟩): F = ⟨1, y, z⟩, F·n = 1. ∬ dS = 1. ✓ - x = 0 face (outward = ⟨−1,0,0⟩): F = ⟨0, 0, 0⟩, F·n = 0. ∬ 0 dS = 0. - y = 1 face (outward = ⟨0,1,0⟩): F = ⟨x², x, xz⟩, F·n = x. ∬ x dS = ∫₀¹∫₀¹ x dz dx = 1/2. - y = 0 face (outward = ⟨0,−1,0⟩): F·n = −(0) = 0. - z = 1 face (outward = ⟨0,0,1⟩): F·n = x. ∬ x dS = ∫₀¹∫₀¹ x dy dx = 1/2. - z = 0 face (outward = ⟨0,0,−1⟩): F·n = −0 = 0.
Sum: 1 + 0 + 1/2 + 0 + 1/2 + 0 = 2. Matches the triple integral. ✓
The divergence theorem turned 6 surface integrals into a single triple integral.
$ **Example 2 — Sphere:** Evaluate ∬_S F · dS where F(x, y, z) = ⟨x³, y³, z³⟩ and S is the sphere x² + y² + z² = 4, oriented outward. $
div F = ∂(x³)/∂x + ∂(y³)/∂y + ∂(z³)/∂z = 3x² + 3y² + 3z² = 3(x² + y² + z²).
∬_S F · dS = ∭_E 3(x² + y² + z²) dV, E: x² + y² + z² ≤ 4.
Use spherical coordinates (ρ, φ, θ): x² + y² + z² = ρ².
∭_E 3ρ² dV = 3 ∫₀^{2π} ∫₀^π ∫₀² ρ² · ρ² sin φ dρ dφ dθ = 3 · 2π · [−cos φ]₀^π · [ρ⁵/5]₀² = 3 · 2π · 2 · (32/5) = 3 · 4π · 32/5 = 384π/5.
$ **Example 3 — Half-cylinder:** Find the flux of F(x, y, z) = ⟨x, y, −2z⟩ through the closed surface consisting of the cylinder x² + y² = 1, 0 ≤ z ≤ 1, plus the top and bottom disks. $
div F = 1 + 1 + (−2) = 0.
If div F = 0 everywhere, then ∬_S F · dS = ∭_E 0 dV = 0.
No integration needed! The flux through the entire closed surface is zero. (Individual faces may have non-zero flux, but the total sums to zero.)
This is a powerful shortcut: if div F = 0, the flux through ANY closed surface is zero.
**Application 2: Compute a triple integral as a surface integral.**
Sometimes the triple integral is harder than the surface integral.
**Example 4:** Compute ∭_E (2x + 3y − z) dV where E is the unit cube [0, 1]³ by finding a vector field F whose divergence is 2x + 3y − z.
We need div F = 2x + 3y − z. One choice: P(x, y, z) = x² (since ∂P/∂x = 2x) Q(x, y, z) = 3xy (since ∂Q/∂y = 3x... wait, we need 3y, not 3x) Actually: Q(x, y, z) = (3/2)y² (since ∂Q/∂y = 3y) R(x, y, z) = −xz (since ∂R/∂z = −x... wait, need −z) Re-think: R(x, y, z) = −(1/2)z² (since ∂R/∂z = −z)
So: F = ⟨x², (3/2)y², −(1/2)z²⟩.
div F = 2x + 3y − z. ✓
Now by the divergence theorem: ∭_E (2x + 3y − z) dV = ∬_S F · dS
over the 6 faces of the cube with outward normals.
x=1 face (n=⟨1,0,0⟩): F = ⟨1, (3/2)y², −(1/2)z²⟩, F·n = 1. ∬ dS = area = 1. x=0 face (n=⟨−1,0,0⟩): F = ⟨0, (3/2)y², −(1/2)z²⟩, F·n = 0. Flux = 0.
y=1 face (n=⟨0,1,0⟩): F·n = (3/2)(1)² = 3/2. ∬ dS = 3/2. y=0 face (n=⟨0,−1,0⟩): F·n = −(3/2)(0)² = 0. Flux = 0.
z=1 face (n=⟨0,0,1⟩): F·n = −(1/2)(1)² = −1/2. ∬ dS = −1/2. z=0 face (n=⟨0,0,−1⟩): F·n = −[−(1/2)(0)²] = 0. Flux = 0.
Total flux = 1 + 0 + 3/2 + 0 − 1/2 + 0 = 2.
Verify: ∭_E (2x+3y−z) dV = ∫₀¹∫₀¹∫₀¹ (2x+3y−z) dz dy dx = ∫₀¹∫₀¹ [2xz + 3yz − z²/2]₀¹ dy dx = ∫₀¹∫₀¹ (2x + 3y − 1/2) dy dx = ∫₀¹ [2xy + (3/2)y² − y/2]₀¹ dx = ∫₀¹ (2x + 3/2 − 1/2) dx = ∫₀¹ (2x + 1) dx. = [x² + x]₀¹ = 2. ✓
(This direction — triple integral → surface integral — is less common but good to know.)
### 4. Gauss's Law — The Divergence Theorem in Electromagnetism
One of the most important applications: **Gauss's law for electric fields.**
The electric field E due to a point charge q at the origin is:
E(r) = (q / 4πε₀) · (r / |r|³) = (q / 4πε₀) · ⟨x, y, z⟩ / (x² + y² + z²)^{3/2}
$ **Gauss's Law:** The electric flux through any closed surface S equals the total enclosed charge divided by ε₀: $
∬_S E · dS = Q_enclosed / ε₀
**Derivation using the divergence theorem:**
For a point charge q at the origin: div E = 0 everywhere except at the origin (where it's undefined). The divergence theorem doesn't directly apply because of the singularity.
But for any volume NOT containing the origin, div E = 0 → flux through the boundary is 0.
For a sphere of radius R centered at the origin:
E = (q / 4πε₀) · ⟨x, y, z⟩ / R³ n = ⟨x/R, y/R, z/R⟩ E · n = (q / 4πε₀) · (x² + y² + z²) / R⁴ = (q / 4πε₀) · 1/R²
dS = R² sin φ dφ dθ (surface area element for sphere)
∬_S E · dS = (q / 4πε₀) · (1/R²) · 4πR² = q/ε₀.
By using a small sphere around the singularity and the divergence theorem on the region between surfaces, one can prove this holds for ANY closed surface containing q. The flux through any closed surface surrounding the charge is q/ε₀.
**General Gauss's law:** For a continuous charge distribution with density ρ(x, y, z):
∇ · E = ρ / ε₀ (differential form)
∬_S E · dS = (1/ε₀) ∭_E ρ dV = Q_enclosed / ε₀ (integral form)
The divergence theorem is the bridge between these two forms.
### 5. Verifying the Divergence Theorem
**Example 5 — Full verification:** Verify the divergence theorem for F(x, y, z) = ⟨xy, yz, zx⟩ over the solid bounded by the coordinate planes and the plane x + y + z = 1.
Step 1: Compute div F. div F = ∂(xy)/∂x + ∂(yz)/∂y + ∂(zx)/∂z = y + z + x = x + y + z.
Step 2: Triple integral over tetrahedron E: x ≥ 0, y ≥ 0, z ≥ 0, x+y+z ≤ 1.
∭_E (x + y + z) dV.
By symmetry (all three variables are symmetric in the domain and integrand): ∭_E x dV = ∭_E y dV = ∭_E z dV.
Compute ∭_E x dV: ∫₀¹ ∫₀^{1−x} ∫₀^{1−x−y} x dz dy dx = ∫₀¹ ∫₀^{1−x} x(1−x−y) dy dx = ∫₀¹ x[(1−x)y − y²/2]₀^{1−x} dx = ∫₀¹ x[(1−x)² − (1−x)²/2] dx = ∫₀¹ x · (1−x)²/2 dx = (1/2) ∫₀¹ x(1 − 2x + x²) dx = (1/2) ∫₀¹ (x − 2x² + x³) dx = (1/2)[x²/2 − 2x³/3 + x⁴/4]₀¹ = (1/2)(1/2 − 2/3 + 1/4) = (1/2)(6/12 − 8/12 + 3/12) = (1/2)(1/12) = 1/24.
So ∭_E (x+y+z) dV = 3 · (1/24) = 1/8.
Step 3: Surface integral over S. S has 4 faces: S₁: x = 0 (triangle in yz-plane), outward n = ⟨−1, 0, 0⟩ S₂: y = 0 (triangle in xz-plane), outward n = ⟨0, −1, 0⟩ S₃: z = 0 (triangle in xy-plane), outward n = ⟨0, 0, −1⟩ S₄: x + y + z = 1, outward n = ⟨1, 1, 1⟩/√3
Face S₁ (x = 0): F = ⟨0, yz, 0⟩. n = ⟨−1, 0, 0⟩. F·n = 0. Flux = 0. Face S₂ (y = 0): F = ⟨0, 0, zx⟩. n = ⟨0, −1, 0⟩. F·n = 0. Flux = 0. Face S₃ (z = 0): F = ⟨xy, 0, 0⟩. n = ⟨0, 0, −1⟩. F·n = 0. Flux = 0.
Three faces give zero flux because F has zero component in the outward normal direction on each coordinate plane.
Face S₄ (x + y + z = 1): Parametrize: r(x, y) = ⟨x, y, 1−x−y⟩, D: x ≥ 0, y ≥ 0, x + y ≤ 1. r_x = ⟨1, 0, −1⟩, r_y = ⟨0, 1, −1⟩. r_x × r_y = ⟨1, 1, 1⟩. (Points outward from tetrahedron? The tetrahedron sits in the first octant; ⟨1,1,1⟩ points away from the origin → outward. ✓)
dS = ⟨1, 1, 1⟩ dx dy (the magnitude √3 is already absorbed — wait, no: dS = r_x × r_y dA = ⟨1,1,1⟩ dA, so the vector dS has magnitude √3 dA).
Actually, let's be precise. The surface integral ∬ F · dS uses the VECTOR dS = n dS = r_x × r_y dA = ⟨1, 1, 1⟩ dx dy (this already incorporates both direction and magnitude).
On S₄: F(x, y, z) = ⟨xy, y(1−x−y), (1−x−y)x⟩.
F · dS = [xy + y(1−x−y) + x(1−x−y)] dx dy = [xy + y − xy − y² + x − x² − xy] dx dy = [y − y² + x − x² − xy] dx dy.
∬_{S₄} F · dS = ∬_D (x + y − x² − y² − xy) dA.
D is the triangle 0 ≤ x ≤ 1, 0 ≤ y ≤ 1−x.
Compute each term: ∬_D x dA = 1/24 (computed earlier). ∬_D y dA = 1/24 (by symmetry).
∬_D x² dA = ∫₀¹ ∫₀^{1−x} x² dy dx = ∫₀¹ x²(1−x) dx = ∫₀¹ (x² − x³) dx = [x³/3 − x⁴/4]₀¹ = 1/3 − 1/4 = 1/12.
∬_D y² dA = 1/12 (by symmetry).
∬_D xy dA = ∫₀¹ ∫₀^{1−x} xy dy dx = ∫₀¹ x · (1−x)²/2 dx = (1/2) ∫₀¹ x(1−2x+x²) dx = (1/2)(1/2 − 2/3 + 1/4) = (1/2)(6/12−8/12+3/12) = (1/2)(1/12) = 1/24.
Total = 1/24 + 1/24 − 1/12 − 1/12 − 1/24 = (1+1−2−2−1)/24 = −3/24 = −1/8.
Wait — this is negative, but the triple integral gave +1/8. What went wrong?
Let me recheck the orientation. The outward normal for the slanted face of the tetrahedron (the one bounding the first octant) should point AWAY from the origin, i.e., with all positive components. ⟨1, 1, 1⟩ does have all positive components. But the tetrahedron is x ≥ 0, y ≥ 0, z ≥ 0, x + y + z ≤ 1. The slanted face is the "hypotenuse" face.
Hmm — the vector r_x × r_y = ⟨1, 1, 1⟩ for the parametrization r(x,y) = ⟨x, y, 1−x−y⟩. Does this point outward?
At the point (0,0,1) on S₄ (x=0, y=0), the outward direction from the tetrahedron should point generally toward (1,1,0) or similar. The outward normal to the plane x+y+z=1 is ⟨1,1,1⟩ (since the plane equation is ⟨1,1,1⟩·⟨x,y,z⟩ = 1, the outward direction to the half-space x+y+z ≥ 1 is ⟨1,1,1⟩). For the tetrahedron in the region x+y+z ≤ 1, the OUTWARD normal through this face is ⟨1,1,1⟩ (since it points away from the interior, toward the half-space x+y+z > 1).
r_x × r_y = ⟨1, 1, 1⟩. ✓
But I got −1/8... Let me re-examine. The flux through S₄ from my computation is −1/8. But the triple integral (the total flux) is +1/8. Since S₁, S₂, S₃ all give 0, the flux through S₄ alone should be +1/8.
Let me recompute F · dS more carefully.
On S₄: z = 1 − x − y. F(x, y, z) = ⟨xy, yz, zx⟩ = ⟨xy, y(1−x−y), (1−x−y)x⟩.
F · dS = ⟨xy, y(1−x−y), x(1−x−y)⟩ · ⟨1, 1, 1⟩ dx dy = [xy + y − xy − y² + x − x² − xy] dx dy
Let me expand the y-component more carefully: y(1−x−y) = y − xy − y². ✓
The x-component (from zx): x(1−x−y) = x − x² − xy. ✓
Sum: xy + (y − xy − y²) + (x − x² − xy) = xy + y − xy − y² + x − x² − xy = y + x − y² − x² − xy. ✓
So the integrand is x + y − x² − y² − xy.
My computation of the double integrals: ∬_D x dA = 1/24 ✓ ∬_D y dA = 1/24 ✓ ∬_D x² dA = 1/12 ✓ ∬_D y² dA = 1/12 ✓ ∬_D xy dA = 1/24 ✓
So total = 1/24 + 1/24 − 1/12 − 1/12 − 1/24 = (1 + 1 − 2 − 2 − 1)/24 = −3/24 = −1/8.
Hmm... −1/8 vs expected +1/8. The sign is flipped. Let me re-examine the orientation.
Actually — r(x,y) = ⟨x, y, 1−x−y⟩. Let me think about the cross product order. r_x × r_y gives a normal. For the upward orientation convention: if x increases to the right and y increases upward, then r_x × r_y points out of the page (toward the viewer). But that's for standard xy orientation.
Let me think about this more concretely. The tetrahedron is in the first octant, bounded by x=0, y=0, z=0, and x+y+z=1. The slanted face x+y+z=1 has the unit outward normal ⟨1,1,1⟩/√3.
r_x = ⟨1, 0, ∂z/∂x⟩ = ⟨1, 0, −1⟩ r_y = ⟨0, 1, ∂z/∂y⟩ = ⟨0, 1, −1⟩
r_x × r_y = det|i j k | |1 0 −1| |0 1 −1| = i(0·(−1) − (−1)·1) − j(1·(−1) − (−1)·0) + k(1·1 − 0·0) = i(0 + 1) − j(−1 − 0) + k(1) = ⟨1, 1, 1⟩.
The components are all positive. This points generally away from the origin. Is this outward to the tetrahedron? The tetrahedron sits in the region x ≥ 0, y ≥ 0, z ≥ 0, x+y+z ≤ 1. Its center of mass is roughly at (1/4, 1/4, 1/4). From the center outward through the slanted face, the direction should have all positive components. So ⟨1,1,1⟩ IS outward. ✓
But I got −1/8... Let me carefully recompute each volume integral and each surface integral independently.
Actually, wait. Let me recompute ∭_E x dV.
E: 0 ≤ x ≤ 1, 0 ≤ y ≤ 1−x, 0 ≤ z ≤ 1−x−y.
∭_E x dV = ∫₀¹∫₀^{1−x}∫₀^{1−x−y} x dz dy dx = ∫₀¹∫₀^{1−x} x(1−x−y) dy dx = ∫₀¹ x[(1−x)y − y²/2]₀^{1−x} dx = ∫₀¹ x[(1−x)² − (1−x)²/2] dx = ∫₀¹ x · (1−x)²/2 dx = (1/2) ∫₀¹ x(1 − 2x + x²) dx = (1/2) ∫₀¹ (x − 2x² + x³) dx = (1/2)[x²/2 − 2x³/3 + x⁴/4]₀¹ = (1/2)(1/2 − 2/3 + 1/4) = (1/2)(6/12 − 8/12 + 3/12) = (1/2)(1/12) = 1/24. ✓
So ∭_E (x+y+z) dV = 3/24 = 1/8. ✓
Now let me re-evaluate the surface integral through S₄, more carefully:
D = {0 ≤ x ≤ 1, 0 ≤ y ≤ 1−x}.
F·dS = (xy + y − xy − y² + x − x² − xy) dx dy = (x + y − x² − y² − xy) dx dy. ✓
Now, let me compute each double integral accurately:
(1) ∬_D x dA: ∫₀¹ ∫₀^{1−x} x dy dx = ∫₀¹ x(1−x) dx = ∫₀¹ (x − x²) dx = [x²/2 − x³/3]₀¹ = 1/2 − 1/3 = 1/6.
WAIT. My earlier computation gave 1/24. Let me recheck.
Ah, I see the issue. In the volume calculation, I used 0 ≤ z ≤ 1−x−y, so the dz integral contributs a factor (1−x−y). For the surface integral, there is no z-integration — just the 2D area.
So: ∬_D x dA = ∫₀¹ ∫₀^{1−x} x dy dx = ∫₀¹ x(1−x) dx = [x²/2 − x³/3]₀¹ = 1/2 − 1/3 = (3−2)/6 = 1/6.
My earlier computation was WRONG because I confused this with the volume integral of x! The volume integral ∭_E x dV has an extra factor of (1−x−y) from the z-integration. But ∬_D x dA is just the 2D integral.
Let me recompute all the surface integral terms:
(1) ∬_D x dA = 1/6. (2) ∬_D y dA = 1/6 (by symmetry). (3) ∬_D x² dA = ∫₀¹ ∫₀^{1−x} x² dy dx = ∫₀¹ x²(1−x) dx = ∫₀¹ (x² − x³) dx = [x³/3 − x⁴/4]₀¹ = 1/3 − 1/4 = 1/12. ✓ (This was correct!) (4) ∬_D y² dA = 1/12 (by symmetry). (5) ∬_D xy dA = ∫₀¹ ∫₀^{1−x} xy dy dx = ∫₀¹ x·(1−x)²/2 dx = (1/2)∫₀¹ x(1−2x+x²)dx = (1/2)(1/2 − 2/3 + 1/4) = (1/2)(6/12−8/12+3/12) = (1/2)(1/12) = 1/24. ✓
Total = 1/6 + 1/6 − 1/12 − 1/12 − 1/24 = (4/24 + 4/24 − 2/24 − 2/24 − 1/24) = 3/24 = 1/8. ✓
So actually the surface integral gives +1/8, matching the triple integral. My earlier error was in computing ∬_D x dA and ∬_D y dA — I used the volume-integral values instead of the area-integral values.
So the verification is: ∭_E div F dV = 1/8 = ∬_S F·dS. ✓
The corrected computation (for reference - use this in the actual file): Total surface flux through S₄ = 1/6 + 1/6 − 1/12 − 1/12 − 1/24 = 3/24 = 1/8. ✓
Other three faces contribute 0. Total = 1/8. Matches the triple integral. ✓
Let me rewrite this section more cleanly.
### 6. Common Misconceptions and Edge Cases
**Misconception 1: "The surface must be a sphere or cube."** Reality: The divergence theorem applies to ANY piecewise-smooth closed surface bounding a solid region — spheres, cubes, cylinders, toruses, and any topologically simple closed shape.
**Misconception 2: "Divergence theorem = Stokes' theorem on a closed surface."** Reality: They're different:
- Divergence theorem: flux of F through closed surface = volume integral of div F
- Stokes' theorem on a closed surface: ∬_S (curl F) · dS = 0 (since ∂(closed surface) = ∅)
- The two are related: div(curl F) = 0 is a consequence of both theorems together
**Misconception 3: "If div F = 0, flux through any surface is zero."** Reality: div F = 0 means flux through any CLOSED surface is zero (by the divergence theorem). An open surface with the same boundary can have non-zero flux.
**Edge case: singularities inside the volume.** If F has a singularity inside E, the divergence theorem doesn't apply directly. Instead, exclude the singularity with a small surface, apply the theorem to the region between surfaces, and take a limit. This is exactly how Gauss's law is proved for point charges.
**Edge case: vector fields that aren't defined everywhere.** For F(x, y, z) = r/|r|³ (the inverse-square field), div F = 0 everywhere except at (0, 0, 0) where it's undefined. The flux through a sphere centered at the origin is 4π, even though div F = 0 almost everywhere. The divergence theorem only works if you include the singularity properly (via a delta function: div(r/|r|³) = 4π δ(r)).
---
---
## Key Terms
- **Divergence**
## Worked Examples
### Worked Example 1: Flux Through a Cylinder
**Problem:** Compute the outward flux of F(x, y, z) = ⟨x², y², z²⟩ through the closed cylinder x² + y² ≤ 4, 0 ≤ z ≤ 3.
Step 1: Compute div F. div F = 2x + 2y + 2z = 2(x + y + z).
Step 2: Set up the triple integral over E: x² + y² ≤ 4, 0 ≤ z ≤ 3. Use cylindrical coordinates (r, θ, z): x = r cos θ, y = r sin θ, z = z. dV = r dz dr dθ.
∭_E 2(x + y + z) dV = 2 ∭_E (x + y + z) dV.
By symmetry: ∭_E x dV = 0, ∭_E y dV = 0. (Odd functions over symmetric domain in θ.)
∭_E z dV = ∫₀^{2π} ∫₀² ∫₀³ z · r dz dr dθ = 2π · [r²/2]₀² · [z²/2]₀³ = 2π · 2 · 9/2 = 18π.
Total flux = 2 · 18π = 36π.
Step 3: Quick verification — direct surface integral (abbreviated): Top disk (z=3, n=⟨0,0,1⟩): F = ⟨x², y², 9⟩, F·n = 9. ∬ 9 dS = 9·π·4 = 36π. Bottom disk (z=0, n=⟨0,0,−1⟩): F = ⟨x², y², 0⟩, F·n = 0. Side (n=⟨x/2, y/2, 0⟩): F·n = (x³ + y³)/2. ∬ (x³+y³)/2 dS. dS = 2 dz dθ (surface area element of cylinder of radius 2). x = 2 cos θ, y = 2 sin θ. (x³+y³)/2 = (8 cos³θ + 8 sin³θ)/2 = 4(cos³θ + sin³θ). ∫₀^{2π} cos³θ dθ = 0, ∫₀^{2π} sin³θ dθ = 0. Side flux = 0.
Total = 36π + 0 + 0 = 36π. ✓ Matches.
### Worked Example 2: Gauss's Law for a Uniformly Charged Sphere
**Problem:** A sphere of radius R has uniform charge density ρ₀. Find the electric field E(r) at all points in space using Gauss's law.
By symmetry, E is radial: E(r) = E(r) r̂, where r = |r|.
For a spherical Gaussian surface of radius r:
Gauss's law: ∬_S E · dS = Q_enclosed / ε₀.
The flux through the Gaussian sphere: E · dS = E(r) r̂ · r̂ dS = E(r) dS. ∬_S E(r) dS = E(r) · 4πr² (since E(r) is constant on the sphere).
Q_enclosed depends on r:
Case 1: r ≥ R (outside the charged sphere): Q_enclosed = ρ₀ · (4/3)πR³ = total charge Q. E(r) · 4πr² = Q/ε₀ E(r) = Q / (4πε₀ r²) = (ρ₀ R³) / (3ε₀ r²).
Outside, the field is exactly as if all charge were at the center (inverse-square law).
Case 2: r < R (inside the charged sphere): Q_enclosed = ρ₀ · (4/3)πr³. E(r) · 4πr² = ρ₀(4/3)πr³ / ε₀ E(r) = ρ₀ r / (3ε₀).
Inside, the field grows linearly with r. At r = R, both formulas give: E(R) = ρ₀ R / (3ε₀) = Q / (4πε₀ R²). ✓ (Continuity at the boundary.)
### Worked Example 3: Divergence Theorem on a Tetrahedron
**Problem:** Verify the divergence theorem for F(x, y, z) = ⟨xy, yz, zx⟩ over the tetrahedron bounded by x = 0, y = 0, z = 0, and x + y + z = 1.
Step 1: Volume integral. div F = y + z + x = x + y + z.
∭_E (x + y + z) dV = 3 · ∭_E x dV (by symmetry).
E: 0 ≤ x ≤ 1, 0 ≤ y ≤ 1−x, 0 ≤ z ≤ 1−x−y.
∭_E x dV = ∫₀¹∫₀^{1−x} x(1−x−y) dy dx = ∫₀¹ x[(1−x)y − y²/2]₀^{1−x} dx = ∫₀¹ x · (1−x)²/2 dx = (1/2)∫₀¹ x(1−2x+x²) dx = (1/2)(1/2 − 2/3 + 1/4) = (1/2)(6/12−8/12+3/12) = 1/24.
Total: 3 · (1/24) = 1/8.
Step 2: Surface integral. S has 4 faces. Check each:
Face S₁ (x = 0): n = ⟨−1, 0, 0⟩. F = ⟨0, yz, 0⟩. F·n = 0. Flux = 0. Face S₂ (y = 0): n = ⟨0, −1, 0⟩. F = ⟨0, 0, zx⟩. F·n = 0. Flux = 0. Face S₃ (z = 0): n = ⟨0, 0, −1⟩. F = ⟨xy, 0, 0⟩. F·n = 0. Flux = 0.
Face S₄ (x + y + z = 1): Parametrize with x, y: r(x, y) = ⟨x, y, 1−x−y⟩, D: x ≥ 0, y ≥ 0, x + y ≤ 1. r_x × r_y = ⟨1, 1, 1⟩. (This is the outward normal — points away from origin. ✓)
F = ⟨xy, y(1−x−y), x(1−x−y)⟩. F · (r_x × r_y) = xy + y(1−x−y) + x(1−x−y) = xy + y − xy − y² + x − x² − xy = x + y − x² − y² − xy.
∬_{S₄} F · dS = ∬_D (x + y − x² − y² − xy) dA.
Compute each term: ∬_D x dA = ∫₀¹ ∫₀^{1−x} x dy dx = ∫₀¹ x(1−x) dx = [x²/2 − x³/3]₀¹ = 1/6. ∬_D y dA = 1/6 (symmetry). ∬_D x² dA = ∫₀¹ x²(1−x) dx = [x³/3 − x⁴/4]₀¹ = 1/12. ∬_D y² dA = 1/12 (symmetry). ∬_D xy dA = (1/2)∫₀¹ x(1−x)² dx = (1/2)(1/2 − 2/3 + 1/4) = 1/24.
Total S₄ flux = 1/6 + 1/6 − 1/12 − 1/12 − 1/24 = (4 + 4 − 2 − 2 − 1)/24 = 3/24 = 1/8.
Total flux = 0 + 0 + 0 + 1/8 = 1/8. ✓ Matches volume integral.
### Worked Example 4: Flux When div F = 0
**Problem:** Compute the outward flux of F(x, y, z) = ⟨y²z³, 2xyz³, 3xy²z²⟩ through the torus (x² + y² + z² + 3)² = 16(x² + y²).
Don't panic! Compute div F:
P = y²z³ → P_x = 0 Q = 2xyz³ → Q_y = 2xz³ R = 3xy²z² → R_z = 6xy²z
div F = 0 + 2xz³ + 6xy²z.
This is not zero, so check if F is a gradient field. Try F = ∇(xy²z³)? ∂/∂x (xy²z³) = y²z³ ✓ ∂/∂y (xy²z³) = 2xyz³ ✓ ∂/∂z (xy²z³) = 3xy²z² ✓
Yes! F = ∇(xy²z³). So F is conservative and curl F = 0.
But we need div F, not curl F: div F = div(∇(xy²z³)) = ∇²(xy²z³) = ∂²/∂x²(xy²z³) + ∂²/∂y²(xy²z³) + ∂²/∂z²(xy²z³) = 0 + 2xz³ + 6xy²z.
This is NOT zero. So the divergence theorem would give a non-zero flux!
Let me pick a better example where div F = 0...
Actually, use F(x, y, z) = ⟨yz, xz, xy⟩. div F = 0 + 0 + 0 = 0. ✓ curl F = ⟨x−x, y−y, z−z⟩ = ⟨0, 0, 0⟩. So this IS conservative (F = ∇(xyz)).
By the divergence theorem: ∬_S F·dS = ∭_E 0 dV = 0.
The flux through the torus (or any closed surface) is exactly 0. No computation needed.
### Worked Example 5: Flux through a Cube with Non-Zero div
**Problem:** Find the outward flux of F(x, y, z) = ⟨x + y, y + z, z + x⟩ through the surface of the cube [−1, 1] × [−1, 1] × [−1, 1].
Step 1: div F = ∂(x+y)/∂x + ∂(y+z)/∂y + ∂(z+x)/∂z = 1 + 1 + 1 = 3.
Step 2: Volume integral. ∬_S F · dS = ∭_E 3 dV = 3 · Volume(cube) = 3 · 8 = 24.
That's it! The divergence theorem reduces what would be 6 separate surface integrals (each with potentially complicated integrands due to the cross-terms) to a trivial computation.
## Quiz
**Q1:** The Divergence Theorem (Gauss) relates a surface integral over a closed surface S to:
A) A line integral around the boundary of S
B) A triple integral over the solid E enclosed by S
C) Another surface integral
D) A double integral in the xy-plane
**Correct: B)**
- If you chose B: ∯_S F · n dS = ∭_E (∇ · F) dV — the flux out of a closed surface equals the integral of divergence over the enclosed volume. Correct!
- If you chose A: That's Stokes' Theorem.
- If you chose C: The theorem relates surface to volume integrals.
- If you chose D: This isn't the Divergence Theorem.
---
**Q2:** The divergence ∇ · F at a point measures:
A) The rotation of the field
B) The net outward flux per unit volume (source/sink strength)
C) The magnitude of the field
D) The direction of the field
**Correct: B)**
- If you chose B: Divergence quantifies how much the field expands (positive divergence = source) or contracts (negative divergence = sink) at a point. Correct!
- If you chose A: That's curl.
- If you chose C: Magnitude is ‖F‖, not divergence.
- If you chose D: Direction is given by F/‖F‖, not divergence.
---
**Q3:** For the Divergence Theorem to apply, the surface S must be:
A) Any surface, open or closed
B) Closed (no boundary), enclosing a solid region E
C) Flat
D) Parametrized by arc length
**Correct: B)**
- If you chose B: The theorem requires a closed surface (like a sphere, not a disk) that bounds a solid. Correct!
- If you chose A: Open surfaces have boundaries — use Stokes' Theorem instead.
- If you chose C: The surface can be curved.
- If you chose D: No arc length parametrization is required.
---
**Q4:** For F = ⟨x, y, z⟩, the divergence ∇ · F equals:
A) 0
B) 1
C) 3
D) x + y + z
**Correct: C)**
- If you chose C: ∇ · ⟨x, y, z⟩ = ∂x/∂x + ∂y/∂y + ∂z/∂z = 1 + 1 + 1 = 3. Every point is a source with uniform strength. Correct!
- If you chose A: The field clearly expands — divergence is nonzero.
- If you chose B: You only added one component.
- If you chose D: That's the function value, not the divergence (which is the sum of derivatives, not the sum of components).
---
**Q5:** Compute the flux of F = ⟨x, y, z⟩ outward through the unit sphere x² + y² + z² = 1.
A) 0
B) 4π
C) 3 · (4π/3) = 4π
D) 3
**Correct: C)**
- If you chose C: div F = 3. ∭_E 3 dV = 3 · Volume(sphere) = 3 · (4π/3) = 4π. (Or directly: on the sphere, F · n = ⟨x,y,z⟩ · ⟨x,y,z⟩ = x²+y²+z² = 1, so flux = ∯_S 1 dS = 4π.) Correct!
- If you chose A: A purely radial field has nonzero flux through a sphere.
- If you chose B: The answer is 4π, but option C has the correct derivation.
- If you chose D: That's the divergence, not the flux.
---
**Q6:** The Divergence Theorem can be viewed as a generalization of:
A) The Fundamental Theorem of Calculus (∫_a^b f′(x) dx = f(b) − f(a))
B) Fubini's Theorem
C) The Mean Value Theorem
D) L'Hôpital's Rule
**Correct: A)**
- If you chose A: All the fundamental theorems share the pattern ∫_{boundary} (derivative) = function value at boundary. FTC (1D), Green's/Stokes (2D), Divergence (3D). Correct!
- If you chose B: Fubini's is about iterated integrals, not boundary-interior relationships.
- If you chose C: MVT is about averages, not flux.
- If you chose D: L'Hôpital's is for limits, unrelated.
---
## Practice Problems
*(Answers are below. Try each problem before checking.)*
**Problem 1:** Use the divergence theorem to evaluate ∬_S F · dS where F(x, y, z) = ⟨x³, y³, z³⟩ and S is the surface of the sphere x² + y² + z² = 1, oriented outward.
**Problem 2:** Compute the outward flux of F(x, y, z) = ⟨x² + y, y² + z, z² + x⟩ through the surface of the unit cube [0, 1] × [0, 1] × [0, 1].
**Problem 3:** Verify the divergence theorem for F(x, y, z) = ⟨x, 2y, 3z⟩ over the solid cylinder x² + y² ≤ 4, 0 ≤ z ≤ 5.
**Problem 4:** Compute the outward flux of F(x, y, z) = ⟨e^x, e^y, e^z⟩ through the surface of the rectangular box [0, 1] × [0, 2] × [0, 3].
**Problem 5:** A vector field F has div F = 5 throughout the region inside the sphere x² + y² + z² = 9. What is the outward flux of F through the sphere? (You don't need to know F itself!)
**Problem 6:** Show that the flux of F(x, y, z) = ⟨y − z, z − x, x − y⟩ through any closed surface is zero.
**Problem 7:** A cube [0, a] × [0, a] × [0, a] sits in a fluid with velocity field v(x, y, z) = ⟨x, 0, 0⟩. Find the net rate of fluid flowing out through all 6 faces using the divergence theorem. Interpret the result physically.
<details>
<summary><strong>Answers (click to expand)</strong></summary>
**Problem 1:**
div F = 3x² + 3y² + 3z² = 3(x² + y² + z²).
∬_S F·dS = ∭_E 3(x² + y² + z²) dV, E: unit sphere.
Spherical coordinates: ρ² = x² + y² + z².
∭ 3ρ² · ρ² sin φ dρ dφ dθ = 3 ∫₀^{2π} dθ ∫₀^π sin φ dφ ∫₀¹ ρ⁴ dρ
= 3 · 2π · 2 · (1/5) = 12π/5.
**Problem 2:**
div F = ∂/∂x(x²+y) + ∂/∂y(y²+z) + ∂/∂z(z²+x) = 2x + 2y + 2z = 2(x+y+z).
∬_S F·dS = ∭_{[0,1]³} 2(x+y+z) dV = 2[∭ x dV + ∭ y dV + ∭ z dV].
By symmetry: ∭ x dV = ∫₀¹ x · 1 · 1 dx = 1/2.
So ∭ x dV = ∭ y dV = ∭ z dV = 1/2.
Total = 2 · 3 · (1/2) = 3.
**Problem 3:**
Volume integral:
div F = 1 + 2 + 3 = 6.
∭_E 6 dV = 6 · Volume(cylinder) = 6 · (π·4·5) = 120π.
Surface integral (verification):
Three surfaces: top disk (z=5, n=⟨0,0,1⟩), bottom disk (z=0, n=⟨0,0,−1⟩), and side.
Top (z=5, n=⟨0,0,1⟩): F = ⟨x, 2y, 15⟩, F·n = 15. ∬ 15 dS = 15·π·4 = 60π.
Bottom (z=0, n=⟨0,0,−1⟩): F = ⟨x, 2y, 0⟩, F·n = 0. Flux = 0.
Side (x²+y²=4, n=⟨x/2, y/2, 0⟩):
F·n = x²/2 + 2y²/2 = (x² + 2y²)/2.
dS = 2 dz dθ. x = 2 cos θ, y = 2 sin θ.
F·n on side = (4 cos²θ + 8 sin²θ)/2 = 2 cos²θ + 4 sin²θ.
∬ side = ∫₀^5 ∫₀^{2π} (2 cos²θ + 4 sin²θ) · 2 dθ dz.
∫₀^{2π} cos²θ dθ = π, ∫₀^{2π} sin²θ dθ = π.
Inner integral = 2(2π + 4π) = 12π.
Outer integral = 5·12π = 60π.
Total flux = 60π + 0 + 60π = 120π. ✓ Matches.
**Problem 4:**
div F = e^x + e^y + e^z.
∬_S F·dS = ∭_{box} (e^x + e^y + e^z) dV.
∭ e^x dV = ∫₀³∫₀²∫₀¹ e^x dx dy dz = (e¹ − e⁰) · 2 · 3 = (e−1)·6.
∭ e^y dV = ∫₀³∫₀²∫₀¹ e^y dy dx dz = (e² − 1) · 1 · 3 = 3(e²−1).
∭ e^z dV = ∫₀³∫₀²∫₀¹ e^z dz dy dx = (e³ − 1) · 1 · 2 = 2(e³−1).
Total = 6(e−1) + 3(e²−1) + 2(e³−1)
= 6e − 6 + 3e² − 3 + 2e³ − 2
= 2e³ + 3e² + 6e − 11.
**Problem 5:**
By the divergence theorem: ∬ F·dS = ∭ div F dV = ∭ 5 dV = 5 · Volume(sphere).
Volume = (4/3)π·27 = 36π.
Flux = 5 · 36π = 180π.
You don't need to know F itself — only its divergence matters!
**Problem 6:**
div F = ∂/∂x(y−z) + ∂/∂y(z−x) + ∂/∂z(x−y) = 0 + 0 + 0 = 0.
By the divergence theorem, for any closed surface S bounding region E:
∬_S F·dS = ∭_E 0 dV = 0.
**Problem 7:**
v = ⟨x, 0, 0⟩. div v = ∂x/∂x + 0 + 0 = 1.
Net outflow = ∬_S v·dS = ∭_E 1 dV = a³ (the volume of the cube).
Physical interpretation: The velocity field pushes fluid in the +x direction and the speed increases with x (like an expanding flow). Since div v = 1 > 0, fluid is being created uniformly throughout the cube at a rate of 1 unit volume per unit time per unit volume, so the total outflow rate from the cube is a³. The x = 0 face has v = ⟨0,0,0⟩ so no inflow; the x = a face has v = ⟨a,0,0⟩ with outward flux a · a² = a³. All other faces have zero flux. Net outflow = a³. ✓
</details>
---
## Summary
1. Gauss's divergence theorem ∬_S F · dS = ∭_E div F dV says the total flux of a vector field out of a closed surface equals the volume integral of divergence inside — it's the 3D analog of the flux form of Green's theorem
2. The theorem converts difficult surface integrals over complex closed surfaces into (usually easier) triple integrals, especially when div F is a simple function; it also works in reverse to compute volume integrals as surface integrals
3. If div F = 0 everywhere, the flux through any closed surface is identically zero (the field is solenoidal/incompressible); this is a powerful shortcut that avoids all integration
4. The divergence theorem is the mathematical bridge between the integral and differential forms of Gauss's law in electromagnetism: the flux of E through a closed surface is proportional to the enclosed charge (∬ E·dS = Q_enclosed/ε₀)
5. The theorem completes the "Trinity" of vector calculus (FTC → Green's → Stokes' → Divergence), all following the pattern: integral of a derivative over a region = integral of the field over the boundary
---
## Pitfalls
1. **Applying the divergence theorem to open surfaces.** The divergence theorem requires a CLOSED surface bounding a solid region. If the surface is open (like a hemisphere without its base disk), you must either close it first or use a different method. Confusing open and closed surfaces is a frequent exam mistake.
2. **Using the inward normal instead of outward.** The standard divergence theorem uses the outward normal. Using the inward normal flips the sign of the result. Always verify that your normal vector points away from the enclosed volume, not into it.
3. **Assuming div F = 0 means flux through any surface is zero.** Zero divergence guarantees zero flux only through CLOSED surfaces. An open surface with the same boundary can have nonzero flux even when div F = 0 everywhere — the flux depends on the boundary, not just local divergence.
4. **Forgetting that the divergence theorem requires F to be C¹ everywhere inside the region.** If F has a singularity inside E (as with the inverse-square field r/|r|³ at the origin), the theorem doesn't apply directly. You must exclude the singularity with a small surface, apply the theorem to the punctured region, and take a limit — the classic technique behind Gauss's law.
5. **Computing div F incorrectly and missing the simplification opportunity.** The whole point of the divergence theorem is that ∭ div F dV is often much simpler than parametrizing a closed surface. But if you compute div F incorrectly, you lose the simplification. Always double-check ∂P/∂x + ∂Q/∂y + ∂R/∂z before setting up the volume integral.
---
---
## Next Steps
Congratulations! You've completed Phase 7 — Calculus IV: Vector Calculus. You now understand the full hierarchy of integral theorems:
Fundamental Theorem of Calculus (1D) → Green's Theorem (2D, plane) → Stokes' Theorem (2D curved surfaces in 3D) → Generalized Stokes' Theorem (n-dimensional manifolds) → Divergence Theorem (3D solid regions) ```
These theorems form the mathematical backbone of electromagnetism, fluid dynamics, and continuum mechanics. In machine learning and LLM research, vector calculus appears in: - Gradient computation through backpropagation (line integrals in weight space) - Information geometry (Manifold operations) - Normalizing flows and continuous normalizing flows (divergence theorem for density transformations) - Physics-informed neural networks (Stokes' and divergence theorems as constraints)
Continue to Phase 8 — Linear Algebra for the foundational mathematics of vectors, matrices, linear transformations, and eigendecompositions — the computational engine behind virtually all modern ML algorithms.