Tutorials › Calculus III › The Shoelace Formula from Green’s Theorem

Green’s Theorem in the Plane · Tutorial 815 of 999

The Shoelace Formula from Green’s Theorem

Derive the shoelace sum from Green’s theorem, then use it to calculate and verify the area of counterclockwise polygons.

Advanced 10 min read

What You'll Learn

  • Derive the shoelace formula from the boundary integral for area.
  • Set up ordered polygon vertices using cyclic indexing.
  • Compute signed area by summing products of consecutive coordinates.
  • Check a shoelace calculation with geometric area or a decomposition.
  • Recognize how reversing vertex order changes the sign.

From a Boundary Integral to a Coordinate Formula

A polygon’s area can be found from its boundary rather than by splitting it into familiar shapes. Green’s theorem explains why: for a positively oriented, simple closed boundary, area is a line integral around that boundary. When the boundary consists of straight edges, each edge contributes a simple expression in its endpoint coordinates. Adding those contributions produces the shoelace formula.

The formula is useful when the vertices are known but a convenient geometric decomposition is not. Its order of coordinates matters: the vertices must be listed consecutively around the boundary, and the sign of the result records the direction in which that boundary is traversed.

Polygon Coordinates and Orientation

Let a polygon have \(n\) vertices listed in boundary order: \((x_1,y_1), (x_2,y_2), \ldots, (x_n,y_n)\). The final edge runs from the last vertex back to the first. To write every edge in the same way, use the cyclic convention \(x_{n+1}=x_1\) and \(y_{n+1}=y_1\). Thus edge \(i\) runs from \((x_i,y_i)\) to \((x_{i+1},y_{i+1})\).

For this formula, the polygon is assumed to be simple: its boundary does not cross itself. Traversing the boundary counterclockwise gives its positive orientation. We also assume the vertices are listed in that order, without repeating the first vertex at the end of the list. Consecutive vertices may lie on a straight line; that does not change the area.

Definition: For an ordered list of polygon vertices, the signed shoelace sum is \[ \frac{1}{2}\sum_{i=1}^{n}\left(x_i y_{i+1}-x_{i+1}y_i\right), \] where \(x_{n+1}=x_1\) and \(y_{n+1}=y_1\). For a simple polygon listed counterclockwise, this sum equals its area and is positive.

The formula is sometimes displayed as two sums: multiply each vertex’s \(x\)-coordinate by the next vertex’s \(y\)-coordinate, add those products, and subtract the sum formed by multiplying each next \(x\)-coordinate by the current \(y\)-coordinate. The final-to-first pair is included in both sums. For a counterclockwise polygon, half the difference is the area.

Deriving the Shoelace Formula

For a positively oriented, simple planar region \(D\) with boundary \(C\), the boundary formula for area is \(\operatorname{Area}(D)=\frac12\oint_C(x\,dy-y\,dx)\). It follows from Green’s theorem by taking \(P=-y/2\) and \(Q=x/2\): then \(\partial Q/\partial x-\partial P/\partial y=1\), so the area integral over \(D\) equals this boundary integral. A polygon has a piecewise-smooth boundary made of straight edges, so we can evaluate the integral edge by edge.

1
Parametrize one edge.
For the edge from vertex \(i\) to vertex \(i+1\), set \(x(t)=x_i+t(x_{i+1}-x_i)\) and \(y(t)=y_i+t(y_{i+1}-y_i)\), with \(0\le t\le1\).
2
Evaluate its boundary contribution.
Substitute \(dx=(x_{i+1}-x_i)\,dt\) and \(dy=(y_{i+1}-y_i)\,dt\) into \(x\,dy-y\,dx\). The terms that contain \(t\) cancel, leaving a constant.
3
Add the edge contributions.
Sum over all \(n\) edges, including the closing edge from vertex \(n\) to vertex \(1\), and multiply by one half.

Here is the cancellation on a single edge in full. Write \(\Delta x=x_{i+1}-x_i\) and \(\Delta y=y_{i+1}-y_i\). Then

$$ \begin{aligned} x(t)\frac{dy}{dt}-y(t)\frac{dx}{dt} &=(x_i+t\Delta x)\Delta y-(y_i+t\Delta y)\Delta x\\ &=x_i\Delta y-y_i\Delta x\\ &=x_i(y_{i+1}-y_i)-y_i(x_{i+1}-x_i)\\ &=x_i y_{i+1}-x_{i+1}y_i. \end{aligned} $$

Since this expression is constant in \(t\), its integral from \(0\) to \(1\) is the same expression. Summing it over the edges and using the boundary formula gives the result.

Derivation: The contribution of edge \(i\) to \(\oint_C(x\,dy-y\,dx)\) is \(x_i y_{i+1}-x_{i+1}y_i\). Therefore, for a simple polygon traversed counterclockwise, \[ \operatorname{Area}(D)=\frac12\sum_{i=1}^{n}\left(x_i y_{i+1}-x_{i+1}y_i\right), \qquad (x_{n+1},y_{n+1})=(x_1,y_1). \]

This derivation also explains why the formula depends on the order of the vertices. Each term describes one directed edge, and reversing the direction of every edge reverses the sign of its contribution.

Using the Formula Carefully

A reliable calculation keeps the two products for each edge together. For edge \(i\), first calculate \(x_i y_{i+1}\), then \(x_{i+1}y_i\), and subtract the second from the first. Add those differences, then divide by two. The last row of the calculation must pair the last vertex with the first.

Coordinates can be positive, negative, or zero; the formula works without changing its form. Individual edge contributions can also be negative. That is not an error: the signed contributions combine to give the polygon’s area when the vertices are counterclockwise. The entire sum, rather than every individual term, determines the sign.

