Fields, Seen Through Local Derivatives · Chapter 2
Divergence and curl: what they extract from the Jacobian
The Jacobian fully describes what a vector field does near a point, and divergence and curl extract two parts of it. Divergence is the trace and reads off the local change of volume; curl comes from the antisymmetric part and equals twice the local angular velocity. This chapter derives both, their integral forms and the two zero identities, and uses optical-flow divergence to estimate time to contact.
Series contentsChapter 2 of 3
Series
Fields, Seen Through Local Derivatives- 01The Jacobian and the gradient: the derivative as a local linear map
- 02Divergence and curl: what they extract from the Jacobian
- 03Hessian, Laplacian and Poisson reconstruction
The question
What is a vector field doing near a point? Which part of that does divergence answer, which part does curl answer, and what do both miss?
Textbooks usually state the component formulas for and and add pictures of “sources” and “vortices”. That makes the formulas memorable but hides why they look the way they do. This chapter starts from the Jacobian of Chapter 1 and shows that divergence and curl are both information extracted from it.
Intuition
Think of as the velocity field of a fluid. Place a tiny parcel of fluid at a point and watch it for a short time. What happens to it splits into four kinds of change:
- translation: the whole parcel moves with velocity ;
- uniform expansion or compression: the volume changes, the shape does not;
- rotation: the parcel turns like a rigid body;
- volume-preserving deformation: it stretches in one direction and squeezes in another, keeping its volume.
Translation is set by the value of the field; the other three are set by the Jacobian. Divergence reads the second kind and curl the third. Neither reads the fourth.
The figure shows four typical 2D fields. The first two are pure expansion and pure rotation. The third, a simple shear, contains both rotation and deformation. The fourth is pure deformation: its divergence and curl both vanish, yet it is clearly not a trivial field.
Formalism
Write and use subscripts for partial derivatives, e.g. . The Jacobian is
Divergence is the trace of the Jacobian
Why the trace measures volume change. In time the velocity field carries the point to . Relative to the parcel’s centre, a small offset is mapped to
The volume of a small element scales by the determinant of this linear map. By the Leibniz formula, is a sum over permutations:
- the identity permutation gives the product of the diagonal, ;
- every other permutation contains at least two off-diagonal factors, each carrying a , so it contributes .
Therefore
Divergence is the instantaneous relative rate of change of local volume: positive means expansion, negative means compression, zero means no first-order change in volume. Zero divergence implies neither zero velocity nor an unchanged shape.
Two quantities are easy to confuse here. is the local volume scaling of a map itself; is the rate of volume change caused by a velocity field. The short-time map connects them.
Curl comes from the antisymmetric part of the Jacobian
Each component is the difference of a pair of mirror-image entries of the Jacobian, so curl depends only on the antisymmetric part .
Half the curl is the local angular velocity. Let , with cross-product matrix
Writing out entry by entry,
Compare with : at , ; at , ; at , . They match exactly, so
A rigid body spinning with angular velocity has velocity . Comparing the two, the local rigid rotation of the parcel has angular velocity
A antisymmetric matrix has exactly three independent entries, which is why it can be represented by an axial vector, and why curl is a vector only in three dimensions. In 2D the antisymmetric part has a single entry, and curl is the scalar , a rotation about the axis normal to the plane.
Example. is a rigid rotation about the -axis with angular velocity 2. Its divergence is 0 and its curl is , exactly twice the angular velocity.
The full decomposition of the Jacobian
Split the Jacobian into symmetric and antisymmetric parts, then remove the trace from the symmetric part:
The three parts have degrees of freedom, exactly the nine entries of the Jacobian. Divergence reads only the first part (one number) and curl only the third (three numbers); the five degrees of freedom of volume-preserving deformation in between are invisible to both.
Counterexample. has Jacobian . Its divergence and curl are both zero, yet it stretches along and squeezes along . Divergence and curl at a point cannot recover the Jacobian there.
Simple shear. The field in the figure has Jacobian . Its symmetric part is deformation, and its antisymmetric part is a rotation with angular velocity (clockwise); the 2D curl is . A flow that looks like layers simply sliding past each other contains both rotation and deformation.
Integral forms: flux and circulation
Divergence and curl also have coordinate-free definitions.
Divergence is net outward flux per unit volume. Take a small cube of side centred at . The two faces normal to the -axis contribute a net outward flux
and the other two pairs of faces contribute likewise. Adding the three gives a net outward flux , so
A component of curl is circulation per unit area. For a small surface through with normal ,
with the boundary oriented by the right-hand rule relative to .
Adding these local relations over a whole region, the contributions of neighbouring cells cancel in the interior and only the boundary survives. This gives the two integral theorems:
| Theorem | Formula | Meaning |
|---|---|---|
| Divergence theorem | Total source inside equals net flux through the boundary | |
| Stokes’ theorem | Total local circulation on the surface equals circulation around its edge |
Both require a sufficiently smooth field, a sufficiently regular region and consistent orientation. Chapter 3 uses the divergence theorem to derive the Poisson equation.
The two zero identities
Gradient fields are curl-free: . The first component is , which vanishes because mixed partials commute for twice continuously differentiable ; the other components are the same.
Curl fields are divergence-free: . Expanding,
where the six terms cancel in pairs, again because mixed partials commute.
Both identities need enough smoothness and cannot be applied blindly at singular points.
Does zero curl imply a potential? Only on a simply connected region. Consider, on ,
A direct computation gives , so everywhere. Around the unit circle, however, and the circulation is . If , every closed loop would have zero circulation, so this field has no global potential. The obstruction is the hole at the origin.
Conventions
- is a differential operator, not a numeric vector. The “dot” and “cross” notation is a mnemonic; on products the product rule still applies, e.g. .
- The formulas in this chapter hold in Cartesian coordinates only. In cylindrical and spherical coordinates the basis vectors vary with position and extra scale-factor terms appear; the Cartesian formulas cannot be copied over.
In robotics
Optical-flow divergence and time to contact
When a drone or robot approaches a facing plane along its optical axis, the optical flow in the image radiates outward from one point, the focus of expansion (FOE). The divergence of that flow gives the time to contact (TTC) directly.
Let the camera move forward along its optical axis with speed towards a plane at depth . In the camera frame, scene points have velocity . With normalized image coordinates and , differentiating in time gives
The flow is exactly the “source” field of the figure, with the FOE at the principal point. Its divergence is
Three properties of this result stand out:
- measuring the flow divergence yields the time to contact without knowing the depth or the speed separately;
- in pixel coordinates both the flow and the coordinates are scaled by , so the divergence is unchanged and the focal length is not needed either;
- divergence measures expansion, and the third column of the projection Jacobian in Chapter 1 shows that motion along the optical axis is precisely what moves image points radially.
These properties are why flow divergence is widely used for obstacle avoidance and landing control on micro air vehicles, for example by holding the divergence constant to produce a smooth decelerating descent. The derivation above holds only for pure forward motion towards a facing plane; lateral translation, a slanted plane or rotation add further terms to the divergence, which must be compensated first.
The curl of optical flow corresponds to rotation about the optical axis. If the camera rotates about its optical axis with rate , scene points move in the camera frame with velocity , the image flow is , and its 2D curl is : twice the angular rate, with the sign opposite to the camera’s rotation. This matches the result that half the curl is the angular velocity.
Experiment
The first script computes, on a grid, the divergence and curl of the four fields in the figure and includes the plotting code.
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-1, 1, 41)
y = np.linspace(-1, 1, 41)
X, Y = np.meshgrid(x, y) # shape (ny, nx); X varies along axis=1
fields = {
"source": (X, Y),
"vortex": (-Y, X),
"shear": (Y, 0 * X),
"strain": (X, -Y),
}
def div_curl(P, Q):
dP_dy, dP_dx = np.gradient(P, y, x)
dQ_dy, dQ_dx = np.gradient(Q, y, x)
return dP_dx + dQ_dy, dQ_dx - dP_dy
for name, (P, Q) in fields.items():
d, c = div_curl(P, Q)
print(f"{name:7s} div = {round(d.mean(), 2) + 0.0:+.2f} curl = {round(c.mean(), 2) + 0.0:+.2f}")
# source div = +2.00 curl = +0.00
# vortex div = +0.00 curl = +2.00
# shear div = +0.00 curl = -1.00
# strain div = +0.00 curl = +0.00
fig, axes = plt.subplots(1, 4, figsize=(12, 3.4))
s = slice(None, None, 4)
for ax, (name, (P, Q)) in zip(axes, fields.items()):
ax.quiver(X[s, s], Y[s, s], P[s, s], Q[s, s])
ax.set_title(name)
ax.set_aspect("equal")
plt.show()
The second script synthesizes the flow of a camera approaching a plane, checks that its divergence equals , and checks that rotation about the optical axis gives a curl of .
import numpy as np
W, Z = 2.0, 10.0 # approach at 2 m/s from 10 m: tau = 5 s
f = 400.0 # focal length in pixels
px = np.linspace(-200, 200, 81) # pixel coordinates relative to the principal point
U, V = np.meshgrid(px, px)
xn, yn = U / f, V / f # normalized coordinates
# pure forward motion: pixel flow = f * (W/Z) * (x, y)
flow_u, flow_v = f * xn * W / Z, f * yn * W / Z
div = np.gradient(flow_u, px, axis=1) + np.gradient(flow_v, px, axis=0)
print(div.mean(), 2 * W / Z, "tau =", 2 / div.mean()) # about 0.4 0.4 tau = 5.0 (up to rounding)
# rotation about the optical axis: pixel flow = f * omega * (y, -x)
omega = 0.3
rot_u, rot_v = f * omega * yn, -f * omega * xn
curl = np.gradient(rot_v, px, axis=1) - np.gradient(rot_u, px, axis=0)
print(curl.mean(), -2 * omega) # about -0.6 -0.6
References
- Koenderink, J. J., & van Doorn, A. J. (1976). Local structure of movement parallax of the plane. Journal of the Optical Society of America, 66(7), 717–723.
- Lee, D. N. (1976). A theory of visual control of braking based on information about time-to-collision. Perception, 5(4), 437–459.
- Herissé, B., Hamel, T., Mahony, R., & Russotto, F.-X. (2012). Landing a VTOL unmanned aerial vehicle on a moving platform using optical flow. IEEE Transactions on Robotics, 28(1), 77–89.
- Schey, H. M. (2005). Div, Grad, Curl, and All That (4th ed.). W. W. Norton.
- OpenStax. Calculus Volume 3, Section 6.5: Divergence and Curl. https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl
- 3Blue1Brown. Divergence and curl: The language of Maxwell’s equations, fluid flow, and more. https://www.3blue1brown.com/lessons/divergence-and-curl/
- MIT OpenCourseWare. 18.02SC Multivariable Calculus (Fall 2010), Unit 4: Triple integrals and surface integrals in 3-space (including the divergence theorem and Stokes’ theorem). https://ocw.mit.edu/courses/18-02sc-multivariable-calculus-fall-2010/