The **shoelace formula** or **shoelace algorithm** (also known as **Gauss's area formula** and the **surveyor's formula**^{[1]}) is a mathematical algorithm to determine the area of a simple polygon whose vertices are described by their Cartesian coordinates in the plane.^{[2]} The user cross-multiplies corresponding coordinates to find the area encompassing the polygon, and subtracts it from the surrounding polygon to find the area of the polygon within. It is called the shoelace formula because of the constant cross-multiplying for the coordinates making up the polygon, like tying shoelaces.^{[2]} It is also sometimes called the **shoelace method**. It has applications in surveying and forestry,^{[3]} among other areas.

The formula was described by Meister (1724-1788) in 1769^{[4]} and by Gauss in 1795.^{[full citation needed]} It can be verified by dividing the polygon into triangles, and can be considered to be a special case of Green's theorem.

The area formula is derived by taking each edge *AB*, and calculating the (signed) area of triangle *ABO* with a vertex at the origin *O*, by taking the cross-product (which gives the area of a parallelogram) and dividing by 2. As one wraps around the polygon, these triangles with positive and negative area will overlap, and the areas between the origin and the polygon will be cancelled out and sum to 0, while only the area inside the reference triangle remains. This is why the formula is called the Surveyor's Formula, since the "surveyor" is at the origin; if going counterclockwise, positive area is added when going from left to right and negative area is added when going from right to left, from the perspective of the origin.^{[citation needed]}

The area formula is valid for any non-self-intersecting (simple) polygon, which can be convex or concave.

## Definition

The formula can be represented by the expression

- $\begin{array}{cc}A& =\frac{1}{2}|\sum _{i=1}^{n-1}{x}_{i}{y}_{i+1}+{x}_{n}{y}_{1}-\sum _{i=1}^{n-1}{x}_{i+1}{y}_{i}-{x}_{1}{y}_{n}|\\ =\frac{1}{2}|{x}_{1}{y}_{2}+{x}_{2}{y}_{3}+\cdots +{x}_{n-1}{y}_{n}+{x}_{n}{y}_{1}-{x}_{2}{y}_{1}-{x}_{3}{y}_{2}-\cdots -{x}_{n}{y}_{n-1}-{x}_{1}{y}_{n}|\end{array}$

where

*A*is the area of the polygon,*n*is the number of sides of the polygon, and- (
*x*_{i},*y*_{i}),*i*= 1, 2,...,*n*are the vertices (or "corners") of the polygon.

Alternatively^{[3]}^{[5]}^{[6]}

- $A=\frac{1}{2}|\sum _{i=1}^{n}{x}_{i}({y}_{i+1}-{y}_{i-1})|=\frac{1}{2}|\sum _{i=1}^{n}{y}_{i}({x}_{i+1}-{x}_{i-1})|=\frac{1}{2}|\sum _{i=1}^{n}{x}_{i}{y}_{i+1}-{x}_{i+1}{y}_{i}|=\frac{1}{2}|\sum _{i=1}^{n}({x}_{i+1}+{x}_{i})({y}_{i+1}-{y}_{i})|=\frac{1}{2}|\sum _{i=1}^{n}det\left(\begin{array}{cc}{x}_{i}& {x}_{i+1}\\ {y}_{i}& {y}_{i+1}\end{array}\right)|$

where
*x*_{n+1} = *x*_{1} and *x*_{0} = *x*_{n},
as well as
*y*_{n+1} = *y*_{1} and *y*_{0} = *y*_{n}.

If the points are labeled sequentially in the counterclockwise direction, then the sum of the above determinants is positive and the absolute value signs can be omitted;^{[1]} if they are labeled in the clockwise direction, the sum of the determinants will be negative. This is because the formula can be viewed as a special case of Green's Theorem.

## Proofs

### Proof for a triangle

Referring to the figure, let $A$ be the area of the triangle whose vertices are given by the coordinates $({x}_{1},{y}_{1}),({x}_{2},{y}_{2}),$ and $({x}_{3},{y}_{3}).$ Draw the minimum area rectangle around the triangle so its sides are parallel to the $x$ or $y$ axes. At least one vertex of the triangle will be on a corner of the rectangle. In the figure, the areas of the three surrounding triangles are $C,D,$ and $E.$ Obviously $A$ is equal to the area of the rectangle (call it $R$) minus the areas of the other three triangles. The equation describing this relationship is

