Foundations to Frontier
Tests
A. Mathematical Foundations › A3 Calculus and Analysis › Vector calculus

Green's, Stokes' and the Divergence Theorems

Three theorems with one idea: adding up a derivative over a region equals adding up the function over its boundary. Green's theorem does it in the plane, Stokes' for curved surfaces, and Gauss's divergence theorem for volumes. They give conservation laws, Gauss's and Ampère's laws, the finite-volume method, polygon areas and centroids, and the winding number.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Counting at the door

How many people are inside a stadium? You could count every seat. Or you could stand at the gates and count everyone who goes in minus everyone who comes out. Both give the same answer, because people don’t appear or vanish inside.

That’s the idea behind the three big theorems of vector calculus. What happens inside a region can be read off its boundary.

  • Divergence theorem: the total “spreading out” inside equals the total flow out through the boundary.
  • Green’s and Stokes’ theorems: the total “spin” inside equals the total circulation around the edge.
Green's theorem: the boundary knows what's inside
field:
region: form:
boundary: ∮ F·dr = -1.5955
inside: ∬ (Qₓ − P_y) dA = -1.5955
difference: 1.1e-10 (numerical error only)
Orange = positive curl, blue = negative. Boundary arrows show F. Try (x, y) in circulation form: zero curl, so zero circulation for every region. In flux form, it's 2 × area.
Why engineers care

Rocket engines, weather models and re-entry simulations all divide space into small cells and track what crosses each cell’s walls. Because whatever leaves one cell enters its neighbour, mass and energy are conserved exactly. That’s the divergence theorem, built into the code.

📝 Quick check (Level 0)
0/3 answered
  1. 1. 1000 enter a stadium and 300 leave. The change inside is…
  2. 2. A loop's circulation equals the total ___ inside.
  3. 3. No sources inside a closed box means the net outflow is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

The three theorems

Theorem Statement Dimension
Green (circulation) ∮∂DP dx+Q dy=∬D(Qx−Py) dA\oint_{\partial D}P\,dx + Q\,dy = \iint_D(Q_x - P_y)\,dA plane region
Green (flux) ∮∂DF⋅n ds=∬D∇⋅F dA\oint_{\partial D}\mathbf F\cdot\mathbf n\,ds = \iint_D\nabla\cdot\mathbf F\,dA plane region
Stokes ∮∂SF⋅dr=∬S(∇×F)⋅n dS\oint_{\partial S}\mathbf F\cdot d\mathbf r = \iint_S(\nabla\times\mathbf F)\cdot\mathbf n\,dS surface in 3-D
Divergence (Gauss) ∯∂VF⋅n dS=∭V∇⋅F dV\oiint_{\partial V}\mathbf F\cdot\mathbf n\,dS = \iiint_V\nabla\cdot\mathbf F\,dV solid in 3-D

The boundary is oriented counter-clockwise for Green (region on your left), with the right-hand rule for Stokes and outward normals for Gauss.

Example (area from the boundary). Take F=(−y/2,x/2)\mathbf F = (-y/2, x/2), so Qx−Py=1Q_x - P_y = 1. Then Area(D)=12∮(x dy−y dx)\text{Area}(D) = \tfrac12\oint(x\,dy - y\,dx). For a polygon this becomes the shoelace formula A=12∑i(xiyi+1−xi+1yi)A = \tfrac12\sum_i(x_iy_{i+1} - x_{i+1}y_i).

Example (flux). F=(x,y)\mathbf F = (x,y) has ∇⋅F=2\nabla\cdot\mathbf F = 2, so the flux out of any region is twice its area. For the unit disk that’s 2π2\pi.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Shoelace area of (0,0), (4,0), (4,3), (0,3)?
  2. 2. ∮(−y, x)·dr around a region of area 5?
  3. 3. Gauss's theorem relates a volume integral of div F to…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

Why they’re true: interior edges cancel

Chop the region into tiny squares. For one tiny square, the circulation around it is approximately (Qx−Py)×(Q_x - P_y)\times its area. That’s the definition of curl as circulation per area (A3.4-1). Now add the circulations of all the squares. Each interior edge is traversed once in each direction by its two neighbours, so those contributions cancel. Only the outer boundary is left. The divergence theorem works the same way, with fluxes through shared faces cancelling.

