What is a Diagonal - Definition, Formula, and Examples

#Geometry
TL;DR
A diagonal is a straight line segment that joins two non-adjacent vertices (corners) of a polygon, never a side. The number of diagonals in any polygon with $n$ sides is given by the formula $\dfrac{n(n-3)}{2}$. This guide defines the diagonal, derives the counting formula, and works through examples for triangles up to hexagons and 3D solids.
BT
Bhanzu TeamLast updated on June 25, 202610 min read

What Is A Diagonal?

A diagonal is a line segment that connects two corners of a polygon that are not next to each other. A polygon's sides already join adjacent corners; a diagonal reaches across the shape to link corners that no side connects. The word comes from the Greek diagonios, "from angle to angle."

Two conditions define it, and both matter. A diagonal must (1) join two vertices, and (2) those vertices must be non-adjacent, meaning corners with no shared side. A line from a corner to the midpoint of a side is not a diagonal; neither is a side itself. Only corner-to-non-neighbouring-corner segments count.

Why Does A Triangle Have No Diagonals?

A triangle is the one polygon with zero diagonals, and seeing why locks in the definition. A triangle has three corners, and every corner is adjacent to the other two, so there is no pair of non-adjacent vertices to connect. Any line you draw between two corners of a triangle is already a side. With no non-adjacent corners, there is nothing for a diagonal to join.

This is the floor of the counting formula below: diagonals only appear once a polygon has four or more sides, because four is the first count that creates a pair of corners not joined by a side.

How Many Diagonals Does A Polygon Have? The Formula

The number of diagonals in a polygon with $n$ sides (and therefore $n$ vertices) is:

$$\text{Number of diagonals} = \frac{n(n-3)}{2}$$

Here $n$ is the number of sides. The formula works for any simple polygon, regular or irregular.

Where The Formula Comes From

The derivation is worth following once, because it explains both the $(n-3)$ and the division by 2.

  1. Start from one vertex. It can connect to $n - 1$ other vertices in total.

  2. Remove the sides. Of those, two are its immediate neighbours, and connecting to them gives sides, not diagonals. That leaves $n - 1 - 2 = n - 3$ diagonals from each vertex.

  3. Count over all vertices. With $n$ vertices each contributing $n - 3$ diagonals, that is $n(n - 3)$.

  4. Divide by 2. Each diagonal has been counted twice, once from each of its two endpoints, so halve the total.

$$\frac{n(n-3)}{2}$$

This is the single most useful result on the topic, and it is also exactly the kind of formula students "know" but cannot reconstruct under pressure, which is why the step-by-step above matters more than the boxed answer.

Number of Diagonals For Common Shapes

Feed each value of $n$ into $\frac{n(n-3)}{2}$:

Shape

Sides ($n$)

Diagonals

Triangle

3

0

Quadrilateral

4

2

Pentagon

5

5

Hexagon

6

9

Heptagon

7

14

Octagon

8

20

Decagon

10

35

So a hexagon has 9 diagonals; a quadrilateral, the family of squares, rectangles, and parallelograms, always has exactly 2.

Length of A Diagonal

Counting diagonals is one question; measuring one is another. For the regular shapes you meet most, the diagonal length comes straight from the Pythagorean theorem, because a diagonal usually splits the shape into right triangles.

Square, side $s$. The diagonal is the hypotenuse of a right triangle with both legs equal to $s$: $$d = s\sqrt{2}$$

Rectangle, length $l$ and width $w$. The diagonal is the hypotenuse of a right triangle with legs $l$ and $w$ (see the properties of a rectangle): $$d = \sqrt{l^2 + w^2}$$

A rhombus is the interesting case: its two diagonals are different lengths and cross at 90°, and you find them through the side using $\left(\frac{p}{2}\right)^2 + \left(\frac{q}{2}\right)^2 = a^2$.

Diagonals of 3D shapes

In three dimensions, "diagonal" splits into two kinds, and the distinction is a common point of confusion. A face diagonal lies on one flat face of the solid; it is just a 2D diagonal of that face. A space diagonal (or body diagonal) cuts through the interior of the solid, joining two corners that share neither a face nor an edge.