- $A=R-C-D-E$

By inspection of the figure it can be seen that the areas are given by

- $R=({x}_{3}-{x}_{2})({y}_{1}-{y}_{3})=({x}_{3}{y}_{1}+{x}_{2}{y}_{3})-({x}_{3}{y}_{3}+{x}_{2}{y}_{1})$

- $-C=-\frac{1}{2}({x}_{3}-{x}_{2})({y}_{2}-{y}_{3})=\frac{1}{2}(-{x}_{3}{y}_{2}-{x}_{2}{y}_{3})+\frac{1}{2}({x}_{3}{y}_{3}+{x}_{2}{y}_{2})$

- $-D=-\frac{1}{2}({x}_{3}-{x}_{1})({y}_{1}-{y}_{3})=\frac{1}{2}(-{x}_{3}{y}_{1}-{x}_{1}{y}_{3})+\frac{1}{2}({x}_{3}{y}_{3}+{x}_{1}{y}_{1})$

- $-E=-\frac{1}{2}({x}_{1}-{x}_{2})({y}_{1}-{y}_{2})=\frac{1}{2}(-{x}_{1}{y}_{1}-{x}_{2}{y}_{2})+\frac{1}{2}({x}_{1}{y}_{2}+{x}_{2}{y}_{1})$

Collecting terms and rearranging yields

- $A=\frac{1}{2}\left(\right({x}_{2}{y}_{3}-{x}_{3}{y}_{2})-({x}_{1}{y}_{3}-{x}_{3}{y}_{1})+({x}_{1}{y}_{2}-{x}_{2}{y}_{1}\left)\right)$

which can be written as a determinant

- $A=\frac{1}{2}\left|\begin{array}{ccc}1& 1& 1\\ {x}_{1}& {x}_{2}& {x}_{3}\\ {y}_{1}& {y}_{2}& {y}_{3}\end{array}\right|$

If the coordinates are written in a clockwise order, the value of the determinant will be $-A.$

Rearranging another way

- $A=\frac{1}{2}|{x}_{1}{y}_{2}+{x}_{2}{y}_{3}+{x}_{3}{y}_{1}-{x}_{2}{y}_{1}-{x}_{3}{y}_{2}-{x}_{1}{y}_{3}|$

which is the form of the shoelace formula. This formula can be extended to find the area of any polygon since a simple polygon can be divided into triangles.

### Proof for a quadrilateral and general polygon

Finding the area of a quadrilateral demonstrates how the shoelace formula is generalized to any polygon by dividing the polygon into triangles. Consider the figure of a quadrilateral whose coordinates are labeled in counterclockwise order. The quadrilateral is divided into two triangles with areas $A$ and $B.$ Using the triangle formula on each triangle we get

- $A=\frac{1}{2}({x}_{1}{y}_{2}+{x}_{2}{y}_{3}+{x}_{3}{y}_{1}-{x}_{2}{y}_{1}-{x}_{3}{y}_{2}-{x}_{1}{y}_{3})$

- $B=\frac{1}{2}({x}_{1}{y}_{3}+{x}_{3}{y}_{4}+{x}_{4}{y}_{1}-{x}_{3}{y}_{1}-{x}_{4}{y}_{3}-{x}_{1}{y}_{4})$

Since both triangles were traced in a counterclockwise direction, both areas are positive and we get the area of the quadrilateral by adding the two areas. The last positive term and the last negative term of $A$ cancel with the first positive term and the first negative term of $B$ giving

- ${A}_{\text{quad.}}=\frac{1}{2}({x}_{1}{y}_{2}+{x}_{2}{y}_{3}+{x}_{3}{y}_{4}+{x}_{4}{y}_{1}-{x}_{2}{y}_{1}-{x}_{3}{y}_{2}-{x}_{4}{y}_{3}-{x}_{1}{y}_{4})$

## Examples

The user must know the points of the polygon in a Cartesian plane. For example, take a triangle with coordinates {(2, 1), (4, 5), (7, 8)}. Take the first *x*-coordinate and multiply it by the second *y*-value, then take the second *x*-coordinate and multiply it by the third *y*-value, and repeat as many times until it is done for all wanted points. This can be defined by this formula:^{[7]}

