Gradient, divergence, curl. The mathematics of fluid flow, electromagnetism, and heat transfer.
A weather map shows wind speed and direction at every point. An ocean current carries water in different directions at different depths. The electric field around a charge pushes test charges in radial directions with varying strength.
All of these are vector fields: assignments of a vector to every point in space. Scalar fields (like temperature) assign just a number. Vector calculus gives us the tools to analyze both.
The symbol ∇ ("del" or "nabla") is the vector differential operator:
Applied different ways, it gives gradient, divergence, and curl. Think of ∇ as a Swiss army knife for fields.
Given a scalar field f(x, y, z) (like temperature), its gradient is the vector of partial derivatives:
The gradient points in the direction of steepest ascent of f. Its magnitude ||∇f|| is the rate of change in that direction. If you are standing on a mountain and want to go uphill as fast as possible, follow the gradient.
The directional derivative of f in the direction of a unit vector u is:
This is the dot product of the gradient with the direction. Maximum when u points along ∇f. Zero when u is tangent to a level curve. Negative when u points downhill.
Contour lines of f(x,y) shown in teal. Gradient vectors (orange arrows) point perpendicular to contours, uphill. Choose a scalar field.
Given a vector field F = (F1, F2, F3), its divergence is the scalar:
The divergence measures the net outward flux per unit volume at each point. Think of it as measuring whether the field is a source (positive divergence, fluid spreading out) or a sink (negative divergence, fluid being sucked in).
Example: F = (x, y, 0). Then div F = 1 + 1 + 0 = 2. This is a uniform source everywhere — the field radiates outward uniformly.
Example: F = (−y, x, 0). Then div F = 0 + 0 + 0 = 0. This is pure rotation — no sources, no sinks. The field just swirls.
Vector field shown as arrows. Background color: orange = positive divergence (source), teal = negative (sink), dark = zero. Choose a field.
The curl of a vector field measures its local rotation:
The curl is a vector: its direction is the axis of rotation (right-hand rule), and its magnitude is twice the angular speed of rotation.
Example: F = (−y, x, 0). Curl F = (0, 0, 1 − (−1)) = (0, 0, 2). The field rotates counterclockwise around the z-axis.
Example: F = (x, y, 0). Curl F = (0, 0, 0). A radial outflow has no rotation.
A field with curl = 0 everywhere is called irrotational (or conservative). A field with div = 0 is called solenoidal (or incompressible). Maxwell's equations are built on these concepts.
A line integral computes the cumulative effect of a field along a curve. For a vector field F along a curve C parameterized by r(t):
This is the work done by force F along path C. At each point, we take the component of F along the curve direction and accumulate.
Test for conservative: In 2D, F = (P, Q) is conservative if and only if ∂P/∂y = ∂Q/∂x (equivalently, curl F = 0 in a simply connected domain). If so, the potential f satisfies ∂f/∂x = P and ∂f/∂y = Q.
A vector field (arrows) and a path (orange curve). The line integral sums F·dr along the path. For conservative fields, different paths give the same answer. Click to change path shape.
Green's theorem connects a line integral around a closed curve to a double integral over the enclosed region:
The left side is a circulation integral around the boundary C. The right side sums up the "curl" (∂Q/∂x − ∂P/∂y) over the interior D.
Special case — area formula: With P = −y/2 and Q = x/2, we get ∂Q/∂x − ∂P/∂y = 1, so:
This lets you compute the area of any region from its boundary parameterization. Surveyors use this formula (the shoelace formula for polygons is a discrete version).
Just as line integrals integrate along curves, surface integrals integrate over surfaces in 3D. For a scalar function f over surface S:
For a vector field F, the flux integral measures how much of F passes through S:
where n is the unit outward normal to the surface. The flux is the net rate at which the field passes through the surface.
The cross product ru × rv of the partial derivatives of the parameterization gives a normal vector to the surface. Its magnitude ||ru × rv|| is the area element that accounts for how the surface stretches.
These are the crown jewels of vector calculus. They generalize Green's theorem to 3D.
The circulation of F around the boundary curve C equals the flux of curl F through any surface S bounded by C. Circulation around the edge = total rotation in the interior.
The total flux through a closed surface S equals the total divergence inside the volume V. What flows out through the boundary = what is produced inside.
| Theorem | Dimension | Boundary ↔ Interior |
|---|---|---|
| Fund. Thm of Calculus | 1D | ∫f'dx = f(b) − f(a) |
| Green's Theorem | 2D | ∮ (P dx + Q dy) = &iint; (∂Q/∂x − ∂P/∂y) dA |
| Stokes' Theorem | 3D (surface) | ∮ F·dr = &iint; (curl F)·dS |
| Divergence Theorem | 3D (volume) | &oiint; F·dS = ∭ div F dV |
Explore 2D vector fields interactively. See gradient, divergence, and curl computed in real time. Drop particles and watch them trace streamlines.
Arrows show the field. Background heatmap shows divergence (orange = source, teal = sink). Click to drop particles that follow the flow. Watch how they concentrate (convergence) or spread (divergence).
| This lesson | Where it leads |
|---|---|
| Gradient | Optimization (gradient descent in ML), potential theory |
| Divergence | Continuity equation (fluid dynamics), Gauss's law (E&M) |
| Curl | Faraday's law, Ampère's law, vorticity in fluids |
| Line integrals | Work, circulation, conservative forces, potential energy |
| Green's theorem | Complex analysis (Cauchy's theorem is Green's in disguise, Ch 7) |
| Stokes & Gauss | Maxwell's equations, general relativity, differential forms |
"The divergence theorem is the most important theorem in physics." — Richard Feynman