Mathwords logoMathwords

Diagonal of a Polygon — Definition, Formula & Examples

Diagonal of a Polygon

A line segment connecting non-adjacent vertices of a polygon. Note: An n-gon has The formula n(n-3)/2, where n represents the number of sides of a polygon. diagonals.

 

Pentagon with one diagonal drawn in red connecting two non-adjacent vertices, labeled "diagonal

Key Formula

D=n(n3)2D = \frac{n(n-3)}{2}
Where:
  • DD = Total number of diagonals in the polygon
  • nn = Number of sides (or equivalently, number of vertices) of the polygon

Worked Example

Problem: How many diagonals does a hexagon (6-sided polygon) have?
Step 1: Identify the number of sides. A hexagon has 6 sides, so n = 6.
n=6n = 6
Step 2: Substitute n = 6 into the diagonal formula.
D=6(63)2D = \frac{6(6-3)}{2}
Step 3: Simplify the expression inside the parentheses: 6 − 3 = 3.
D=6×32D = \frac{6 \times 3}{2}
Step 4: Multiply and divide to get the final result.
D=182=9D = \frac{18}{2} = 9
Answer: A hexagon has 9 diagonals.

Another Example

This example works the formula in reverse — given the number of diagonals, you find the number of sides by solving a quadratic equation.

Problem: A polygon has exactly 20 diagonals. How many sides does it have?
Step 1: Set the diagonal formula equal to 20 and solve for n.
n(n3)2=20\frac{n(n-3)}{2} = 20
Step 2: Multiply both sides by 2 to clear the fraction.
n(n3)=40n(n-3) = 40
Step 3: Expand and rearrange into a standard quadratic equation.
n23n40=0n^2 - 3n - 40 = 0
Step 4: Factor the quadratic. You need two numbers that multiply to −40 and add to −3. Those are −8 and 5.
(n8)(n+5)=0(n - 8)(n + 5) = 0
Step 5: Solve for n. Since n must be a positive integer, discard the negative solution.
n=8(rejecting n=5)n = 8 \quad \text{(rejecting } n = -5\text{)}
Answer: The polygon has 8 sides (it is an octagon).

Frequently Asked Questions

Why does a triangle have zero diagonals?
A triangle has 3 vertices, and every vertex is adjacent to both of the other vertices. Since a diagonal must connect non-adjacent vertices, there are no possible diagonals. You can verify this with the formula: D = 3(3 − 3)/2 = 0.
How do you derive the diagonal formula n(n − 3)/2?
From any single vertex of an n-gon, you can draw a line segment to n − 1 other vertices. However, 2 of those are adjacent vertices (connected by a side), so each vertex contributes n − 3 diagonals. With n vertices, that gives n(n − 3) counted segments, but each diagonal has been counted twice (once from each endpoint), so you divide by 2 to get n(n − 3)/2.
What is the difference between a diagonal and a side of a polygon?
A side connects two adjacent (neighboring) vertices, forming part of the polygon's boundary. A diagonal connects two non-adjacent vertices and lies in the interior of a convex polygon. Every n-gon has exactly n sides but n(n − 3)/2 diagonals.

Diagonal of a Polygon vs. Side of a Polygon

Diagonal of a PolygonSide of a Polygon
DefinitionLine segment connecting two non-adjacent verticesLine segment connecting two adjacent vertices
Count in an n-gonn(n − 3)/2n
PositionPasses through the interior (in convex polygons)Forms the boundary of the polygon
Exists in a triangle?No (0 diagonals)Yes (3 sides)

Why It Matters

Counting diagonals is a classic problem in combinatorics and geometry courses, often used to introduce quadratic formulas and systematic counting techniques. Diagonals also play a practical role: drawing all diagonals from one vertex of a polygon divides it into triangles, which is the basis of polygon triangulation — a key technique for computing area and used extensively in computer graphics. You will encounter diagonals again when studying interior angle sums, since an n-gon splits into n − 2 triangles using non-crossing diagonals from a single vertex.

Common Mistakes

Mistake: Using n(n − 1)/2 instead of n(n − 3)/2.
Correction: The expression n(n − 1)/2 counts all line segments between n vertices (including the n sides). You must subtract the n sides to get only diagonals: n(n − 1)/2 − n = n(n − 3)/2. Always use (n − 3) in the numerator, not (n − 1).
Mistake: Forgetting to divide by 2 and writing n(n − 3) as the answer.
Correction: Each diagonal has two endpoints, so it gets counted once from each end. You must divide by 2 to avoid double-counting. For example, in a pentagon: 5 × 2 = 10 is wrong; the correct count is 5 × 2 / 2 = 5 diagonals.

Related Terms

  • Line SegmentA diagonal is a specific type of line segment
  • Non-AdjacentDiagonals connect non-adjacent vertices
  • VertexEndpoints of every diagonal
  • PolygonThe shape in which diagonals are drawn
  • n-gonGeneral polygon with n sides used in the formula
  • Convex PolygonAll diagonals lie inside a convex polygon
  • TriangulationDiagonals divide polygons into triangles
  • CombinationDiagonal count uses combinatorial reasoning