What is it?
: the net outflow per unit volume at a point. Positive at sources, negative at sinks, zero for incompressible flow.
Why does it exist?
To express conservation laws locally. "Mass is neither created nor destroyed" becomes ; "water does not compress" becomes ; "electric charge produces electric field" becomes Gauss's law.
Intuition
Draw a tiny box around the point and count what flows out minus what flows in, divided by the box's volume. A tap is a source (positive divergence), a drain a sink (negative). In a river, water entering a region must leave it: divergence zero.
Formal definition
Formulas
- continuity equation (conservation of mass)
- Gauss's law
Example
points straight out from the origin: everywhere — every point is a source. rotates around the -axis: — it swirls but nothing is created.
Why does it matter?
Every incompressible fluid solver in games and films (stable fluids, FLIP) has a "projection" step that removes the divergence of the velocity field by solving a Poisson equation. Electromagnetic simulators and finite-volume CFD codes are organized around fluxes and divergence.
Where it shows up in computing
Incompressibility is enforced each step by a pressure projection.
Two of Maxwell's equations are divergence equations: , .
Where it shows up in AI
Continuous normalizing flows track log-density with the divergence of the velocity field (instantaneous change of variables).
Where is it used?
Computing topics reachable from here, through the chain of ideas that leads to them:
What depends on it
Exercises
Compute for .
Solution
.