---
title: Green's theorem
heading: Circulation around a loop from what's inside it
eyebrow: A9 · Lesson 27 · Green's theorem
xp: 40
---

::: hook
A PCB design file stores a copper pad as a list of corner points, and the fabrication software needs its area. It doesn't fill the shape with tiny squares: it walks around the outline once and adds up a simple product at each step, the "shoelace formula". That works because of **Green's theorem**, which trades an integral around a closed curve for an integral over the area inside it. It's the flat version of the two big theorems of vector calculus, and the first time you'll see why "what happens inside" and "what happens on the boundary" must agree.
:::

::: play
- The field is $\mathbf{F} = (-ay, bx)$, whose curl $\frac{\partial F_y}{\partial x} - \frac{\partial F_x}{\partial y} = a + b$ is the same everywhere.
- The ellipse is the loop. The first readout is the circulation, computed by walking around it; the second is the curl times the area inside.
- Change the ellipse and the field. Do the two numbers ever disagree?
:::
:::

```sim plot
view: flow
x: x = -2.5..2.5
y: y = -2..2
slider: a = 0..2 step 0.1 = 1
slider: b = -1..2 step 0.1 = 0.5
slider: A = 0.5..2 step 0.1 = 1.5
slider: B = 0.5..1.8 step 0.1 = 1
dx: -a*y
dy: b*x
arrows: scaled
grid: 12
path: A*cos(2*pi*u), B*sin(2*pi*u) | over: u = 0..1 | work: W | color: ch2
readout: circulation around the loop = W
readout: curl × area inside = (a + b)*pi*A*B
```

::: predict
## A field has curl 3 everywhere. What is its circulation around a counterclockwise loop enclosing an area of 2?

- [ ] 3
- [ ] 1.5
- [x] 6
- [ ] 0

::: reveal
6. Green's theorem adds up the curl over the enclosed area: $3 \times 2$. The shape of the loop doesn't matter, only the area inside it, because the curl is the same everywhere. Going around clockwise would give $-6$.
:::
:::

::: nameit
## Green's theorem

For a closed curve $C$ traversed counterclockwise around a region $R$, with $\mathbf{F} = (P, Q)$ smooth throughout $R$:

$$\oint_C P\,dx + Q\,dy = \iint_R\left(\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}\right)dA$$

The left side is the **circulation**; the integrand on the right is the 2D **curl**. Tiny loops inside $R$ cancel along their shared edges, leaving only the outer boundary, which is why the two sides agree.

## The flux form

Rotate the field by 90° and the same theorem says the **flux** out through $C$ equals the integral of the **divergence**:

$$\oint_C\mathbf{F}\cdot\hat{\mathbf{n}}\,ds = \iint_R\left(\frac{\partial P}{\partial x} + \frac{\partial Q}{\partial y}\right)dA$$

These are the 2D versions of Stokes's theorem and the divergence theorem (lesson 37).

## Area from the boundary

Choose $P = -\frac{y}{2}$, $Q = \frac{x}{2}$, whose curl is 1. Then

$$\text{Area} = \frac{1}{2}\oint_C(x\,dy - y\,dx)$$

For a polygon with corners $(x_1, y_1), \ldots, (x_n, y_n)$ in order, this becomes the **shoelace formula**:

$$\text{Area} = \frac{1}{2}\left|\sum_i(x_iy_{i+1} - x_{i+1}y_i)\right|$$

with the last corner joined back to the first.
:::

::: example
## Evaluate $\oint(-y\,dx + x\,dy)$ counterclockwise around the unit square $[0, 1]^2$.

::: solution
1. **Curl of the field.** Here $P = -y$ and $Q = x$:
   $$\begin{aligned} \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} &= 1 - (-1) \\ &= 2 \end{aligned}$$
2. **Apply Green's theorem.** The circulation is $2 \times \text{area} = 2$.
3. **Check by walking the sides.** The four sides give
   $$0 + 1 + 1 + 0 = 2$$
   as well.

**Answer:** the circulation is 2.
:::
:::

::: example
## Find the area of the triangle with corners $(0, 0)$, $(4, 0)$, $(1, 3)$ by the shoelace formula.