- ${A}_{\text{tri.}}=\frac{1}{2}|{x}_{1}{y}_{2}+{x}_{2}{y}_{3}+{x}_{3}{y}_{1}-{x}_{2}{y}_{1}-{x}_{3}{y}_{2}-{x}_{1}{y}_{3}|$

for *x*_{i} and *y*_{i} representing each respective coordinate. This formula is just the expansion of those given above for the case n = 3. Using it, one can find that the area of the triangle equals one half of the absolute value of 10 + 32 + 7 − 4 − 35 − 16, which equals 3. The number of variables depends on the number of sides of the polygon. For example, a pentagon will be defined up to *x*_{5} and *y*_{5}:

- ${A}_{\text{pent.}}=\frac{1}{2}|{x}_{1}{y}_{2}+{x}_{2}{y}_{3}+{x}_{3}{y}_{4}+{x}_{4}{y}_{5}+{x}_{5}{y}_{1}-{x}_{2}{y}_{1}-{x}_{3}{y}_{2}-{x}_{4}{y}_{3}-{x}_{5}{y}_{4}-{x}_{1}{y}_{5}|$

A quadrilateral will be defined up to *x*_{4} and *y*_{4}:

- ${A}_{\text{quad.}}=\frac{1}{2}|{x}_{1}{y}_{2}+{x}_{2}{y}_{3}+{x}_{3}{y}_{4}+{x}_{4}{y}_{1}-{x}_{2}{y}_{1}-{x}_{3}{y}_{2}-{x}_{4}{y}_{3}-{x}_{1}{y}_{4}|$

## More complex example

Consider the polygon defined by the points (3,4), (5,11), (12,8), (9,5), and (5,6), and illustrated in the following diagram:

The area of this polygon is:

- $\begin{array}{cc}A& =\frac{1}{2}|3\times 11+5\times 8+12\times 5+9\times 6+5\times 4\\ \phantom{\rule{2em}{0ex}}\\ =\frac{60}{2}=30\end{array}$

## Etymology

The reason this formula is called the shoelace formula is because of a common method used to evaluate it. This method uses matrices. As an example, choose the triangle with vertices (2,4), (3,−8), and (1,2). Then construct the following matrix by “walking around” the triangle and ending with the initial point.^{[8]}

- $\left[\begin{array}{cc}2& 4\\ 3& -8\\ 1& 2\\ 2& 4\end{array}\right]$

First, draw diagonal down and to the right slashes (as shown below),

and multiply the two numbers connected by each slash, then add all the products: (2 × −8) + (3 × 2) + (1 × 4) = −6. Do the same thing with slashes diagonal down and to the left (shown below with downwards slashes):

(4 × 3) + (−8 × 1) + (2 × 2) = 8. Then take the difference of these two numbers: |(−6 )−( 8)| = 14. Halving this gives the area of the triangle: 7. Organizing the numbers like this makes the formula easier to recall and evaluate. With all the slashes drawn, the matrix loosely resembles a shoe with the laces done up, giving rise to the algorithm's name.

## See also

## References

- ^
^{a}^{b}Bart Braden (1986). "The Surveyor's Area Formula" (PDF).*The College Mathematics Journal*.**17**(4): 326–337. doi:10.2307/2686282. - ^
^{a}^{b}Dahlke, Karl. "Shoelace Formula". Retrieved 9 June 2008. - ^
^{a}^{b}Hans Pretzsch,*Forest Dynamics, Growth and Yield: From Measurement to Model*, Springer, 2009, ISBN 3-540-88306-1, p. 232. **^**Meister, A. L. F. (1769), "Generalia de genesi figurarum planarum et inde pendentibus earum affectionibus",*Nov. Com. Gött.*(in Latin),**1**: 144.**^**Shoelace Theorem,*Art of Problem Solving Wiki*.**^**Weisstein, Eric W. "Polygon Area".*Wolfram MathWorld*. Retrieved 24 July 2012.**^**Richard Rhoad; George Milauskas; Robert Whipple (1991).*Geometry for Enjoyment and Challenge*(new ed.). McDougal Littell. pp. 717–718. ISBN 0-86609-965-4.**^**IMSA JHMC Guide, Page. 10 "Shoelace" by Cindy Xi