Stokes' Theorem
Stokes' theorem says that the circulation of a vector field around a closed curve in space equals the flux of its curl through any surface that has that curve as its edge. It is Green's theorem with the flat region allowed to bend. This lesson states it precisely, sketches why it is true, verifies it on fields and surfaces of our own, and uses it to give curl a physical meaning.
The statement
Let be an oriented, piecewise-smooth surface whose boundary is a simple closed, piecewise-smooth curve with positive orientation: if you walk along with your head pointing in the direction of the normal , the surface is on your left. Let have continuous partial derivatives on an open region containing . Then
The left side is a line integral; the right side is a flux, computed as in Surface Integrals, with from Curl and Divergence. The gentle version is in Green's, Stokes' and Divergence Theorems.
Note: If lies flat in the -plane with , then and , and Stokes' theorem is exactly Green's theorem.
Why it is true (sketch for a graph)
Take to be a graph over a region with upward normal, and look at one term of , say . Then and, using the graph formula for flux,
On the other side, parametrise as , the lift of the boundary of . The line integral becomes , a plane line integral. Apply Green's theorem to it: the integrand is , which by the chain rule is . The two sides match. The and terms work the same way, and general surfaces are handled by cutting them into graph-shaped pieces whose shared edges cancel.
Surface independence
The right side depends only on the boundary , so every surface with the same oriented edge gives the same flux of . Take , so , and the circle at height , counter-clockwise seen from above. Two surfaces share that edge: the flat disc at , and the cap of the paraboloid above .
import numpy as np
curl = lambda x, y, z: np.array([2 * y, 2 + 0 * x, 3 + 0 * x])
# 1) line integral around the circle of radius 2 at z = 1
n = 4000
t = (np.arange(n) + 0.5) * 2 * np.pi / n
x, y, z = 2 * np.cos(t), 2 * np.sin(t), np.ones(n)
dx, dy, dz = -2 * np.sin(t), 2 * np.cos(t), 0 * t
line = np.sum(2 * z * dx + 3 * x * dy + y**2 * dz) * 2 * np.pi / n
# polar grid on the parameter disc rho <= 2
m = 800
rho = (np.arange(m) + 0.5) * 2 / m
R, T = np.meshgrid(rho, (np.arange(m) + 0.5) * 2 * np.pi / m)
X, Y = R * np.cos(T), R * np.sin(T)
w = R * (2 / m) * (2 * np.pi / m) # polar area element
disc = np.sum(curl(X, Y, 1)[2] * w) # n = k
c = curl(X, Y, 5 - X**2 - Y**2)
cap = np.sum((c[0] * 2 * X + c[1] * 2 * Y + c[2]) * w) # upward <-g_x, -g_y, 1>
print(f"circulation {line:.6f}")
print(f"flux via disc {disc:.6f}")
print(f"flux via cap {cap:.6f}")
print(f"12π {12 * np.pi:.6f}")circulation 37.699112
flux via disc 37.699112
flux via cap 37.699112
12π 37.699112
On the cap, the extra terms integrate to zero over the disc, leaving 3 times the area , the same as the flat disc.
A boundary that is not flat
Stokes' theorem shines when the curve is awkward and a simple surface spans it. Take the same and the curve where the cylinder meets the saddle . Spanning it with the saddle itself over the unit disc :
import sympy as sp
t, r, th = sp.symbols('t r theta', real=True)
x, y = sp.cos(t), sp.sin(t)
z = x * y
F = sp.Matrix([2*z, 3*x, y**2])
dr = sp.Matrix([x, y, z]).diff(t)
line = sp.integrate(sp.expand(F.dot(dr)), (t, 0, 2*sp.pi))
print("circulation along the saddle edge:", line)
X, Y = r*sp.cos(th), r*sp.sin(th)
curl = sp.Matrix([2*Y, 2, 3])
normal = sp.Matrix([-Y, -X, 1]) # <-g_x, -g_y, 1> for g = x y
flux = sp.integrate(sp.expand(curl.dot(normal) * r), (r, 0, 1), (th, 0, 2*sp.pi))
print("flux of curl through the saddle: ", flux)circulation along the saddle edge: 5*pi/2
flux of curl through the saddle: 5*pi/2
What curl measures
Shrink the surface to a tiny disc of radius centred at a point with unit normal . The curl is nearly constant on it, so Stokes gives . Hence
The component of curl along is the circulation per unit area in the plane perpendicular to : put a tiny paddle wheel there with its axle along , and it spins fastest when points along . Check it at , , where :
import numpy as np
F = lambda p: np.array([2 * p[2], 3 * p[0], p[1] ** 2])
P = np.array([1.0, 2.0, 0.0])
nrm = np.array([1.0, 1.0, 1.0]) / np.sqrt(3)
e1 = np.array([1.0, -1.0, 0.0]) / np.sqrt(2) # e1, e2, n: right-handed frame
e2 = np.cross(nrm, e1)
k = 2000
t = (np.arange(k) + 0.5) * 2 * np.pi / k
for eps in (1.0, 0.1, 0.01):
pts = P[:, None] + eps * (np.outer(e1, np.cos(t)) + np.outer(e2, np.sin(t)))
tang = eps * (-np.outer(e1, np.sin(t)) + np.outer(e2, np.cos(t)))
circ = np.sum(F(pts) * tang) * 2 * np.pi / k
print(f"eps = {eps:<5} circulation / area = {circ / (np.pi * eps**2):.6f}")
print("curl F · n =", round(9 / np.sqrt(3), 6))eps = 1.0 circulation / area = 5.196152
eps = 0.1 circulation / area = 5.196152
eps = 0.01 circulation / area = 5.196152
curl F · n = 5.196152
The ratio is exact even for here because this curl is a linear function, whose average over a disc equals its value at the centre. For a curl with curvature the ratio would only converge as .
In software
- Fluid simulation. Vorticity is the paddle-wheel spin of the flow. Vorticity-confinement in game smoke and fire solvers measures on the grid and adds a force that keeps small swirls from being smeared away by numerical diffusion. Discrete curl on a staggered grid is literally circulation around a cell face divided by its area.
- Electromagnetics. Faraday's and Ampère's laws in integral form are Stokes' theorem; FDTD solvers (antenna and chip design) update and fields with exactly these face-circulation formulas.
- Geometry processing. Discrete exterior calculus turns Stokes' theorem into the rule "the boundary of a boundary is empty", which is what makes mesh-based vector-field design and remeshing tools consistent.
- Path-independence checks. In AI steering with potential fields (see The Fundamental Theorem for Line Integrals), a zero curl guarantees an agent cannot gain "energy" by going around a loop.
Exercises
Exercise 1: Pick the easy surface
Use Stokes' theorem to find for around the circle , , counter-clockwise from above.
Answer
.
Solution
Exercise 2: A field with zero curl
Show that for around every closed curve.
Answer
, so every circulation is 0 ().
Solution
By Stokes, the circulation around any curve that bounds a surface is . Directly: , and the line integral of a gradient around a loop is 0.
Exercise 3: Orientation matters
The paraboloid cap in the lesson is given the downward normal instead. What must happen to the direction of , and what is the circulation then?
Answer
must be traversed clockwise (seen from above); the circulation is .
Solution
The positive orientation rule pairs a downward normal with clockwise traversal seen from above. Reversing the normal flips the sign of the flux, and reversing the curve flips the sign of the line integral, so both sides become and the theorem still holds.
Exercise 4: The tilted ellipse (code)
The plane cuts the cylinder in an ellipse (oriented counter-clockwise seen from above). For , compute through the flat elliptical piece of the plane, then check it directly with SymPy.
Answer
Solution
The curl is constant and parallel to the plane, so nothing of it passes through the ellipse. The line integral agrees:
import sympy as sp
t = sp.symbols('t', real=True)
x, y = sp.cos(t), sp.sin(t)
z = 2 + x
F = sp.Matrix([y, z, x])
dr = sp.Matrix([x, y, z]).diff(t)
print("F·dr =", sp.expand(F.dot(dr)))
print("circulation =", sp.integrate(sp.expand(F.dot(dr)), (t, 0, 2*sp.pi)))F·dr = -sin(t)**2 - sin(t)*cos(t) + cos(t)**2 + 2*cos(t)
circulation = 0
Test yourself
Two different surfaces and have the same oriented boundary curve . What can you say about the flux of through them?
- They are equal
- They differ by the area between them
- They have opposite signs
- Nothing in general
Stokes' theorem reduces to Green's theorem when…
- is a gradient field
- is a closed surface
- is a flat region in the -plane with normal
- is a circle
What is the flux of through a closed surface such as a sphere?
- It equals the volume
- It depends on
- 0