::: solution
1. **Apply the shoelace formula.**
   $$\begin{aligned} A &= \tfrac{1}{2}|(0 \cdot 0 - 4 \cdot 0) \\ &\qquad + (4 \cdot 3 - 1 \cdot 0) \\ &\qquad + (1 \cdot 0 - 0 \cdot 3)| \\ &= \tfrac{1}{2} \times 12 \\ &= 6 \end{aligned}$$
2. **Check.** Base 4 times height 3 over 2 agrees.

**Answer:** the triangle's area is 6.
:::
:::

::: example
## Use Green's theorem to find the area of the ellipse $\frac{x^2}{9} + \frac{y^2}{4} = 1$.

::: solution
1. **Area as a line integral.**
   $$A = \frac12\oint(x\,dy - y\,dx)$$
2. **Parametrize.** With $x = 3\cos t$, $y = 2\sin t$:
   $$\begin{aligned} A &= \frac12\int_0^{2\pi}(3\cos t \cdot 2\cos t \\ &\qquad + 2\sin t \cdot 3\sin t)\,dt \\ &= \frac12\int_0^{2\pi}6\,dt \\ &= 6\pi \\ &= 18.85 \end{aligned}$$
3. **Generalize.** In general it's $\pi ab$. Planimeters, the mechanical instruments that measure areas on maps by tracing their outlines, work on this principle.

**Answer:** the ellipse's area is $6\pi = 18.85$.
:::
:::

::: check
given: a = 1 | 2; b = 0.5 | 3; R = 1 | 3
answer: (a + b)*pi*R^2
tolerance: 0.5%

## What is $\oint\mathbf{F}\cdot d\mathbf{l}$ for $\mathbf{F} = (-\given{a}y, \given{b}x)$ counterclockwise around the circle of radius {R}?

::: right
Right. The curl is $a + b$ everywhere, times the area $\pi R^2$: {answer}.
:::

::: misses
- [(b - a)*pi*R^2] $\frac{\partial P}{\partial y} = -a$, so subtracting it adds $a$.
- [(a + b)*2*pi*R] Multiply the curl by the enclosed area, not the length.
- [any] Not yet. Curl times area.
:::
:::

::: check
given: p = 3 | 6; q = 1 | 2; r = 2 | 5
answer: p*r/2

## What is the area of the triangle with corners $(0, 0)$, $(\given{p}, 0)$, $(\given{q}, \given{r})$, by the shoelace formula?

::: right
Right. $\frac{1}{2}|p \cdot r - q \cdot 0| = \frac{pr}{2}$ = {answer}.
:::

::: misses
- [p*r] Include the $\frac{1}{2}$.
- [any] Not yet. $\frac{1}{2}|\sum(x_iy_{i+1} - x_{i+1}y_i)|$.
:::
:::

::: check
given: a = 1 | 2; b = 2 | 3
answer: a^2*b/2
tolerance: 0.5%

## Use Green's theorem: what is $\oint(xy\,dx + x^2\,dy)$ counterclockwise around the rectangle $[0, \given{a}] \times [0, \given{b}]$?

::: right
Right. $Q_x - P_y = 2x - x = x$, and $\iint x\,dA = \frac{a^2b}{2}$ = {answer}.
:::

::: misses
- [a^2*b] $P_y = x$ cancels half of $Q_x = 2x$.
- [any] Not yet. Compute $Q_x - P_y$ and integrate over the rectangle.
:::
:::

::: check
given: a = 1 | 3; b = 2 | -0.5; R = 1 | 2
answer: (a + b)*pi*R^2
tolerance: 0.5%

## What is the flux of $\mathbf{F} = (\given{a}x, \given{b}y)$ out of the circle of radius {R}?

::: right
Right. The divergence is $a + b$ everywhere, times the area: {answer}.
:::

::: misses
- [(a - b)*pi*R^2] Flux uses the divergence, $P_x + Q_y$.
- [any] Not yet. The flux form: $\iint(P_x + Q_y)\,dA$.
:::
:::

::: check
given: c = 2 | 5; A = 3 | 4
answer: -c*A