Worked Example: A Counterclockwise Rectangle

Find the area of the rectangle with vertices \((0,0)\), \((5,0)\), \((5,3)\), and \((0,3)\), listed counterclockwise. Include the closing edge back to \((0,0)\).

The forward products \(x_i y_{i+1}\), in order, are \(0\cdot0=0\), \(5\cdot3=15\), \(5\cdot3=15\), and \(0\cdot0=0\). Their sum is \(0+15+15+0=30\).

The reverse products \(x_{i+1}y_i\) are \(5\cdot0=0\), \(5\cdot0=0\), \(0\cdot3=0\), and \(0\cdot3=0\). Their sum is \(0+0+0+0=0\). Hence the shoelace sum is \(\frac12(30-0)=15\), so the area is \(15\) square units.

Check: the rectangle’s side lengths are \(5\) and \(3\), so its geometric area is \(5\cdot3=15\) square units, agreeing with the formula.

Worked Example: A Five-Sided Polygon

Find the area of the polygon whose counterclockwise vertices are \((1,1)\), \((4,1)\), \((5,3)\), \((2,5)\), and \((0,3)\).

For the five successive edges, the forward products are \(1\cdot1=1\), \(4\cdot3=12\), \(5\cdot5=25\), \(2\cdot3=6\), and \(0\cdot1=0\). Their sum is \(1+12+25+6+0=44\).

The reverse products are \(4\cdot1=4\), \(5\cdot1=5\), \(2\cdot3=6\), \(0\cdot5=0\), and \(1\cdot3=3\). Their sum is \(4+5+6+0+3=18\). Therefore the signed area is \(\frac12(44-18)=\frac12(26)=13\) square units.

Check by splitting the polygon into three triangles from \((1,1)\). The triangle with vertices \((1,1),(4,1),(5,3)\) has area \(3\). The triangle with vertices \((1,1),(5,3),(2,5)\) has area \(\frac12|4\cdot4-2\cdot1|=7\). The triangle with vertices \((1,1),(2,5),(0,3)\) has area \(\frac12|1\cdot2-4(-1)|=3\). Their areas sum to \(3+7+3=13\), confirming the result.

Worked Example: A Triangle with Negative Coordinates

Find the area of the triangle with counterclockwise vertices \(A=(2,-1)\), \(B=(6,1)\), and \(C=(3,5)\). The closing edge is from \(C\) back to \(A\).

The forward products are \(2\cdot1=2\), \(6\cdot5=30\), and \(3\cdot(-1)=-3\), so their sum is \(2+30-3=29\). The reverse products are \(6\cdot(-1)=-6\), \(3\cdot1=3\), and \(2\cdot5=10\), so their sum is \(-6+3+10=7\).

The signed area is \(\frac12(29-7)=\frac12(22)=11\) square units.

Check using vectors from \(A\): \(\overrightarrow{AB}=(4,2)\) and \(\overrightarrow{AC}=(1,6)\). The triangle’s area is half the absolute value of \(4\cdot6-2\cdot1=22\), which is \(11\) square units. This independently confirms the shoelace result.

Orientation and a Common Sign Error

The formula gives a signed area. Under the stated counterclockwise ordering, that signed area is positive. If the same simple polygon is listed clockwise, the boundary integral changes sign, so the shoelace sum is negative. The geometric area, which is a magnitude, remains positive; however, a negative result indicates that the listed orientation was clockwise rather than counterclockwise.

Common Mistake: Treating a Clockwise Sum as a Negative Geometric Area

Take the rectangle from the first example but list its vertices clockwise: \((0,0)\), \((0,3)\), \((5,3)\), and \((5,0)\). The forward products are \(0\cdot3=0\), \(0\cdot3=0\), \(5\cdot0=0\), and \(5\cdot0=0\), which sum to \(0\). The reverse products are \(0\cdot0=0\), \(5\cdot3=15\), \(5\cdot3=15\), and \(0\cdot0=0\), which sum to \(30\).

The signed sum is \(\frac12(0-30)=-15\). Calling the geometric area “negative \(15\)” is the mistake. The negative sign records clockwise traversal; the rectangle’s area is \(15\) square units. To use the positive-area form derived above, reorder the vertices counterclockwise. As a check, the side lengths still give \(5\cdot3=15\) square units.

Why the Formula Is Useful

The shoelace formula turns a geometric area problem into a finite arithmetic procedure using only ordered coordinates. It is especially helpful for irregular polygons, where a direct height-and-base calculation may be awkward. Its derivation also makes its limits clear: it is a boundary formula for a simple polygon traversed in a specified direction. The assumptions about the boundary and its orientation are part of the result, not optional details.

For organized work, write the vertices in boundary order, include the last-to-first pair, calculate both product sums, and only then take half their difference. Finally, check the sign against the stated orientation and, when possible, compare with a geometric decomposition. These checks catch missing closing edges, misordered coordinates, and arithmetic errors.

Check Your Understanding

Use the definitions and derivation above to answer these questions.

  1. Why must the shoelace calculation include the edge from the last listed vertex back to the first?
  2. Write the signed shoelace sum for a polygon with four ordered vertices using cyclic indexing.
  3. A simple polygon’s shoelace sum is negative. What does that indicate about its traversal, assuming the coordinates are listed consecutively around its boundary?
  4. Why do the terms involving \(t\) cancel when the boundary integral is evaluated along one straight edge?
  5. For the counterclockwise triangle with vertices \((0,0)\), \((4,0)\), and \((0,2)\), calculate the signed area using the shoelace formula.