The Shoelace Formula

Problem 1. Consider the triangle below.

Show that the triangle has area \frac 12 (x_1 y_2 - x_2 y_1).

(Click for Solution)

Solution. Add dashed lines to draw in “phantom” triangles.

We subtract the area of the three smaller triangles from the larger rectangle:

\begin{aligned} &\textstyle x_1 y_2 - \frac 12 x_1 y_1 - \frac 12 (x_1 - x_2)(y_2 - y_1) - \frac 12 x_2 y_2 \\ & = \textstyle x_1 y_2 - \frac 12 (x_1 y_1 + (x_1 - x_2)(y_2 - y_1) + x_2 y_2) \\ & = \textstyle x_1 y_2 - \frac 12 (x_1 y_1 + (x_1 y_2 - x_1 y_1 - x_2 y_2 + x_2 y_1) + x_2 y_2) \\ & = \textstyle x_1 y_2 - \frac 12 ( x_1 y_2 + x_2 y_1 ) \\ &= \textstyle \frac 12 (2x_1 y_2 - (x_1 y_2 + x_2 y_1)) \\ &= \textstyle \frac 12 (x_1 y_2 - x_2 y_1). \end{aligned}

Remark 1. There are many other kinds of triangles, but with enough patience, they can all be shown to yield the same area formula.

Definition 1. Define

\begin{aligned} \left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right| &:= x_1 y_2 - x_2 y_1. \end{aligned}

In particular, the area of the triangle in Problem 1 can be written as \displaystyle \frac 12 \left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right|.

Problem 2. Show that \left| \begin{matrix} x_2 & x_1 \\ y_2 & y_1 \end{matrix} \right| = -\left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right|. In particular,

\left| \begin{matrix} x_2 & x_1 \\ y_2 & y_1 \end{matrix} \right| + \left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right| = 0.

(Click for Solution)

Solution. By definition,

\begin{aligned} \left| \begin{matrix} x_2 & x_1 \\ y_2 & y_1 \end{matrix} \right| &=  (x_2y_1 - x_1y_2) \\ &= -(x_1 y_2 - x_1 y_2) \\ &= -\left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right|. \end{aligned}

Remark 1. In particular, a polygon is said to have positive orientation if its coordinates are traversed in anti-clockwise direction, and have negative orientation if its coordinates are traversed in clock-wise direction.

Problem 3. Consider the triangle below with positive orientation.

Show that the triangle has area

\displaystyle \frac 12 \left(\left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right| + \left| \begin{matrix} x_2 & x_3 \\ y_2 & y_3 \end{matrix} \right| + \left| \begin{matrix} x_3 & x_1 \\ y_3 & y_1 \end{matrix} \right|\right).

(Click for Solution)

Solution. Draw some “phantom” triangles:

Denote the area of the triangle by A. By Problem 1,

\begin{aligned}A + \frac 12 \left| \begin{matrix} x_1 & x_3 \\ y_1 & y_3 \end{matrix} \right| &= \frac 12 \left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right|  + \frac 12 \left| \begin{matrix} x_2 & x_3 \\ y_2 & y_3 \end{matrix} \right|. \end{aligned}

By Problem 2,

\begin{aligned}A &= \frac 12 \left(\left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right| + \left| \begin{matrix} x_2 & x_3 \\ y_2 & y_3 \end{matrix} \right| - \left| \begin{matrix} x_1 & x_3 \\ y_1 & y_3 \end{matrix} \right|  \right) \\ &= \frac 12 \left(\left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right| + \left| \begin{matrix} x_2 & x_3 \\ y_2 & y_3 \end{matrix} \right| + \left| \begin{matrix} x_3 & x_1 \\ y_3 & y_1 \end{matrix} \right|  \right). \end{aligned}

Remark 2. In a similar manner, for triangles with other orientations, as long as the vertices are traversed in an anti-clockwise direction, we still recover the same formula as in Problem 3.

Definition 2. Make the notation

\begin{aligned} \left| \begin{matrix} x_1 & x_2 & \cdots & x_n \\ y_1 & y_2 & \cdots & y_n\end{matrix} \right| &:= \left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right| + \left| \begin{matrix} x_2 & x_3 \\ y_2 & y_3 \end{matrix} \right| + \cdots + \left| \begin{matrix} x_{n-1} & x_n \\ y_{n-1} & y_n \end{matrix} \right|. \end{aligned}

This notation is commonly referred to as the shoelace formula. In particular, the area in Problem 3 can be expressed as