For a rectangular box (cuboid) with edges $l$, $w$, and $h$, the space diagonal extends the Pythagorean idea into 3D: $$d = \sqrt{l^2 + w^2 + h^2}$$

A cube of edge $a$ therefore has a space diagonal of $a\sqrt{3}$, while each of its face diagonals is $a\sqrt{2}$.

Examples of What is a Diagonal

Example 1

How many diagonals does an octagon (8 sides) have?

$$\frac{n(n-3)}{2} = \frac{8(8-3)}{2}$$ $$= \frac{8 \times 5}{2}$$ $$= \frac{40}{2}$$ $$= 20$$

Final answer: 20 diagonals.

Example 2

A student counts the diagonals of a pentagon by drawing 5 lines from each of its 5 corners, getting 25. Why is that wrong, and what is the right count?

First instinct: each of the 5 corners connects to 5 others, so $5 \times 5 = 25$. Let us see where it breaks. A corner cannot connect to itself, and two of its connections are sides, not diagonals, so it does not produce 5 diagonals. On top of that, the count joins every diagonal from both ends, doubling it.

The correct method: from each vertex there are $n - 3 = 5 - 3 = 2$ diagonals. Over 5 vertices that is $5 \times 2 = 10$, and dividing by 2 (each diagonal counted from both endpoints) gives:

$$\frac{5(5-3)}{2} = \frac{10}{2} = 5$$

Final answer: A pentagon has 5 diagonals, not 25.

Example 3

A polygon has 9 diagonals. How many sides does it have?

Set the formula equal to 9 and solve.

$$\frac{n(n-3)}{2} = 9$$ $$n(n-3) = 18$$ $$n^2 - 3n - 18 = 0$$ $$(n-6)(n+3) = 0$$ $$n = 6$$

