Divergence and Curl
Divergence asks how much a point acts as a source, curl asks how much it swirls. One number for outflow, one for rotation, both read off the arrows.
Why Does This Exist?
Arrow patterns need numbers, not adjectives. Saying a field "spreads out" or "swirls" does not distinguish a gentle widening from a fierce source, and ML uses these measurements in real places: probability flows in generative models must conserve mass, which is a divergence statement, and rotational components of updates explain oscillations that never settle, which is a curl statement.
Divergence and curl are the two numbers. Divergence measures net outflow at a point: positive at sources, negative at sinks, zero where flow passes through unchanged. Curl measures rotation at a point: nonzero where arrows loop, zero where they merely bend. This page teaches both readings on two small fields; the arrow-pattern vocabulary comes from gradients and the area integrals behind the big theorems from integration and area.
The one idea you need first
A vector field pins one arrow to every point. Stand at a point and watch the arrows around it: if more flows out of a tiny box than into it, the point is a source. If the arrows around it turn in a loop, the point swirls. Divergence formalizes the first observation, curl the second, and both are limits over shrinking boxes and loops.
Think of It Like This
A fountain and a whirlpool in the same pool
A fountain pushes water outward in every direction: every drop near it moves away, and the outflow per second is its divergence. A whirlpool turns water in circles: drops orbit without leaving, and the spin rate is its curl. A real pool can host both at once, and measuring one tells you nothing about the other.
That independence is the point people miss. A field can spread without swirling, swirl without spreading, do both, or do neither. The radial field below spreads with zero swirl; the rotation field swirls with zero spread. Two dials, not one, and each needs its own reading before you claim to understand a flow.
The analogy stops at friction. Real whirlpools dissipate and fountains run dry, while the mathematical readings are instantaneous and exact, defined at a point with no running costs.
How It Actually Works
For :
In plain words: divergence adds how fast the horizontal arrow grows rightward to how fast the vertical arrow grows upward. If rightward arrows strengthen to the right, flow accumulates outward. Curl subtracts the cross-tilts: how fast the vertical arrow grows rightward minus how fast the horizontal arrow grows upward, which is nonzero exactly when the arrows turn in a loop.
Two theorems give these readings their power, stated without proof. The divergence theorem: total outflow from a region equals the flux through its boundary. Stokes' theorem: total swirl inside a loop equals the circulation around it. Both convert hard interior measurements into easier boundary ones.
Worked example
Take . Then and , so everywhere: every point is a source of strength 5. Its curl is : no swirl, pure spreading, as the left panel draws.
Take the rotation field . Its divergence is : nothing spreads, no sources anywhere. Its curl is : uniform swirl of strength 2, as the right panel draws. Same arrows-as-input, opposite verdicts, which is why both dials exist.
Watch Out For
Concluding no swirl from straight-looking arrows
Curl measures infinitesimal rotation, not visible curvature. The shear field draws as straight horizontal lines, yet its curl is : a paddle wheel dropped in it spins, because faster flow on top turns it. Straight pictures can hide rotation, so compute the cross-tilts instead of eyeballing.
Expecting zero divergence from incompressible-looking flows
A field can look balanced globally while sourcing locally: divergence is a point measurement, and positive and negative regions can cancel in the total. Generative flows exploit exactly this, keeping total mass fixed while pushing it around. Read the dial at the point you care about, not the mood of the whole picture.
The Quick Version
- Divergence adds the two straight-tilts and reports outflow: sources positive, sinks negative, through-flow zero.
- Curl subtracts the cross-tilts and reports rotation: loops nonzero, pure spreading zero.
- The field (2x, 3y) has divergence 5 and no swirl; the rotation field has curl 2 and no source.
- Divergence and Stokes theorems trade interior measurements for easier boundary ones.
- Straight arrows can hide curl and balanced pictures can hide sources, so compute both dials.