TExcelTAD
Home › Calculus in Depth › Green's Theorem

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 CC has positive orientation if it is traversed counter-clockwise, so that the enclosed region DD is always on the left. We write ∮C\oint_C for a line integral around a closed curve.

Green's theorem. Let CC be a positively oriented, piecewise-smooth, simple closed curve in the plane and DD the region it bounds. If PP and QQ have continuous partial derivatives on an open region containing DD, then

∮CP dx+Q dy=∬D(∂Q∂x−∂P∂y)dA\oint_C P\,dx + Q\,dy = \iint_D \left(\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}\right) dA

Sometimes the left side is written ∮∂D\oint_{\partial D}, where ∂D\partial D means the positively oriented boundary of DD.

Why it is true

Call DD type I if it can be described as a≤x≤ba \le x \le b, g1(x)≤y≤g2(x)g_1(x) \le y \le g_2(x), and type II if it can be described as c≤y≤dc \le y \le d, h1(y)≤x≤h2(y)h_1(y) \le x \le h_2(y) (see Double Integrals over General Regions). Suppose DD is both. Green's theorem follows from two separate identities:

∮CP dx=−∬D∂P∂y dAand∮CQ dy=∬D∂Q∂x dA\oint_C P\,dx = -\iint_D \frac{\partial P}{\partial y}\,dA \qquad\text{and}\qquad \oint_C Q\,dy = \iint_D \frac{\partial Q}{\partial x}\,dA

For the first, use type I. By the Fundamental Theorem of Calculus in the inner integral,

∬D∂P∂y dA=∫ab[P(x,g2(x))−P(x,g1(x))] dx\iint_D \frac{\partial P}{\partial y}\,dA = \int_a^b [P(x, g_2(x)) - P(x, g_1(x))]\,dx

Now split CC into four pieces. The bottom curve C1C_1 (y=g1(x)y = g_1(x), xx from aa to bb) contributes ∫abP(x,g1(x)) dx\int_a^b P(x, g_1(x))\,dx. The top curve C3C_3 is traversed from right to left, so it contributes −∫abP(x,g2(x)) dx-\int_a^b P(x, g_2(x))\,dx. The vertical sides (possibly of length 0) have dx=0dx = 0 and contribute nothing. Adding: ∮CP dx=−∬DPy dA\oint_C P\,dx = -\iint_D P_y\,dA. The second identity is the same argument with type II and the roles of xx and yy 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.

python · try it yourself
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 exe^x and sin⁡y\sin y parts drop out completely: exe^x has no yy in it and sin⁡y\sin y has no xx, so they contribute nothing to Qx−PyQ_x - P_y, 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 DD with holes, provided the boundary ∂D\partial D is oriented so that DD is on the left: counter-clockwise on the outer curve, clockwise on each inner curve. Proof: cut DD with a few segments into simply connected pieces; the cuts cancel in pairs.

For the annulus 1≤r≤21 \le r \le 2 and F=⟨−y3,x3⟩\mathbf{F} = \langle -y^3, x^3 \rangle, the curl is Qx−Py=3x2+3y2=3r2Q_x - P_y = 3x^2 + 3y^2 = 3r^2, and

∬D3r2 dA=∫02π∫123r2⋅r dr dθ=2π⋅3⋅16−14=45π2\iint_D 3r^2\,dA = \int_0^{2\pi} \int_1^2 3r^2 \cdot r\,dr\,d\theta = 2\pi \cdot 3 \cdot \frac{16 - 1}{4} = \frac{45\pi}{2}
python · try it yourself
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 ⟨−y,x⟩/(x2+y2)\langle -y, x \rangle/(x^2 + y^2) 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 2π2\pi.

Area from a line integral

Choosing PP and QQ with Qx−Py=1Q_x - P_y = 1 makes the double integral the area of DD:

A=∮Cx dy=−∮Cy dx=12∮C(x dy−y dx)A = \oint_C x\,dy = -\oint_C y\,dx = \frac{1}{2} \oint_C (x\,dy - y\,dx)

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.

python · try it yourself
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 (∮v⋅dr\oint \mathbf{v} \cdot d\mathbf{r}) 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 vortex loop integral÷2π\text{vortex loop integral} \div 2\pi.

Exercises

Exercise 1: A rectangle

Use Green's theorem to evaluate ∮C(x2−2y) dx+(3x+y2) dy\oint_C (x^2 - 2y)\,dx + (3x + y^2)\,dy, where CC is the boundary of the rectangle [0,2]×[0,1][0, 2] \times [0, 1], positively oriented.

Answer
Solution
Qx−Py=3−(−2)=5∬D5 dA=5⋅area=5⋅2=10\begin{aligned} Q_x - P_y &= 3 - (-2) = 5 \\ \iint_D 5\,dA &= 5 \cdot \text{area} = 5 \cdot 2 = 10 \end{aligned}

Exercise 2: Wrong direction

The same integral is computed with CC 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 (1,1)(1, 1), (4,2)(4, 2), (2,5)(2, 5) using A=12∑(xiyi+1−xi+1yi)A = \frac{1}{2} \sum (x_i y_{i+1} - x_{i+1} y_i).

Answer

112=5.5\frac{11}{2} = 5.5.

Solution
(1⋅2−4⋅1)+(4⋅5−2⋅2)+(2⋅1−1⋅5)=−2+16−3=11A=112\begin{aligned} (1 \cdot 2 - 4 \cdot 1) + (4 \cdot 5 - 2 \cdot 2) + (2 \cdot 1 - 1 \cdot 5) &= -2 + 16 - 3 = 11 \\ A &= \frac{11}{2} \end{aligned}

The sum is positive, so the vertices are listed counter-clockwise.

Exercise 4: A disc, both sides (code)

For F=⟨−x2y,xy2⟩\mathbf{F} = \langle -x^2y, xy^2 \rangle and the disc of radius 2, compute ∬D(Qx−Py) dA\iint_D (Q_x - P_y)\,dA by hand in polar coordinates, then check with a numerical line integral around the circle.

Answer

8π≈25.1327418\pi \approx 25.132741.

Solution
Qx−Py=y2−(−x2)=x2+y2=r2∬Dr2 dA=∫02π∫02r3 dr dθ=2π⋅164=8π\begin{aligned} Q_x - P_y &= y^2 - (-x^2) = x^2 + y^2 = r^2 \\ \iint_D r^2\,dA &= \int_0^{2\pi} \int_0^2 r^3\,dr\,d\theta = 2\pi \cdot \frac{16}{4} = 8\pi \end{aligned}
python · try it yourself
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…

  1. clockwise
  2. in either direction
  3. counter-clockwise (region on the left)
  4. twice

Which choice of P and Q turns ∮P dx+Q dy\oint P\,dx + Q\,dy into the area of the region?

  1. P=0, Q=xP = 0,\ Q = x
  2. P=x, Q=yP = x,\ Q = y
  3. P=y, Q=xP = y,\ Q = x
  4. P=x, Q=0P = x,\ Q = 0

For a region with one hole, how is the inner boundary oriented in Green's theorem?

  1. Counter-clockwise
  2. Clockwise, so the region stays on the left
  3. It is ignored
  4. Either way