TExcelTAD
Home › Calculus in Depth › Stokes' Theorem

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 SS be an oriented, piecewise-smooth surface whose boundary is a simple closed, piecewise-smooth curve CC with positive orientation: if you walk along CC with your head pointing in the direction of the normal n\mathbf{n}, the surface is on your left. Let F\mathbf{F} have continuous partial derivatives on an open region containing SS. Then

∮CF⋅dr=∬S(curl⁡F)⋅dS\oint_C \mathbf{F} \cdot d\mathbf{r} = \iint_S (\operatorname{curl} \mathbf{F}) \cdot d\mathbf{S}

The left side is a line integral; the right side is a flux, computed as in Surface Integrals, with curl⁡F=∇×F\operatorname{curl} \mathbf{F} = \nabla \times \mathbf{F} from Curl and Divergence. The gentle version is in Green's, Stokes' and Divergence Theorems.

Note: If SS lies flat in the xyxy-plane with n=k\mathbf{n} = \mathbf{k}, then (curl⁡F)⋅k=Qx−Py(\operatorname{curl} \mathbf{F}) \cdot \mathbf{k} = Q_x - P_y and dS=dAdS = dA, and Stokes' theorem is exactly Green's theorem.

Why it is true (sketch for a graph)

Take SS to be a graph z=g(x,y)z = g(x, y) over a region DD with upward normal, and look at one term of F\mathbf{F}, say F=⟨P,0,0⟩\mathbf{F} = \langle P, 0, 0 \rangle. Then curl⁡F=⟨0,Pz,−Py⟩\operatorname{curl} \mathbf{F} = \langle 0, P_z, -P_y \rangle and, using the graph formula for flux,

∬Scurl⁡F⋅dS=∬D(−Pz⋅gy−Py) dA(P evaluated at (x,y,g(x,y)))\iint_S \operatorname{curl} \mathbf{F} \cdot d\mathbf{S} = \iint_D (-P_z \cdot g_y - P_y)\,dA \qquad (P \text{ evaluated at } (x, y, g(x, y)))

On the other side, parametrise CC as (x(t),y(t),g(x(t),y(t)))(x(t), y(t), g(x(t), y(t))), the lift of the boundary C1C_1 of DD. The line integral becomes ∮C1P(x,y,g(x,y)) dx\oint_{C_1} P(x, y, g(x, y))\,dx, a plane line integral. Apply Green's theorem to it: the integrand is −∂∂y[P(x,y,g(x,y))]-\frac{\partial}{\partial y}[P(x, y, g(x, y))], which by the chain rule is −(Py+Pz⋅gy)-(P_y + P_z \cdot g_y). The two sides match. The QQ and RR 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 CC, so every surface with the same oriented edge gives the same flux of curl⁡F\operatorname{curl} \mathbf{F}. Take F=⟨2z,3x,y2⟩\mathbf{F} = \langle 2z, 3x, y^2 \rangle, so curl⁡F=⟨2y,2,3⟩\operatorname{curl} \mathbf{F} = \langle 2y, 2, 3 \rangle, and CC the circle x2+y2=4x^2 + y^2 = 4 at height z=1z = 1, counter-clockwise seen from above. Two surfaces share that edge: the flat disc at z=1z = 1, and the cap of the paraboloid z=5−x2−y2z = 5 - x^2 - y^2 above z=1z = 1.

python · try it yourself
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 4xy+4y4xy + 4y integrate to zero over the disc, leaving 3 times the area 4π4\pi, 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 F\mathbf{F} and the curve where the cylinder x2+y2=1x^2 + y^2 = 1 meets the saddle z=xyz = xy. Spanning it with the saddle itself over the unit disc DD:

python · try it yourself
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 ε\varepsilon centred at a point PP with unit normal n\mathbf{n}. The curl is nearly constant on it, so Stokes gives ∮F⋅dr≈(curl⁡F)(P)⋅n⋅πε2\oint \mathbf{F} \cdot d\mathbf{r} \approx (\operatorname{curl} \mathbf{F})(P) \cdot \mathbf{n} \cdot \pi\varepsilon^2. Hence

(curl⁡F)(P)⋅n=lim⁡ε→01πε2∮CεF⋅dr(\operatorname{curl} \mathbf{F})(P) \cdot \mathbf{n} = \lim_{\varepsilon \to 0} \frac{1}{\pi\varepsilon^2} \oint_{C_\varepsilon} \mathbf{F} \cdot d\mathbf{r}

The component of curl along n\mathbf{n} is the circulation per unit area in the plane perpendicular to n\mathbf{n}: put a tiny paddle wheel there with its axle along n\mathbf{n}, and it spins fastest when n\mathbf{n} points along curl⁡F\operatorname{curl} \mathbf{F}. Check it at P=(1,2,0)P = (1, 2, 0), n=⟨1,1,1⟩/3\mathbf{n} = \langle 1, 1, 1 \rangle/\sqrt{3}, where curl⁡F⋅n=(4+2+3)/3≈5.196152\operatorname{curl} \mathbf{F} \cdot \mathbf{n} = (4 + 2 + 3)/\sqrt{3} \approx 5.196152:

python · try it yourself
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 ε=1\varepsilon = 1 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 ε→0\varepsilon \to 0.