(The negative root $n = -3$ is rejected, since a polygon can't have negative sides.)

Final answer: 6 sides, a hexagon.

Example 4

Find the length of the diagonal of a square with side 8 cm.

$$d = s\sqrt{2}$$ $$d = 8\sqrt{2}$$ $$d \approx 11.31 \text{ cm}$$

Final answer: $8\sqrt{2}$ cm, about 11.31 cm.

Example 5

Find the space diagonal of a box measuring 3 cm by 4 cm by 12 cm.

$$d = \sqrt{l^2 + w^2 + h^2}$$ $$d = \sqrt{3^2 + 4^2 + 12^2}$$ $$d = \sqrt{9 + 16 + 144}$$ $$d = \sqrt{169}$$ $$d = 13 \text{ cm}$$

Final answer: 13 cm.

Example 6

How many diagonals does a decagon (10 sides) have, and how many run from a single vertex?

Total diagonals: $$\frac{10(10-3)}{2} = \frac{70}{2} = 35$$

From a single vertex: $$n - 3 = 10 - 3 = 7$$

Final answer: 35 diagonals in total, 7 from each vertex.

Why Diagonals Matter

Diagonals are not just lines on a worksheet; they are how flat shapes are made rigid. A four-sided frame can be pushed into a leaning parallelogram, but add a diagonal brace and it locks: the diagonal turns the shape into two triangles, and a triangle cannot be deformed without changing a side length. This is why bridges, cranes, bicycle frames, and the back of a bookshelf all carry diagonal members. The diagonal is the cheapest way to make a structure hold its shape.

The space diagonal does similar work in three dimensions. The diagonal of a rectangular room tells a mover whether a long object will fit through a doorway or down a stairwell; the $\sqrt{l^2 + w^2 + h^2}$ formula answers "what is the longest straight thing that fits in this box?" Computer graphics use the same diagonal to wrap a shape in its bounding box before testing whether two objects collide. The diagonal is the longest reach across a shape, and a great deal of geometry is really the study of that longest reach.

Tripping Points To Avoid

Mistake 1: Counting sides as diagonals

Where it slips in: Drawing or counting diagonals straight from a figure, especially for the first few shapes.

Don't do this: Including the segments that join adjacent corners. The first instinct is to connect every pair of corners and call them all diagonals, but a segment between neighbouring corners is a side, not a diagonal.

The correct way: A diagonal joins only non-adjacent vertices. Before counting, mark which corners are neighbours (joined by a side) and exclude those connections. This is exactly why each vertex gives $n - 3$ diagonals, not $n - 1$.

Mistake 2: Forgetting to divide by 2

Where it slips in: Deriving the count by hand instead of using the boxed formula.

Don't do this: Stopping at $n(n - 3)$. The rusher multiplies vertices by diagonals-per-vertex and writes that down, but every diagonal has two endpoints, so it has been counted twice.

The correct way: Divide by 2. Each diagonal is shared between the two vertices it joins, so $n(n-3)$ double-counts every one. The formula $\frac{n(n-3)}{2}$ has the $\div 2$ built in for this reason.

Mistake 3: Confusing face and space diagonals in 3D

Where it slips in: Box and cube problems that ask for "the diagonal" without saying which.

Don't do this: Using $\sqrt{l^2 + w^2}$ (a face diagonal) when the question wants the longest internal diagonal of the solid.

The correct way: A face diagonal lies on one flat side and uses two dimensions; a space diagonal cuts through the interior and uses all three: $\sqrt{l^2 + w^2 + h^2}$. Read which one the problem wants before computing.

A real-world version of the count mistake: in network and circuit design, the number of direct links needed to connect every node to every other is the diagonal-plus-sides count. It grows like $\frac{n(n-1)}{2}$, and underestimating it (the same "forgot to account for every pair" slip) has led engineers to under-provision cabling. The famous case is the early ARPANET planning, where the explosion in the number of possible connections between sites forced a rethink of how nodes were linked, exactly the combinatorial growth the diagonal formula captures.

Conclusion

  • A diagonal joins two non-adjacent vertices of a polygon, never a side and never a corner-to-midpoint line.

  • A polygon with $n$ sides has $\frac{n(n-3)}{2}$ diagonals; a triangle has zero.

  • Each vertex contributes $n - 3$ diagonals, and the $\div 2$ removes the double-count.

  • Diagonal length comes from the Pythagorean theorem: $s\sqrt{2}$ for a square, $\sqrt{l^2 + w^2}$ for a rectangle.

  • In 3D, a face diagonal uses two dimensions; a space diagonal uses all three, $\sqrt{l^2 + w^2 + h^2}$.

A Practical Next Step

Practice these problems to solidify your understanding, mixing counting with measuring.

  1. How many diagonals does a heptagon (7 sides) have? (Answer to Question 1: 14)

  2. A polygon has 14 diagonals; how many sides does it have? (Answer to Question 2: 7)

  3. Find the diagonal of a rectangle 6 cm by 8 cm. (Answer to Question 3: 10 cm)

If you get stuck on Question 2, set $\frac{n(n-3)}{2} = 14$ and solve the resulting quadratic. To go deeper, read how diagonals behave in specific shapes: the diagonal of rhombus, the quadrilaterals family, and the diagonal of parallelogram formula.

Want a live Bhanzu trainer to walk through more diagonal problems and the counting formula? Book a free demo class.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is a diagonal in simple terms?
A diagonal is a straight line joining two corners of a shape that are not next to each other. Sides join neighbouring corners; diagonals reach across to the corners that no side connects.
How many diagonals does a polygon with n sides have?
Use $\frac{n(n-3)}{2}$. A hexagon ($n = 6$) has $\frac{6 \times 3}{2} = 9$; an octagon ($n = 8$) has 20. The formula divides by 2 because each diagonal is counted once from each of its two endpoints.
Why does a triangle have no diagonals?
Because all three of its corners are adjacent. Every pair of corners is already joined by a side, so there are no non-adjacent vertices left for a diagonal to connect.
What is the difference between a diagonal and a side?
A side joins two adjacent (neighbouring) corners and forms part of the shape's boundary. A diagonal joins two non-adjacent corners and cuts across the interior. A side is part of the outline; a diagonal is not.
How do you find the length of a diagonal?
For most regular shapes, the diagonal is the hypotenuse of a right triangle, so the Pythagorean theorem applies: a square gives $s\sqrt{2}$, a rectangle gives $\sqrt{l^2 + w^2}$, and a 3D box's space diagonal is $\sqrt{l^2 + w^2 + h^2}$.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →