27. Divergence and curl

📖 Reading · 11 min
💡 Every code box below is live — edit it and hit Run.

Green's theorem's integrand, Q_x-P_y, measured a two-dimensional field's local rotation. This lesson promotes that quantity to full three-dimensional status as curl, and introduces its sibling divergence — the two local measurements that Stokes' theorem and the divergence theorem, closing out this module, will each generalize Green's theorem around.

The del operator

Define the symbol \nabla (already used for the gradient, §10.5) as a vector of partial-derivative operators:

\nabla=\left\langle\frac\partial{\partial x},\frac\partial{\partial y},\frac\partial{\partial z}\right\rangle

Applied to a scalar function, \nabla f recovers §10.5's gradient. Applied to a vector field via §9.1's dot product or §9.2's cross product, \nabla produces two entirely new quantities — genuinely reusing both vector products from Module 9, one operation each.

Divergence

\text{div}\,\vec F=\nabla\cdot\vec F=\frac{\partial P}{\partial x}+\frac{\partial Q}{\partial y}+\frac{\partial R}{\partial z}

for \vec F=\langle P,Q,R\rangle — the dot product of \nabla with \vec F, exactly §9.1's formula, with each component multiplication replaced by a partial derivative.

Physical meaning: divergence measures the net outward flux per unit volume at a point — how much a fluid is expanding (spreading outward, divergence >0, a "source") or compressing (converging inward, divergence <0, a "sink") right there. A field with divergence identically 0 everywhere is called incompressible — fluid flowing through any small region has exactly as much leaving as entering, no net accumulation or depletion anywhere.

Curl

\text{curl}\,\vec F=\nabla\times\vec F=\left\langle\frac{\partial R}{\partial y}-\frac{\partial Q}{\partial z},\ \frac{\partial P}{\partial z}-\frac{\partial R}{\partial x},\ \frac{\partial Q}{\partial x}-\frac{\partial P}{\partial y}\right\rangle

— the cross product of \nabla with \vec F, computed using §9.2's determinant formula with \vec i,\vec j,\vec k in the first row and \partial/\partial x,\partial/\partial y,\partial/\partial z in the second.

The third component is exactly §12.4's Green's theorem integrand, Q_x-P_y — for a field confined to the xy-plane (R=0, P,Q independent of z), the curl reduces to \langle0,0,Q_x-P_y\rangle, a vector pointing purely in the z-direction whose magnitude is exactly the scalar curl from §12.4. Curl in three dimensions is the direct generalization of Green's rotational integrand, now pointing in the axis a rotation happens around, using the right-hand rule from §9.2.

Physical meaning: curl measures local rotational tendency — imagine a tiny paddlewheel dropped into a fluid flow at a point; curl points along the paddlewheel's axis of spin, and its magnitude measures how fast the paddlewheel would spin. A field with curl identically \vec0 everywhere is called irrotational.

The conservative-field test, generalized to three dimensions

§12.3's test, P_y=Q_x, is exactly the statement that the third component of curl vanishes. In full three dimensions:

\vec F\text{ is conservative (on a simply connected domain)}\iff\text{curl}\,\vec F=\vec0

"Conservative" and "irrotational" are the same property, restated — a gradient field can never have any local rotational tendency at all, because moving around any tiny closed loop within it returns to the exact same potential value, which is precisely what zero circulation (§12.3) means at every scale.

A structural identity worth knowing

\text{div}(\text{curl}\,\vec F)=0\qquad\text{always}

— the divergence of any curl is identically zero, regardless of what \vec F is. This isn't a coincidence about specific fields; it follows from Clairaut's theorem (§10.2) applied to every mixed partial that appears when the two operators are composed — each term in the expanded sum cancels against another term with the opposite sign, purely from f_{xy}=f_{yx}. This identity becomes structurally important in §12.9's divergence theorem, where it guarantees a curl field can never have any net flux through a closed surface.

Doing it in Python

Computing divergence and curl for \vec F(x,y,z)=\langle x^2y,y^2z,z^2x\rangle, and confirming the div-of-curl identity:

import sympy as sp

x, y, z = sp.symbols('x y z')
P, Q, R = x**2*y, y**2*z, z**2*x

div_F = sp.diff(P, x) + sp.diff(Q, y) + sp.diff(R, z)
print(f"div F = {div_F}")

curl_F = sp.Matrix([
    sp.diff(R, y) - sp.diff(Q, z),
    sp.diff(P, z) - sp.diff(R, x),
    sp.diff(Q, x) - sp.diff(P, y)
])
print(f"curl F = {curl_F.T}")

div_of_curl = sp.diff(curl_F[0], x) + sp.diff(curl_F[1], y) + sp.diff(curl_F[2], z)
print(f"div(curl F) = {sp.simplify(div_of_curl)}")

Confirming the 3D curl of a purely planar rotational field reduces to exactly Green's theorem's scalar curl, in the z-component:

import sympy as sp

x, y, z = sp.symbols('x y z')
P, Q, R = -y, x, 0   # the section 12.0 rotational field, embedded in 3D with R=0

curl_F = sp.Matrix([
    sp.diff(R, y) - sp.diff(Q, z),
    sp.diff(P, z) - sp.diff(R, x),
    sp.diff(Q, x) - sp.diff(P, y)
])
print(f"curl of <-y,x,0> = {curl_F.T}")
print("z-component matches Green's theorem's Q_x - P_y = 1-(-1) = 2, from section 12.4")

Testing whether a 3D field is conservative via curl, then verifying with §12.3's potential-function method:

import sympy as sp

x, y, z = sp.symbols('x y z')
P, Q, R = 2*x, 2*y, 2*z   # candidate: gradient of x^2+y^2+z^2

