Green's Theorem
Green's theorem trades a line integral around a closed curve in the plane for a double integral over the region inside it. It is the first of the three "boundary equals interior" theorems of vector calculus, and the source of practical formulas such as the area of a polygon from its vertices. This lesson states the theorem with its hypotheses, proves it for simple regions, extends it to regions with holes, and checks each claim numerically on fresh examples. The survey version is in Green's, Stokes' and Divergence Theorems.
Statement
A simple closed curve has positive orientation if it is traversed counter-clockwise, so that the enclosed region is always on the left. We write for a line integral around a closed curve.
Green's theorem. Let be a positively oriented, piecewise-smooth, simple closed curve in the plane and the region it bounds. If and have continuous partial derivatives on an open region containing , then
Sometimes the left side is written , where means the positively oriented boundary of .
Why it is true
Call type I if it can be described as , , and type II if it can be described as , (see Double Integrals over General Regions). Suppose is both. Green's theorem follows from two separate identities:
For the first, use type I. By the Fundamental Theorem of Calculus in the inner integral,
Now split into four pieces. The bottom curve (, from to ) contributes . The top curve is traversed from right to left, so it contributes . The vertical sides (possibly of length 0) have and contribute nothing. Adding: . The second identity is the same argument with type II and the roles of and swapped. ∎
For a general region, cut it into pieces that are both types. The line integrals over the cuts appear twice with opposite orientations and cancel, while the double integrals add up.
import numpy as np
import sympy as sp
P = lambda x, y: np.exp(x) - y**2 # F = <e^x − y², xy + sin y>
Q = lambda x, y: x * y + np.sin(y)
def edge(a, b, n=200_000): # ∫ P dx + Q dy along the segment a → b (midpoint rule)
s = (np.arange(n) + 0.5) / n
x, y = a[0] + s * (b[0] - a[0]), a[1] + s * (b[1] - a[1])
return float(np.sum(P(x, y) * (b[0] - a[0]) + Q(x, y) * (b[1] - a[1])) / n)
A, B, C = (0, 0), (1, 0), (0, 1) # counter-clockwise triangle
boundary = edge(A, B) + edge(B, C) + edge(C, A)
x, y = sp.symbols('x y')
curl = sp.diff(x*y + sp.sin(y), x) - sp.diff(sp.exp(x) - y**2, y)
area_side = sp.integrate(curl, (y, 0, 1 - x), (x, 0, 1))
print("Q_x - P_y =", curl)
print("line integral ≈", round(boundary, 6), " double integral =", area_side)Q_x - P_y = 3*y
line integral ≈ 0.5 double integral = 1/2
The and parts drop out completely: has no in it and has no , so they contribute nothing to , and around a closed loop their line integrals vanish. Green's theorem lets you skip computing them.
Regions with holes
Green's theorem also holds for a region with holes, provided the boundary is oriented so that is on the left: counter-clockwise on the outer curve, clockwise on each inner curve. Proof: cut with a few segments into simply connected pieces; the cuts cancel in pairs.
For the annulus and , the curl is , and
import numpy as np
def circle(R, n=200_000, clockwise=False):
t = (np.arange(n) + 0.5) * 2 * np.pi / n
s = -1 if clockwise else 1
x, y = R * np.cos(s * t), R * np.sin(s * t)
dx, dy = -s * R * np.sin(s * t), s * R * np.cos(s * t)
P, Q = -y**3, x**3
return float(np.sum(P * dx + Q * dy) * 2 * np.pi / n)
outer, inner = circle(2), circle(1, clockwise=True)
print("outer (ccw) ≈", round(outer, 6), " inner (cw) ≈", round(inner, 6))
print("sum ≈", round(outer + inner, 6), " 45π/2 =", round(45 * np.pi / 2, 6))outer (ccw) ≈ 75.398224 inner (cw) ≈ -4.712389
sum ≈ 70.685835 45π/2 = 70.685835
The same idea explains the vortex field from the previous lesson: its curl is 0 away from the origin, so on any region between two loops that both wind around the origin, the two loop integrals are equal. That is why every such loop gives .
Area from a line integral
Choosing and with makes the double integral the area of :
This is how a mechanical planimeter measures the area of a shape by tracing its outline, and, applied to straight edges, it gives the shoelace formula for polygons.
import sympy as sp
t = sp.symbols('t')
x, y = sp.cos(t)**3, sp.sin(t)**3 # astroid
area = sp.integrate(sp.Rational(1, 2) * (x * sp.diff(y, t) - y * sp.diff(x, t)), (t, 0, 2 * sp.pi))
print("astroid area =", sp.simplify(area), "≈", round(float(area), 6))
x, y = 2 * sp.cos(t) - sp.cos(2 * t), 2 * sp.sin(t) - sp.sin(2 * t) # cardioid-like curve
area = sp.integrate(sp.Rational(1, 2) * (x * sp.diff(y, t) - y * sp.diff(x, t)), (t, 0, 2 * sp.pi))
print("cardioid area =", sp.simplify(area), "≈", round(float(area), 6))astroid area = 3*pi/8 ≈ 1.178097
cardioid area = 6*pi ≈ 18.849556
In software
- Polygon area and winding order. The shoelace formula, used in GIS, CAD, font rendering and game level editors, is Green's theorem on straight edges. Its sign tells clockwise from counter-clockwise, which decides front faces and the holes of glyphs.
- Image moments. Area, centroid and second moments of a shape (used in computer vision to describe blobs) can be computed from the contour alone with Green's theorem, instead of visiting every pixel.
- Physics. The circulation around an aerofoil () relates to lift; by Green's theorem it equals the total vorticity enclosed, which is how simple aerodynamics codes estimate it.
- Vector graphics. Fill algorithms decide inside/outside with a winding number, the .
Exercises
Exercise 1: A rectangle
Use Green's theorem to evaluate , where is the boundary of the rectangle , positively oriented.
Answer
Solution
Exercise 2: Wrong direction
The same integral is computed with traversed clockwise. What is the result?
Answer
−10.
Solution
Green's theorem needs positive (counter-clockwise) orientation. Reversing the curve flips the sign of a line integral of a vector field, so the result is −10.
Exercise 3: Triangle area by the shoelace formula
Find the area of the triangle with vertices , , using .
Answer
.
Solution
The sum is positive, so the vertices are listed counter-clockwise.
Exercise 4: A disc, both sides (code)
For and the disc of radius 2, compute by hand in polar coordinates, then check with a numerical line integral around the circle.
Answer
.
Solution
import numpy as np
n = 200_000
t = (np.arange(n) + 0.5) * 2 * np.pi / n
x, y, dx, dy = 2 * np.cos(t), 2 * np.sin(t), -2 * np.sin(t), 2 * np.cos(t)
print(round(float(np.sum(-x**2 * y * dx + x * y**2 * dy) * 2 * np.pi / n), 6), round(8 * np.pi, 6))25.132741 25.132741
Test yourself
Green's theorem requires the boundary curve to be traversed…
- clockwise
- in either direction
- counter-clockwise (region on the left)
- twice
Which choice of P and Q turns into the area of the region?
For a region with one hole, how is the inner boundary oriented in Green's theorem?
- Counter-clockwise
- Clockwise, so the region stays on the left
- It is ignored
- Either way