The pattern behind all of them (and the 1-D fundamental theorem) is the generalized Stokes theorem ∫Ωdω=∫∂Ωω\int_\Omega d\omega = \int_{\partial\Omega}\omega: integrate a derivative over a region, or the function over its boundary.

Using them

  • Compute the easier side. A messy boundary integral of a simple-curl field becomes an area, and vice versa.
  • Surface independence (Stokes). Every surface with the same boundary curve has the same curl flux, so swap a hemisphere for a flat disk.
  • Regions with holes. The boundary includes the inner curves, oriented clockwise. This is how the vortex gets circulation 2π2\pi with zero curl in the annulus: the hole carries it.
  • Conservation laws. For a density ρ\rho with flux J\mathbf J, the rate of change of mass in VV is ddt∭Vρ=−∯∂VJ⋅n\frac{d}{dt}\iiint_V\rho = -\oiint_{\partial V}\mathbf J\cdot\mathbf n. Applying the divergence theorem for every VV gives the continuity equation ρt+∇⋅J=0\rho_t + \nabla\cdot\mathbf J = 0.
🐍 Exercise 1: verify Green's theorem and derive the shoelace formula
On an ellipse, compute ∮F·dr and ∬(Qₓ − P_y) dA numerically for a non-trivial field and compare them with the exact value. Check the flux form too. Then implement the shoelace area from Green's theorem.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Why do interior edges cancel?
  2. 2. Flux of curl F through a hemisphere vs the flat disk with the same rim:
  3. 3. The continuity equation ρₜ + ∇·J = 0 comes from…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Proof of Green’s theorem (for simple regions)

Suppose D={a≤x≤b, g1(x)≤y≤g2(x)}D = \{a\le x\le b,\ g_1(x)\le y\le g_2(x)\}. Then

−∬DPy dA=−∫ab[P(x,g2(x))−P(x,g1(x))]dx=∮∂DP dx-\iint_DP_y\,dA = -\int_a^b\big[P(x,g_2(x)) - P(x,g_1(x))\big]dx = \oint_{\partial D}P\,dx

The bottom curve runs left to right (+P(x,g1)+P(x,g_1)), the top curve right to left (−P(x,g2)-P(x,g_2)), and the vertical sides contribute nothing to ∫P dx\int P\,dx. Symmetrically, with DD written as xx-simple, ∬Qx dA=∮Q dy\iint Q_x\,dA = \oint Q\,dy. Adding the two gives Green. General regions are finite unions of simple ones, glued along cancelling edges. ∎

The flux form is Green’s theorem applied to (−Q,P)(-Q, P), because F⋅n ds=P dy−Q dx\mathbf F\cdot\mathbf n\,ds = P\,dy - Q\,dx. Stokes’ theorem follows by mapping a parameter-domain Green’s theorem onto the surface with the chain rule. Gauss’s theorem is proved like Green’s, one coordinate at a time.

Gauss’s law and the point source

E=x/∣x∣3\mathbf E = \mathbf x/|\mathbf x|^3 has ∇⋅E=0\nabla\cdot\mathbf E = 0 for x≠0\mathbf x\ne0. Apply the divergence theorem to the region between any closed surface SS enclosing 0 and a tiny sphere: the flux through SS equals the flux through the tiny sphere, which is 4π4\pi. In distribution language, ∇⋅E=4πδ\nabla\cdot\mathbf E = 4\pi\delta. That’s Gauss’s law ∯E⋅n dS=Q/ε0\oiint\mathbf E\cdot\mathbf n\,dS = Q/\varepsilon_0, and Newtonian gravity’s analogue.

The winding number

For a closed curve avoiding p\mathbf p, w=12π∮−(y−py) dx+(x−px) dy∣x−p∣2w = \frac1{2\pi}\oint\frac{-(y-p_y)\,dx + (x-p_x)\,dy}{|\mathbf x - \mathbf p|^2} is an integer: how many times the curve wraps around p\mathbf p. By Green on the region minus a small disk, it’s 1 for a counter-clockwise simple loop enclosing p\mathbf p and 0 if p\mathbf p is outside. This gives a robust point-in-polygon test (Practice Code 5), and it’s the start of complex analysis (residues) and topology (degree theory).

Exercise 3.1: Use the divergence theorem to find the flux of (x, y, z) out of a sphere of radius R

