Sub topic 3
Counting diagonals and triangulating a polygon
This chapter assumes you know the interior angle sum of a triangle (180°), basic combinations (choosing 2 items from n), and how to solve a simple quadratic equation. It builds on the previous chapter, which gave the interior angle sum (n−2)×180° for a polygon with n sides.
Two ideas do most of the work here. The first is a counting formula for diagonals. The second is triangulation, which means cutting a polygon into triangles using diagonals. Both reduce a many-sided figure to something you can count or add up.
What a diagonal is
A diagonal is a line segment joining two vertices of a polygon that are not next to each other. Sides join neighbouring vertices, so they are not diagonals. In this chapter every polygon is convex, meaning all interior angles are less than 180° and every diagonal lies inside the polygon. CAT questions almost always assume this.
The formula n(n−3)/2
Pick one vertex. It can be joined to n−1 other vertices. Two of those are its neighbours, which gives sides, not diagonals. So each vertex starts n−3 diagonals.
Multiplying by n vertices gives n(n−3). Each diagonal has two ends, so it was counted twice. Divide by 2:
Diagonals = n(n−3)/2
A second route gives the same answer. There are C(n,2) = n(n−1)/2 segments joining any two vertices. Remove the n sides:
n(n−1)/2 − n = n(n−1−2)/2 = n(n−3)/2
The second route is useful when a question asks about "lines" or "segments" among points, because the same C(n,2) idea appears again.
from itertools import combinations
def diagonals(n):
return n * (n - 3) // 2
def diagonals_brute(n):
count = 0
for i, j in combinations(range(n), 2):
adjacent = (j - i == 1) or (i == 0 and j == n - 1)
if not adjacent:
count += 1
return count
for n in range(3, 13):
assert diagonals(n) == diagonals_brute(n)
print(n, diagonals(n))The brute-force count lists every pair of vertices and skips neighbouring pairs, including the wrap-around pair (0, n−1). It agrees with the formula for every n from 3 to 12. A triangle gives 0 diagonals, which is correct.
Triangulation
To triangulate a polygon, pick one vertex and draw all its diagonals. They split the polygon into triangles.
- That vertex has n−3 diagonals.
- n−3 diagonals cut the polygon into n−2 triangles.
- The triangles together fill the polygon, and their angles make up its interior angles.
So the interior angle sum is (n−2)×180°, which is exactly the result from the previous chapter. This is where that rule comes from.
| Sides n | Diagonals from one vertex (n−3) | Triangles (n−2) | Total diagonals | Angle sum |
|---|---|---|---|---|
| 4 | 1 | 2 | 2 | 360° |
| 5 | 2 | 3 | 5 | 540° |
| 6 | 3 | 4 | 9 | 720° |
| 8 | 5 | 6 | 20 | 1080° |
| 10 | 7 | 8 | 35 | 1440° |
Notice the difference between two quantities that are easy to confuse. A triangulation uses only n−3 diagonals, while the polygon has n(n−3)/2 diagonals in total. A triangulation picks a non-crossing subset.
Worked examples
Finding n from the diagonal count
A convex polygon has 54 diagonals. How many sides does it have?
Set n(n−3)/2 = 54, so n(n−3) = 108. Look for two numbers that differ by 3 and multiply to 108. These are 12 and 9, so n = 12.
As a quadratic, n² − 3n − 108 = 0, which factors as (n−12)(n+9) = 0. Reject n = −9 because a polygon cannot have a negative number of sides.
Diagonals from an angle
Each interior angle of a regular polygon is 140°. How many diagonals does it have?
The exterior angle is 180° − 140° = 40°. So n = 360/40 = 9. Diagonals = 9×6/2 = 27.
When diagonals equal sides
For which polygon is the number of diagonals equal to the number of sides?
n(n−3)/2 = n gives n−3 = 2, so n = 5. Only the pentagon works. You can divide by n because n is not zero.
Diagonals through the centre
How many diagonals of a regular 12-gon do not pass through its centre?
Total diagonals: 12×9/2 = 54. A diagonal passes through the centre when it joins opposite vertices. A polygon with an even number of sides has n/2 such diagonals, so here there are 6. The answer is 54 − 6 = 48.
For an odd n, no diagonal passes through the centre.
Counting triangles
How many triangles can be formed using the vertices of a convex octagon as their corners?
Any 3 vertices make a triangle, so there are C(8,3) = 56 triangles.
How many of them share no side with the octagon? A triangle that uses no polygon side needs vertices with gaps between them. The count is n(n−4)(n−5)/6, so here 8×4×3/6 = 16. You can check this by hand: choose 3 vertices of 8 around a circle with at least one unused vertex between each pair. The result is 16.
Further counts that appear in questions
Interior intersection points
In a convex polygon, every set of 4 vertices determines exactly one pair of crossing diagonals. So if no three diagonals meet at one point, the number of interior intersection points is C(n,4).
For n = 8 this gives C(8,4) = 70.
This count assumes general position. A regular polygon often breaks that assumption. In a regular hexagon, the three long diagonals meet at the centre. C(6,4) = 15 counts that centre point three times, once for each pair of long diagonals, so the true number of distinct points is 15 − 3 + 1 = 13.
Distinct diagonal lengths in a regular polygon
Diagonals are classified by how many vertices they skip. In a regular n-gon, the chord from one vertex to the vertex k steps away has the same length as the chord k steps the other way. So the distinct lengths come from k = 2, 3, …, ⌊n/2⌋. That gives ⌊n/2⌋ − 1 different diagonal lengths.
- Regular hexagon: 2 lengths, which are √3 times the side and 2 times the side.
- Regular octagon: 3 lengths.
- Regular heptagon: 2 lengths.
Number of ways to triangulate
Questions sometimes ask in how many ways a convex polygon can be cut into triangles by non-crossing diagonals. The answer is a Catalan number, C(2(n−2), n−2)/(n−1). The values are 2 for a quadrilateral, 5 for a pentagon, 14 for a hexagon and 42 for a heptagon. CAT rarely asks for more than a pentagon or hexagon, so listing the cases by hand is usually fast enough.
Common errors
- Using n(n−3) without dividing by 2. This counts each diagonal twice.
- Using n−3 triangles. Triangulating gives n−2 triangles, because the n−3 diagonals make n−3+1 pieces.
- Mixing up "diagonals from one vertex" (n−3) with "total diagonals."
- Dropping the negative root when solving the quadratic, or forgetting to check that n is a whole number of at least 3.
- Treating C(n,4) as exact for regular polygons. Concurrent diagonals reduce the count of distinct points.
Exercises
Exercise
A convex polygon has 3 more diagonals than it has sides. How many sides does it have, and what is the sum of its interior angles?
Show answer
Set n(n−3)/2 = n + 3, so n² − 3n = 2n + 6, giving n² − 5n − 6 = 0, which factors as (n−6)(n+1) = 0. So n = 6, a hexagon. Check: 6×3/2 = 9 diagonals, which is 6 + 3. The angle sum is (6−2)×180° = 720°.
Exercise
A regular polygon has 20 diagonals. What is each of its exterior angles, and how many of its diagonals pass through the centre?
Show answer
n(n−3)/2 = 20 gives n(n−3) = 40, so n = 8. The exterior angle is 360°/8 = 45°. Since n is even, n/2 = 4 diagonals pass through the centre.
Exercise
In a convex decagon (10 sides), a triangulation is made using non-crossing diagonals. How many diagonals are drawn, how many triangles result, and how many diagonals of the decagon are not used?
Show answer
A triangulation uses n−3 = 7 diagonals and gives n−2 = 8 triangles. The decagon has 10×7/2 = 35 diagonals in total, so 35 − 7 = 28 are not used.
Exercise
A convex 7-sided polygon is drawn so that no three diagonals meet at a single point. How many interior points do the diagonals cross at?
Show answer
Each set of 4 vertices gives exactly one crossing, so the count is C(7,4) = 35.