Polygon Diagonal Calculator
Find the number of diagonals in a polygon from its side count, plus diagonals per vertex, vertex pairs and triangles.
What it does
A diagonal is a segment joining two vertices of a polygon that are not next to each other. The University of Florida handout on diagonals defines it as a line connecting non neighbouring vertices of a convex polygon and then derives the count by fitting a quadratic to small cases. The result is that an n sided polygon has n(n-3)/2 diagonals.
The reasoning takes two steps. From any one corner you can reach n-3 other corners by diagonals, because the two adjacent corners are joined by sides instead. Doing this at all n corners counts every diagonal twice, once from each end, so the product n(n-3) is divided by two.
There is a second route to the same number. A set of n points has n(n-1)/2 pairs, and drawing every pair gives the complete set of segments between vertices. Remove the n pairs that are sides of the polygon and the remainder is n(n-1)/2 - n, which simplifies to n(n-3)/2.
This page returns the total diagonal count along with the number leaving one vertex, the number of vertex pairs and the number of triangles obtained by cutting the polygon from one corner. The University of Texas exam solutions use the same endpoint argument: n non adjacent choices per vertex, divided by two because each diagonal has two ends.
The count depends only on n. A regular polygon and a lopsided polygon with the same number of sides have the same number of diagonals. The default example is the decagon, which the Florida handout also quotes as having 35 diagonals.
How to use
- Count the sides of your polygon. This is also the number of vertices.
- Enter that count as a whole number of 3 or more.
- Read the main result as the total number of diagonals.
- Use the per vertex figure when you need to know how many diagonals start at one corner.
- Compare the vertex pair count with the diagonal count: removing the sides from the pairs gives the diagonals.
- Use the triangle count when you plan to split the polygon into triangles from a single corner.
Formula
- D
- Total number of diagonals in the polygon.
- n
- Number of sides, equal to the number of vertices.
- n - 3
- Diagonals that leave any one vertex.
- n(n - 1)/2
- All pairs of vertices, including the n sides.
The recursive form is d(n) = d(n-1) + n - 2 with d(3) = 0, which builds each polygon by adding one vertex. Cutting an n-gon into triangles from one vertex gives n-2 triangles, one more than the n-3 diagonals leaving that vertex. The formula also works for concave polygons when a diagonal is defined as any segment between non adjacent vertices, even if part of it lies outside the shape.
Worked example
Example: a ten sided polygon
Default: n = 10 sides, a decagon.
- Enter n = 10 for a decagon.
- Diagonals from one vertex: n - 3 = 10 - 3 = 7.
- Across all 10 vertices that gives 10 x 7 = 70 endpoints, so D = 10 x 7/2 = 35 diagonals.
- Cross check with vertex pairs: 10 x 9/2 = 45 pairs, minus the 10 sides leaves 35 diagonals.
- Triangles from one corner: n - 2 = 10 - 2 = 8.
- The tool shows 35 diagonals, 7 per vertex, 45 vertex pairs and 8 triangles.
Reference table
| Sides n | Polygon | Diagonals | Per vertex |
|---|---|---|---|
| 3 | Triangle | 0 | 0 |
| 4 | Quadrilateral | 2 | 1 |
| 5 | Pentagon | 5 | 2 |
| 6 | Hexagon | 9 | 3 |
| 8 | Octagon | 20 | 5 |
| 10 | Decagon | 35 | 7 |
| 12 | Dodecagon | 54 | 9 |
Limits
- Counts straight segments between non adjacent vertices. It does not count the crossing points made when diagonals intersect.
- Assumes a simple polygon. A self intersecting star polygon has a different structure and needs separate treatment.
- For a concave polygon some counted diagonals lie outside the shape, but the total is unchanged.
- The input must be a whole number of sides of 3 or more, so a two sided figure has no meaning here.
Common mistakes
- Counting the sides as diagonals. Each vertex has n-3 diagonals, not n-1 connections.
- Forgetting to halve the product, which gives 70 for a decagon instead of 35.
- Writing n-1 in the formula where n-3 belongs.
- Assuming the polygon must be regular. The count does not depend on equal sides or equal angles.
- Treating crossing points inside the shape as additional diagonals.
Try it yourself
Quick checks. Answers sit tucked under each question.
How many diagonals does a hexagon have?
D = 6 x 3/2 = 9 diagonals, three from each vertex.
A polygon has 90 diagonals. How many sides does it have?
Solve n(n-3)/2 = 90, so n squared minus 3n minus 180 is zero and n = 15. Check: 15 x 12/2 = 90 diagonals.
How many more diagonals does a decagon have than a hexagon?
A decagon has 35 and a hexagon has 9, so the difference is 35 - 9 = 26 diagonals.
Questions
What is a diagonal of a polygon?
A segment joining two vertices that are not adjacent. The two sides meeting at a vertex are edges, not diagonals.
Why do we divide by two?
Each diagonal is counted once from each endpoint, so n(n-3) counts every diagonal twice.
Does the polygon have to be regular?
No. The count uses only the number of vertices, so a regular octagon and an irregular octagon both have 20 diagonals.
How many diagonals does a triangle have?
None. Substituting n = 3 gives 3 x 0/2 = 0, since every pair of vertices is already a side.
Do concave polygons have the same number?
Yes, provided a diagonal means any segment between non adjacent vertices. Some of those segments may lie partly outside the shape.
How does this relate to triangulation?
Drawing diagonals from one corner of an n-gon splits it into n-2 triangles, using n-3 diagonals from that corner.
Sources
- University of Florida, Number of Diagonals and Sub-Areas in Polygons
- University of Texas at Austin, CS 336 exam solutions: diagonals of a convex polygon
- Grand Valley State University, Mathematical Reasoning: Number of Diagonals of a Polygon