## A field has curl {c} everywhere. What is its circulation **clockwise** around a loop enclosing area {A}?

::: right
Right. Clockwise reverses the sign: {answer}.
:::

::: misses
- [c*A] That's counterclockwise.
- [any] Not yet. Curl times area, with the orientation's sign.
:::
:::

::: check
kind: choice

## When does Green's theorem fail for $\mathbf{F} = \left(\frac{-y}{x^2 + y^2}, \frac{x}{x^2 + y^2}\right)$ and the unit circle?

- [x] Always: the field blows up at the origin, inside the circle
- [ ] Never: the curl is zero, and so is the circulation
- [ ] Only if the circle is traversed clockwise
- [ ] Only for circles of radius greater than 1

::: right
Right. The theorem needs $\mathbf{F}$ smooth throughout the region. The curl is zero away from the origin, yet the circulation is $2\pi$: everything is concentrated at the hole, where the wire is.
:::

::: misses
- [2] The circulation is $2\pi$, not zero.
- [any] Check the theorem's conditions inside the circle.
:::
:::

::: check
kind: parts
given: a = 2 | 3 | 5; b = 1 | 4

## Use $\frac12\oint(x\,dy - y\,dx)$.

::: part
answer: pi*a*b
tolerance: 0.5%

### What is the area of the ellipse with semi-axes {a} and {b}?

::: misses
- [any] With $x = a\cos t$, $y = b\sin t$ the integrand is $\frac{ab}{2}$.
:::
:::

::: part
answer: a*b/2
tolerance: 0.5%

### What is the area of the triangle $(0, 0)$, $(\given{a}, 0)$, $(0, \given{b})$?

::: misses
- [any] Only the edge from $(a, 0)$ to $(0, b)$ contributes.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.5..3, b = 0.5..3

## Check Green's theorem for $\mathbf{F} = (-y, x)$ on the rectangle $[0, a] \times [0, b]$.

::: step
answer: 2

### What is $\frac{\partial F_2}{\partial x} - \frac{\partial F_1}{\partial y}$?
:::

::: step
answer: 2*a*b

### What is the circulation around the rectangle?
:::

::: right
Right. Twice the area, matching $\oint(-y\,dx + x\,dy)$ computed edge by edge.
:::
:::

::: explain
## Explain why the circulation around a big loop equals the sum of the circulations around many small loops inside it.

::: model
Divide the region into small cells and go around each one counterclockwise. Wherever two cells share an edge, one of them traverses it in one direction and its neighbor in the other, so those contributions cancel. The only edges that don't cancel are those on the outer boundary, which are traversed just once, in the same direction as the big loop. So the sum of the small circulations is the big circulation. Each small circulation is about the curl times the cell's area, which in the limit makes the sum the integral of the curl.
:::
:::

::: practice

::: check
given: x2 = 3 | 5; y3 = 2 | 4
answer: x2*y3

## What is the area of the rectangle with corners $(0, 0)$, $(\given{x2}, 0)$, $(\given{x2}, \given{y3})$, $(0, \given{y3})$, by the shoelace formula?

::: misses
- [x2*y3/2] That's half the rectangle. The sum already gives twice the area, and the $\frac{1}{2}$ corrects it.
- [any] $\frac{1}{2}|\sum(x_iy_{i+1} - x_{i+1}y_i)|$.
:::
:::

::: check
given: c = 2 | 4; R = 1 | 3
answer: c*pi*R^2
tolerance: 0.5%

## A field has curl {c} everywhere. What is its counterclockwise circulation around the circle of radius {R}?

::: misses
- [any] Curl times area.
:::
:::

::: check
given: a = 2 | 5; b = 1 | 3
answer: pi*a*b
tolerance: 0.5%

## Use $\text{Area} = \frac{1}{2}\oint(x\,dy - y\,dx)$ to find the area of the ellipse $x = \given{a}\cos t$, $y = \given{b}\sin t$.

::: misses
- [2*pi*a*b] Include the $\frac{1}{2}$.
- [any] $x\,dy - y\,dx = ab\,dt$.
:::
:::
:::