\displaystyle \frac 12 \left| \begin{matrix} x_1 & x_2 & x_3 & x_1 \\ y_1 & y_2 & y_3 & y_1 \end{matrix} \right|.

Problem 4. Show that

\left| \begin{matrix} x_1 & \cdots & x_k \\ y_1 & \cdots & y_k\end{matrix} \right| + \left| \begin{matrix} x_k & \cdots & x_n \\ y_k & \cdots & y_n\end{matrix} \right| = \left| \begin{matrix} x_1 & x_2 & \cdots & x_n \\ y_1 & y_2 & \cdots & y_n\end{matrix} \right|.

(Click for Solution)

Solution. Patiently expand the right-hand side:

\begin{aligned} &\left| \begin{matrix} x_1 & \cdots & x_k & \cdots & x_n \\ y_1 & \cdots & y_k & \cdots & y_n\end{matrix} \right| \\ &= \left| \begin{matrix} x_1 & x_2 \\ y_1 & y_2 \end{matrix} \right| + \cdots + \left| \begin{matrix} x_{k-1} & x_k \\ y_{k-1} & y_k \end{matrix} \right| + \left| \begin{matrix} x_k & x_{k+1} \\ y_k & y_{k+1} \end{matrix} \right| + \cdots + \left| \begin{matrix} x_{n-1} & x_n \\ y_{n-1} & y_n \end{matrix} \right| \\ &= \left| \begin{matrix} x_1 & \cdots & x_k \\ y_1 & \cdots & y_k\end{matrix} \right| + \left| \begin{matrix} x_k & \cdots & x_n \\ y_k & \cdots & y_n\end{matrix} \right| . \end{aligned}

Problem 5. Consider the quadrilateral below.

Show that the quadrilateral has area

\displaystyle \frac 12 \left| \begin{matrix} x_1 & x_2 & x_3 & x_4 & x_1 \\ y_1 & y_2 & y_3 & y_4 & y_1 \end{matrix} \right|.

(Click for Solution)

Solution. Connect (x_1,y_1) to (x_3,y_3).

The quadrilateral consists of two triangles, and therefore its area is given by the sum of both triangles, whose formulas are given by Problem 4:

\begin{aligned} & \left| \begin{matrix} x_1 & x_2 & x_3 & x_1 \\ y_1 & y_2 & y_3 & y_1 \end{matrix} \right| + \left| \begin{matrix} x_1 & x_3 & x_4 & x_1 \\ y_1 & y_3 & y_4 & y_1 \end{matrix} \right| \\ &= \left| \begin{matrix} x_1 & x_2 & x_3  \\ y_1 & y_2 & y_3 \end{matrix} \right| + \underbrace{ \left| \begin{matrix} x_3 & x_1 \\ y_3 & y_1 \end{matrix} \right| + \left| \begin{matrix} x_1 & x_3  \\ y_1 & y_3 \end{matrix} \right| }_0 + \left| \begin{matrix} x_3 & x_4 & x_1 \\ y_3 & y_4 & y_1 \end{matrix} \right| \\ &= \left| \begin{matrix} x_1 & x_2 & x_3  \\ y_1 & y_2 & y_3 \end{matrix} \right| +  \left| \begin{matrix} x_3 & x_4 & x_1 \\ y_3 & y_4 & y_1 \end{matrix} \right| \\ &= \left| \begin{matrix} x_1 & x_2 & x_3 & x_4 & x_1 \\ y_1 & y_2 & y_3 & y_4 & y_1 \end{matrix} \right|, \end{aligned}

where the 0 comes from Problem 2. Multiplying both sides by 1/2 yields the formula

\displaystyle \frac 12 \left| \begin{matrix} x_1 & x_2 & x_3 & x_4 & x_1 \\ y_1 & y_2 & y_3 & y_4 & y_1 \end{matrix} \right|.

Remark 2. Using mathematical induction and the same strategy in Problem 5, the signed area of an n-gon with vertices

(x_1, y_1), (x_2,y_2), \dots, (x_n, y_n)

can be shown to equal

\displaystyle \frac 12 \left| \begin{matrix} x_1 & x_2 & \cdots & x_n & x_1 \\ y_1 & y_2 & \cdots & y_n & y_1 \end{matrix} \right|.

Furthermore, this quantity is positive if the vertices are traversed in an anti-clockwise direction and negative if the vertices are traversed in a clockwise direction.

—Joel Kindiak, 24 Jan 26, 1722H

,

Published by


Leave a comment