In software

  • Fluid simulation. Vorticity ω=curl⁡v\omega = \operatorname{curl} \mathbf{v} is the paddle-wheel spin of the flow. Vorticity-confinement in game smoke and fire solvers measures ω\omega 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 E\mathbf{E} and H\mathbf{H} 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 ∮CF⋅dr\oint_C \mathbf{F} \cdot d\mathbf{r} for F=⟨−y,x,z3⟩\mathbf{F} = \langle -y, x, z^3 \rangle around the circle x2+y2=9x^2 + y^2 = 9, z=4z = 4, counter-clockwise from above.

Answer

18π18\pi.

Solution
curl⁡F=⟨Ry−Qz,Pz−Rx,Qx−Py⟩=⟨0−0,0−0,1−(−1)⟩=⟨0,0,2⟩take S=flat disc of radius 3 at z=4, n=k∬Scurl⁡F⋅n dS=2⋅π⋅32=18π\begin{aligned} \operatorname{curl} \mathbf{F} &= \langle R_y - Q_z, P_z - R_x, Q_x - P_y \rangle = \langle 0 - 0, 0 - 0, 1 - (-1) \rangle = \langle 0, 0, 2 \rangle \\ &\text{take } S = \text{flat disc of radius 3 at } z = 4,\ \mathbf{n} = \mathbf{k} \\ \iint_S \operatorname{curl} \mathbf{F} \cdot \mathbf{n}\,dS &= 2 \cdot \pi \cdot 3^2 = 18\pi \end{aligned}

Exercise 2: A field with zero curl

Show that ∮CF⋅dr=0\oint_C \mathbf{F} \cdot d\mathbf{r} = 0 for F=⟨yz,xz,xy⟩\mathbf{F} = \langle yz, xz, xy \rangle around every closed curve.

Answer

curl⁡F=0\operatorname{curl} \mathbf{F} = \mathbf{0}, so every circulation is 0 (F=∇(xyz)\mathbf{F} = \nabla(xyz)).

Solution
curl⁡F=⟨∂(xy)∂y−∂(xz)∂z,∂(yz)∂z−∂(xy)∂x,∂(xz)∂x−∂(yz)∂y⟩=⟨x−x,y−y,z−z⟩=0\begin{aligned} \operatorname{curl} \mathbf{F} &= \left\langle \frac{\partial(xy)}{\partial y} - \frac{\partial(xz)}{\partial z}, \frac{\partial(yz)}{\partial z} - \frac{\partial(xy)}{\partial x}, \frac{\partial(xz)}{\partial x} - \frac{\partial(yz)}{\partial y} \right\rangle \\ &= \langle x - x, y - y, z - z \rangle = \mathbf{0} \end{aligned}

By Stokes, the circulation around any curve that bounds a surface is ∬0⋅dS=0\iint \mathbf{0} \cdot d\mathbf{S} = 0. Directly: F=∇(xyz)\mathbf{F} = \nabla(xyz), 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 CC, and what is the circulation then?

Answer

CC must be traversed clockwise (seen from above); the circulation is −12π-12\pi.

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 −12π-12\pi and the theorem still holds.

Exercise 4: The tilted ellipse (code)

The plane z=2+xz = 2 + x cuts the cylinder x2+y2=1x^2 + y^2 = 1 in an ellipse CC (oriented counter-clockwise seen from above). For F=⟨y,z,x⟩\mathbf{F} = \langle y, z, x \rangle, compute ∮F⋅dr\oint \mathbf{F} \cdot d\mathbf{r} through the flat elliptical piece of the plane, then check it directly with SymPy.

Answer
Solution
curl⁡F=⟨Ry−Qz,Pz−Rx,Qx−Py⟩=⟨0−1,0−1,0−1⟩=⟨−1,−1,−1⟩plane z=g(x,y)=2+x: upward normal ⟨−gx,−gy,1⟩=⟨−1,0,1⟩curl⁡F⋅⟨−1,0,1⟩=1+0−1=0flux=∬D0 dA=0\begin{aligned} \operatorname{curl} \mathbf{F} &= \langle R_y - Q_z, P_z - R_x, Q_x - P_y \rangle = \langle 0 - 1, 0 - 1, 0 - 1 \rangle = \langle -1, -1, -1 \rangle \\ &\text{plane } z = g(x, y) = 2 + x\text{: upward normal } \langle -g_x, -g_y, 1 \rangle = \langle -1, 0, 1 \rangle \\ \operatorname{curl} \mathbf{F} \cdot \langle -1, 0, 1 \rangle &= 1 + 0 - 1 = 0 \\ \text{flux} &= \iint_D 0\,dA = 0 \end{aligned}

The curl is constant and parallel to the plane, so nothing of it passes through the ellipse. The line integral agrees:

python · try it yourself
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 S1S_1 and S2S_2 have the same oriented boundary curve CC. What can you say about the flux of curl⁡F\operatorname{curl} \mathbf{F} through them?

  1. They are equal
  2. They differ by the area between them
  3. They have opposite signs
  4. Nothing in general

Stokes' theorem reduces to Green's theorem when…

  1. F\mathbf{F} is a gradient field
  2. SS is a closed surface
  3. SS is a flat region in the xyxy-plane with normal k\mathbf{k}
  4. CC is a circle

What is the flux of curl⁡F\operatorname{curl} \mathbf{F} through a closed surface such as a sphere?

  1. 4π4\pi
  2. It equals the volume
  3. It depends on F\mathbf{F}
  4. 0