∇⋅F=3\nabla\cdot\mathbf F = 3, so the flux is 3⋅43πR3=4πR33\cdot\tfrac43\pi R^3 = 4\pi R^3. Directly: F⋅n=R\mathbf F\cdot\mathbf n = R on the sphere, times area 4πR24\pi R^2. ✓

📝 Quick check (Level 3)
0/3 answered
  1. 1. Green's flux form is Green's circulation form applied to…
  2. 2. Flux of x/|x|³ through any closed surface around 0:
  3. 3. Winding number of a counter-clockwise square around an inside point:

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

The finite-volume method

Integrate a conservation law qt+∇⋅J(q)=0q_t + \nabla\cdot\mathbf J(q) = 0 over each grid cell CiC_i, and use the divergence theorem:

ddtqˉi=−1∣Ci∣∑faces f∫fJ⋅n dS\frac{d}{dt}\bar q_i = -\frac{1}{|C_i|}\sum_{\text{faces } f}\int_f\mathbf J\cdot\mathbf n\,dS

The unknowns are cell averages, and the update is “flux in minus flux out”. The flux leaving cell ii through a face is exactly the flux entering its neighbour, so the total is conserved to round-off, whatever the accuracy of the flux approximation. This is why finite volumes dominate computational fluid dynamics: aircraft and rocket aerodynamics, combustion chambers, atmospheric and ocean models (LeVeque, 2002). With shocks, non-conservative schemes even converge to the wrong shock speed (Lax and Wendroff, 1960).

🐍 Exercise 2 (research): conservative vs non-conservative transport
Advect a tracer in a discretely divergence-free swirl on a staggered grid. The finite-volume (flux-form) update conserves mass to round-off; the advective form drifts by percent.

More applications

  • Robotics geometry:
    • The area, centroid and second moments of a polygon (a robot footprint, a support polygon, a link cross-section) come from boundary sums via Green (Practice Code 5).
    • Static stability of a walking robot requires the centre-of-mass projection inside the support polygon (McGhee and Frank, 1968), a winding-number test.
  • Electromagnetism and sensing:
    • Maxwell’s equations in integral form are the theorems applied to E\mathbf E and B\mathbf B.
    • Faraday’s law ∮E⋅dr=−ddt∬B⋅n\oint\mathbf E\cdot d\mathbf r = -\frac{d}{dt}\iint\mathbf B\cdot\mathbf n (Stokes) is how magnetometers, inductive sensors and electric motors work.
  • Aerodynamics: Kutta–Joukowski’s lift theorem L′=ρVΓL' = \rho V\Gamma ties lift per unit span to the circulation Γ=∮u⋅dr\Gamma = \oint\mathbf u\cdot d\mathbf r around an airfoil.
  • Physics-informed and geometric learning:
    • Conservation constraints in neural PDE solvers, flux-conservative neural operators, and divergence-free architectures use these theorems (A3.4-4).
    • Discrete exterior calculus makes Stokes’ theorem hold exactly on meshes, by definition (Desbrun et al., 2005).
  • Boundary methods: the divergence theorem turns volume integrals into surface integrals. That is the basis of boundary element methods (antenna and acoustics design) and of exact asteroid gravity fields from polyhedral shape models (Werner and Scheeres, 1997).

References

  1. J. E. Marsden, A. Tromba (2011). Vector Calculus, 6th ed. Freeman.
  2. M. Spivak (1965). Calculus on Manifolds. Benjamin. (Generalized Stokes theorem.)
  3. R. J. LeVeque (2002). Finite Volume Methods for Hyperbolic Problems. Cambridge.
  4. P. Lax, B. Wendroff (1960). “Systems of conservation laws.” Communications on Pure and Applied Mathematics, 13.
  5. R. A. Werner, D. J. Scheeres (1997). “Exterior gravitation of a polyhedron derived and compared with harmonic and mascon gravitation representations of asteroid 4769 Castalia.” Celestial Mechanics and Dynamical Astronomy, 65.
  6. R. McGhee, A. Frank (1968). “On the stability properties of quadruped creeping gaits.” Mathematical Biosciences, 3.
  7. M. Desbrun, A. Hirani, M. Leok, J. Marsden (2005). “Discrete exterior calculus.” arXiv:math/0508341.
  8. J. D. Anderson (2017). Fundamentals of Aerodynamics, 6th ed. McGraw-Hill. (Kutta–Joukowski.)