The diagonal formula for polygons
A diagonal joins two corners of a polygon that are not neighbors. A polygon with n sides has n(n - 3)/2 diagonals. The word "diagonal" is also used for the length of that segment in a rectangle, a square or a box, and the length formulas come from the Pythagorean theorem. This page covers both meanings and keeps them apart.
For students and parents planning test prep or coursework: one hour with George Li, one to one by video, is $180, $200 or $160, by subject. You leave with a written plan within one working day.
Book your first session| Sides n | Polygon | Diagonals n(n - 3)/2 | Distinct diagonal lengths if regular |
|---|---|---|---|
| 3 | triangle | 0 | 0 |
| 4 | quadrilateral | 2 | 1 |
| 5 | pentagon | 5 | 1 |
| 6 | hexagon | 9 | 2 |
| 7 | heptagon | 14 | 2 |
| 8 | octagon | 20 | 3 |
| 9 | nonagon | 27 | 3 |
| 10 | decagon | 35 | 4 |
| 12 | dodecagon | 54 | 5 |
| 20 | 20-gon | 170 | 9 |
A triangle has no diagonals, because every pair of its vertices is already joined by a side.
Diagonal count n(n - 3)/2 and the count of distinct lengths, the floor of (n - 2)/2 for a regular polygon, as stated in the Wikipedia article on diagonals; each count was recomputed here
Where does the formula n(n - 3)/2 come from?
There are two short derivations, and either one is enough to rebuild the formula during a test.
Count by vertex. Stand on one vertex. It cannot connect to itself, and its two neighbors are joined to it by sides, so it connects to n - 3 other vertices by diagonals. There are n vertices, so n(n - 3) is the total, except that each diagonal has two ends and has been counted from both. Divide by 2.
Count by pairs. Any two vertices make a pair, and there are n(n - 1)/2 pairs. Of those pairs, n are sides. The rest are diagonals: n(n - 1)/2 - n = n(n - 3)/2. For n = 6, that is 15 pairs, minus 6 sides, which leaves 9.
The formula holds for any simple polygon, convex or concave. In a convex polygon all diagonals lie inside it. In a concave one, some can run outside the polygon, and they still count because they join vertices that are not adjacent.
Worked example. A polygon has 54 diagonals. How many sides does it have?
- Set up the equation: n(n - 3)/2 = 54, so n(n - 3) = 108.
- Expand: n^2 - 3n - 108 = 0.
- Factor: (n - 12)(n + 9) = 0, so n = 12 or n = -9.
- A side count cannot be negative, so n = 12. The polygon is a dodecagon.
Answer: 12 sides. Check: 12 x 9 / 2 = 54.
How long is a diagonal?
The length of a diagonal comes from a right triangle.
- A rectangle with length l and width w has diagonal sqrt(l^2 + w^2).
- A square with side a has diagonal a x sqrt(2), the same formula with l = w = a.
- A rectangular box with length l, width w and height h has a space diagonal sqrt(l^2 + w^2 + h^2).
- A cube with edge s has a space diagonal s x sqrt(3).
The box formula is the Pythagorean theorem applied twice: first across the floor, then up the wall. A rectangle 7 by 24 has a diagonal of sqrt(49 + 576) = sqrt(625) = 25, and a room 12 by 9 by 8 has a space diagonal of sqrt(144 + 81 + 64) = sqrt(289) = 17.
Worked example. A television is sold as 55 inches, which names the diagonal of its screen. The screen has a width to height ratio of 16 to 9. How wide and how tall is it?
- Write the sides as 16k and 9k for some k.
- The diagonal gives (16k)^2 + (9k)^2 = 55^2, so 337k^2 = 3,025.
- Then k^2 = 3,025/337, so k is about 2.996.
- The width is 16k, about 47.9 inches, and the height is 9k, about 27.0 inches.
Answer: about 47.9 inches wide and 27.0 inches tall. Check: 47.94^2 + 26.96^2 is 3,025, which is 55^2.
Why does a diagonal help in construction and in proofs?
A rectangle that has no diagonal can lean into a parallelogram, because a four-sided frame can change its angles without changing its side lengths. Adding one diagonal splits the frame into two triangles, and a triangle cannot change its shape if its sides are fixed. That is why braces on shelves, gates and bridges run along diagonals. In proofs, a diagonal does the same job on paper: it cuts a polygon into triangles so that triangle facts can be used, as when a diagonal turns a rectangle into two congruent right triangles.
Which mistakes show up most?
- Forgetting to divide by 2. Counting from every vertex counts each diagonal twice.
- Using n - 2 or n - 1 per vertex. A vertex has n - 3 diagonals, because the two neighbors are joined by sides.
- Mixing up the number of diagonals with their length. The first uses n(n - 3)/2, and the second uses the Pythagorean theorem.
- Using a cube's face diagonal in place of its space diagonal. A face diagonal is s x sqrt(2), and the space diagonal through the center is s x sqrt(3).
When does a tutor help with polygons?
A tutor helps when formulas are memorized without their reasons. A session can rebuild the diagonal count in under a minute from the two derivations above, then drill the length formulas on box and screen problems. See the high school courses page, the packages, or book a first session. For related polygon pages, read about the decagon, the dodecagon and area and perimeter of polygons.
Common questions
What is the formula for the number of diagonals of a polygon?
n(n - 3)/2, with n standing for the count of sides.
How many diagonals does a hexagon have?
9.
What is the diagonal of a square?
The side length times the square root of 2.
What is the diagonal of a cube?
The edge length times the square root of 3.