curl_F = sp.Matrix([
    sp.diff(R, y) - sp.diff(Q, z),
    sp.diff(P, z) - sp.diff(R, x),
    sp.diff(Q, x) - sp.diff(P, y)
])
print(f"curl F = {curl_F.T}")
print(f"conservative: {curl_F == sp.zeros(3, 1)}")

Worked example

Compute the divergence and curl of $\vec F(x,y,z)=\langle x^2y,y^2z,z^2x\rangle$, and confirm \text{div}(\text{curl}\,\vec F)=0.

\text{div}\,\vec F=\frac\partial{\partial x}(x^2y)+\frac\partial{\partial y}(y^2z)+\frac\partial{\partial z}(z^2x)=2xy+2yz+2zx

\text{curl}\,\vec F=\left\langle\frac\partial{\partial y}(z^2x)-\frac\partial{\partial z}(y^2z),\ \frac\partial{\partial z}(x^2y)-\frac\partial{\partial x}(z^2x),\ \frac\partial{\partial x}(y^2z)-\frac\partial{\partial y}(x^2y)\right\rangle

=\langle0-y^2,\ 0-z^2,\ 0-x^2\rangle=\boxed{\langle-y^2,-z^2,-x^2\rangle}

Checking \text{div}(\text{curl}\,\vec F)=0:

\frac\partial{\partial x}(-y^2)+\frac\partial{\partial y}(-z^2)+\frac\partial{\partial z}(-x^2)=0+0+0=\boxed0

Sanity check. The div-of-curl identity holds automatically here, without needing any special property of this particular \vec F — exactly as the concept section claimed, since each of the three terms in this final sum is trivially zero (differentiating -y^2 with respect to x, -z^2 with respect to y, -x^2 with respect to z — none of these expressions even contain the variable being differentiated against), confirming the identity's structural, not coincidental, nature. ✓

Your turn

1. Compute the divergence of \vec F(x,y,z)=\langle x,y,z\rangle (the outward-radial field), and interpret the sign.

2. Compute the curl of \vec F(x,y,z)=\langle yz,xz,xy\rangle, and determine whether this field is conservative.

3. True or false: an incompressible field (divergence zero everywhere) must also be irrotational (curl zero everywhere).

Solutions

1. \text{div}\,\vec F=1+1+1=\boxed3 — a positive constant, consistent with \langle x,y,z\rangle pointing directly away from the origin everywhere: any small region has more flow leaving through its outer boundary than entering, exactly the "source" behavior a positive divergence signals.

2. R_y-Q_z=x-x=0. P_z-R_x=y-y=0. Q_x-P_y=z-z=0.

\text{curl}\,\vec F=\langle0,0,0\rangle=\vec0

\boxed{\text{conservative (irrotational)}}

(Its potential function is f(x,y,z)=xyz: check $\nabla(xyz)=\langle yz,xz,xy\rangle$ — matches exactly.)

3. False. Divergence and curl measure entirely independent properties of a field — one tracks net outward flow, the other tracks local rotation — and neither implies the other. The rotational field \langle-y,x,0\rangle from earlier in this lesson has curl \langle0,0,2\rangle\ne\vec0 (not irrotational), yet \text{div}\langle-y,x,0\rangle=0+0+0=0 — perfectly incompressible while still rotating everywhere. A field can independently be compressible or not, and rotational or not, in any of the four combinations.

Check yourself in code

Compute the divergence and curl of $\vec F(x,y,z)=\langle x^2y,y^2z,z^2x\rangle$, and confirm \text{div}(\text{curl}\,\vec F)=0.

Print exactly this:

div F = 2*x*y + 2*x*z + 2*y*z
curl F = [-y**2, -z**2, -x**2]
div(curl F) = 0
import sympy as sp

x, y, z = sp.symbols('x y z')
P, Q, R = x**2*y, y**2*z, z**2*x

div_F = sp.diff(P, x) + sp.diff(Q, y) + sp.diff(R, z)
print("div F = ...")

curl_F = sp.Matrix([
    sp.diff(R, y) - sp.diff(Q, z),
    sp.diff(P, z) - sp.diff(R, x),
    sp.diff(Q, x) - sp.diff(P, y)
])
print("curl F = ...")

div_of_curl = sp.diff(curl_F[0], x) + sp.diff(curl_F[1], y) + sp.diff(curl_F[2], z)
print("div(curl F) = ...")
import sympy as sp

x, y, z = sp.symbols('x y z')
P, Q, R = x**2*y, y**2*z, z**2*x

div_F = sp.diff(P, x) + sp.diff(Q, y) + sp.diff(R, z)
print(f"div F = {div_F}")

curl_F = sp.Matrix([
    sp.diff(R, y) - sp.diff(Q, z),
    sp.diff(P, z) - sp.diff(R, x),
    sp.diff(Q, x) - sp.diff(P, y)
])
print(f"curl F = {list(curl_F)}")

div_of_curl = sp.diff(curl_F[0], x) + sp.diff(curl_F[1], y) + sp.diff(curl_F[2], z)
print(f"div(curl F) = {sp.simplify(div_of_curl)}")

Divergence, \nabla\cdot\vec F, and curl, \nabla\times\vec F, reuse §9.1's dot product and §9.2's cross product with \nabla's partial-derivative components — divergence measuring net outward flux (source or sink behavior), curl measuring local rotation, generalizing §12.4's Green's-theorem integrand into a full three-dimensional vector. Curl zero everywhere is exactly the three-dimensional restatement of §12.3's conservative-field test, and the structural identity \text{div}(\text{curl}\,\vec F)=0 — a direct consequence of Clairaut's theorem — will underpin the divergence theorem two lessons from now.

Next: extending curves to two-dimensional surfaces living in three-dimensional space, and measuring their area — the surface counterpart of §9.5's arc length.