The Shoelace Theorem is a method for calculating the area of a simple (non-self-intersecting) polygon in the plane given only the coordinates of its vertices. For example:
This polygon has area 12. The Shoelace Theorem says we can calculate the area by writing the coordinates in clockwise order in a column, repeat the first pair, then multiply diagonally adjacent coordinates, sum each column of products, take the difference and divide by two:
If we notice this particular shape can be divided along a horizontal to become two triangles of base 6 and height 2, then we easily verify the area is in fact 12. Note if we write down the coordinates in counterclockwise order we get the negation of the area. When applying this theorem, always remember to divide by 2!
In general, if we have a simple polygon of vertices with coordinates listed in clockwise order and we define then the area is:
This is a direct consequence of Green’s Theorem (and thus the ubiquitous Stoke’s Theorem), but understanding those theorems requires calculus. Thus we will use a more direct way of deriving the theorem.
Let’s consider the example quadrilateral again, where we label the vertices clockwise starting with on the left. One way to calculate its area is to draw a rectangle around it and subtract the area of the triangles that are formed.
However this doesn’t work for other shapes, where the number and position of triangles varies, and we even might need to introduce smaller rectangles as well.
Let’s consider the top edges of our quadrilateral. By extending one of them down to the x-axis, we form a trapezoid.
It’s easy to calculate the area of this trapezoid: it’s just the width times the average height, or . By adding all the top edges together, we almost get the total area of our shape, but this sum unfortunately includes all the area swept down to the x-axis.
We can use the same trick with the bottom edges to find the area of this extra region.
For the bottom edges, we notice that we have to do the trapezoid width subtraction the other way around, because for bottom edges . Thus the total area is:
Now we make a few observations. First, if we replace and with and , but only in the last term, then each term involves only vertices and . (Remember .) Second, we see that if we distribute in the negative sign on bottom edges, they look just like top edges, i.e. each term is just . Whether a term is a top or bottom edge depends only on whether . If it is, then it’s a top edge and we want to add it to the sum, if it’s not, then it’s a bottom edge and we want to subtract it. All of this together means we can write the area as:
Multiplying this out gives us:
Now we notice that there are terms and terms. When we take the wrap-around into account, we see each of these is summing the exact same numbers, just with opposite signs. Thus the total is zero and we can just drop those terms. Rewriting the remaining two terms in their own sums yields:
This is the formula we are after. We still have a few issues to resolve before we call this a theorem, however.
When we were calculating the area of an edge-trapezoid, we implicitly assumed both y-coordinates were non-negative. That’s because if they weren’t our trapezoid would be some other shape:
In this case we aren’t calculating the area of this shape, so our logic breaks down. To resolve this we notice that our formula is vertically shift invariant, i.e. we can add a constant to all the y-coordinates, and the formula gives the same result. To see this, recall this form of the formula:
If we add a constant to all y-coordinates, we get:
Now we see that with the wrap-around is just zero, and so we can add whatever constant we want without changing the value of the formula. When we are deriving the theorem we can shift the shape up until all y-coordinates are positive. Of course, when we actually use the theorem to calculate an area, we don’t need to do this, as we just showed the same area is calculated regardless.
For the shapes we’ve seen so far, “top” and “bottom” have been quite clear. But what about more complicated shapes?
Some of the edges in these shapes aren’t completely above or below the shape. Does the theorem still work for these shapes?
Naturally, the answer is yes, but it requires some more subtle reasoning to see why this is true. First, we’ll take our shape and divide it into strips vertically at each of its vertices. We’ll color the shape gray, top edges green, and bottom edges red.
Each vertical section looks like a series of trapezoids and triangles stacked on each other, where the horizontal edges of the trapezoids are the edges of the original polygon and the vertical edges are the vertical edges of the strip. Because we list the vertices in clockwise order, each edge has the polygon’s interior to the right, as it would be if we imagined ourselves walking along each edge from vertex to vertex in order. Thus in each of the regions in the strip on the polygon’s interior will have a green edge above and a red edge below each part of the strip the intersects our shape. The area of that region of the strip is just the difference between the trapezoid from the top edge to the x-axis and the analogous bottom edge trapezoid. By summing up over all the pieces of every strip, we find the total area is all the top edge areas minus all the bottom edge areas, which is exactly what our formula computes.