Skip to main content

Right triangles and Pythagoras’ theorem

Why is the straight line from (1, 2) to (4, 6) exactly 5 long? Measure angles in degrees, see why the angles of a triangle add up to 180 degrees, prove Pythagoras’ theorem by arranging four triangles in a square, and meet the two special triangles of trigonometry.
M01.2.2L0 Foundation25 minIn review

Before this lesson

M01.2.1 The coordinate plane M01.1.2 Expressions and the rules of algebra

After this lesson you can

  • State the number of degrees in a full turn, a half turn and a right angle, and explain with a parallel line why the angles of a triangle add up to 180 degrees.
  • Name the legs and the hypotenuse of a right triangle and state Pythagoras’ theorem.
  • Prove Pythagoras’ theorem by arranging four copies of a right triangle in a square and counting its area in two ways.
  • Find a missing side of a right triangle, including the sides of half a square and of half an equilateral triangle.

In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.

The question

In the last lesson the walk from \({P = (1, 2)}\) to \({Q = (4, 6)}\) was 3 across and then 4 up: 7 steps along the grid. A bird flying straight from \(P\) to \(Q\) covers less ground. Measure the straight line with a ruler and you get 5, exactly. Why 5? Is there a rule that turns any two changes into a straight-line distance? There is, and the nearest-neighbour methods of machine learning (ML01.3) use it over and over.

From the last lesson

1. What are the horizontal and the vertical change from \((4, 6)\) to \((1, 2)\)?

Show answer

End minus start:

\[ \begin{aligned} 1 - 4 &= -3 \text{ across}, \\ 2 - 6 &= -4 \text{ up}. \end{aligned} \]

That is 3 to the left and 4 down.

2. What is the midpoint of \({(-2, 5)}\) and \((4, 1)\)?

Show answer

Average each coordinate:

\[ \begin{aligned} \frac{-2 + 4}{2} &= 1, \\ \frac{5 + 1}{2} &= 3, \end{aligned} \]

so the midpoint is \((1, 3)\).

Intuition

Draw the walk from \(P\) to \(Q\): 3 across, then 4 up. The two moves meet in a square corner. Add the straight line from \(P\) to \(Q\) and you have a triangle with a square corner, a right triangle. The question “how far is it from \(P\) to \(Q\)?” has become “how long is the third side of a right triangle whose other two sides are 3 and 4?”

Now build a square on each side of the triangle. The square on the side of length 3 holds 9 unit squares. The square on the side of length 4 holds 16. The square on the long side holds 25, and

\[ 9 + 16 = 25 . \]

A square of area 25 has sides of length 5, because \({5^2 = 25}\). That is why the ruler says 5.

A right triangle with a horizontal side of length 3, an upright side of length 4 and a slanted long side of length 5, with a small square marking the right angle. A square is built outward on each side and divided into unit cells: a blue square of 9 cells below the side labelled a = 3, a sky-blue square of 16 cells to the right of the side labelled b = 4, and a tilted vermillion square of 25 cells on the long side labelled c = 5. The words 9 + 16 = 25 sit in the empty corner.
M01.2.2-F1

The squares on the two short sides of a right triangle together have the same area as the square on the long side: \({9 + 16 = 25}\).

That the two smaller squares exactly fill the big one is Pythagoras’ theorem. It is not a lucky property of 3, 4 and 5. It holds for every right triangle, and this lesson proves it. First we need angles, because “right triangle” is a statement about an angle.

Build it up

Step 1. Angles in degrees. An angle measures a turn. A full turn, all the way round, is 360 degrees, written \(360^\circ\). Half a turn is \(180^\circ\): it turns you to face the opposite way, so the two arms of a \(180^\circ\) angle make one straight line. A quarter turn is \(90^\circ\), the corner of a square, called a right angle and marked with a small square.

Step 2. The angles of a triangle add up to \(180^\circ\). Take any triangle with corners \(A\), \(B\) and \(C\), and call its angles \(\alpha\), \(\beta\) and \(\gamma\) (the Greek letters alpha, beta and gamma of M01.1.4). Draw the line through \(C\) that is parallel to the side \(AB\). Where a straight line crosses two parallel lines, the two angles it makes on opposite sides, in the shape of a Z, are equal. These are called alternate angles. So a copy of \(\alpha\) appears at \(C\), between the new line and the side \(CA\), and a copy of \(\beta\) appears between the new line and the side \(CB\).

Two panels showing the same triangle with corners A and B on a horizontal base and C at the top. Left panel, titled Three angles: the angles are shaded at each corner, blue alpha at A, sky-blue beta at B and orange gamma at C. Right panel, titled A parallel line through C: a green line through C runs parallel to the base. Just below it, at C, a blue copy of alpha, the orange gamma and a sky-blue copy of beta sit side by side and fill the straight line. The label reads alpha + gamma + beta = 180 degrees.
M01.2.2-F2

Left: the three angles of a triangle. Right: the line through \(C\) parallel to \(AB\) carries a copy of \(\alpha\) and a copy of \(\beta\) up to \(C\). Side by side with \(\gamma\) they fill a straight line, so they add up to \(180^\circ\).

At \(C\) the three angles \(\alpha\), \(\gamma\) and \(\beta\) sit side by side along the straight line, so

\[ \alpha + \beta + \gamma = 180^\circ . \]

Step 3. Right triangles. In a right triangle one angle is \(90^\circ\). The other two therefore add up to \({180^\circ - 90^\circ}\), which is \(90^\circ\). The two sides that make the right angle are the legs. The side opposite the right angle is the hypotenuse.

Step 4. Squares on the sides. For the 3-4-5 triangle the squares on the legs add up to the square on the hypotenuse. Try another right triangle, with legs 5 and 12. Its hypotenuse measures 13, and

\[ 5^2 + 12^2 = 25 + 144 = 169 = 13^2 . \]

Two examples agree. Examples are evidence, not proof, so we now prove it for every right triangle.

The formal statement

NoteTheorem: Pythagoras

In a right triangle with legs of lengths \(a\) and \(b\) and a hypotenuse of length \(c\),

\[ a^2 + b^2 = c^2 . \]

Since \(c\) is a length, it is the positive square root: \({c = \sqrt{a^2 + b^2}}\).

The proof. Take four copies of the triangle. Place them inside a square whose side is \({a + b}\), one in each corner with its right angle in that corner, each turned a quarter turn further than the one before. Every side of the square then holds one leg of length \(a\) followed by one leg of length \(b\), which fill that side exactly.

Two panels, each a large square with sides marked a and b. Left panel, titled Way 1: four triangles and c squared. Four grey right triangles sit in the four corners, and their long sides enclose a tilted vermillion square labelled c squared, with sides c. At one point on the bottom edge, where two triangles meet, the two triangle angles are shaded blue and sky blue and the corner of the tilted square between them is marked as a right angle. Right panel, titled Way 2: a squared, b squared and four triangles. The same large square is cut into a blue square a squared in the bottom left, a sky-blue square b squared in the top right, and two rectangles a by b, each split by a dashed diagonal into two grey triangles.
M01.2.2-F3

The same square of side \({a + b}\), filled in two ways. Left: four triangles and a tilted square on the hypotenuse. Right: the cut-up square of M01.1.2, whose two rectangles split into the same four triangles. What the triangles leave uncovered is \(c^2\) on the left and \({a^2 + b^2}\) on the right.

The four long sides enclose a square. Each side of the inner shape is a hypotenuse, so all four sides have length \(c\). For its corners, look at a point where two triangles meet on a side of the big square. Three angles meet there along a straight line, so they add up to \(180^\circ\): an angle of one triangle, a corner of the inner shape and an angle of the other triangle. One triangle meets the point where its leg \(a\) ends, the other where its leg \(b\) starts, so the two triangle angles are the triangle’s two angles that are not the right angle. By Step 3 they add up to \(90^\circ\). So the corner of the inner shape is \({180^\circ - 90^\circ}\), a right angle. Four equal sides and four right angles make a square, with area \(c^2\).

Count the area of the big square in two ways. Each triangle is half of a rectangle \(a\) by \(b\), so its area is \(\tfrac{1}{2}ab\). The left panel gives

\[ \begin{aligned} (a + b)^2 &= 4 \times \tfrac{1}{2}ab + c^2 \\ &= 2ab + c^2 . \end{aligned} \]

The right panel is the expansion of M01.1.2:

\[ (a + b)^2 = a^2 + 2ab + b^2 . \]

Both count the same area, so the two right-hand sides are equal. Take \(2ab\) from both sides:

\[ \begin{aligned} a^2 + 2ab + b^2 &= 2ab + c^2 \\ a^2 + b^2 &= c^2 . \end{aligned} \]

That proves the theorem. In words: the same four triangles leave the same area uncovered, \(c^2\) in one arrangement and \({a^2 + b^2}\) in the other.

Go deeper: the parallel line, and a world where it fails

Step 2 used one fact about parallel lines: a line that crosses two parallel lines makes equal alternate angles. Euclid proves it as Proposition 29 of Book I of the Elements, and it is the first result there that needs his fifth postulate, the one about parallel lines. Proposition 32 then proves the angle sum with the same parallel line through \(C\), and Proposition 47 is Pythagoras’ theorem.

On a globe the straightest paths are great circles, such as the equator, and any two great circles cross, so there are no parallel lines at all. Both results fail there. Take a triangle with one corner at the North Pole and two on the equator, a quarter of the way round from each other. All three of its angles are right angles, so they add up to \(270^\circ\), not \(180^\circ\). All three sides are the same length, so \({a^2 + b^2 = c^2}\) fails too. The flat plane of this course is the world where both results hold.

Worked example

Three right triangles, solved.

The 3-4-5 triangle. With legs 3 and 4,

\[ \begin{aligned} c &= \sqrt{3^2 + 4^2} = \sqrt{9 + 16} \\ &= \sqrt{25} = 5 . \end{aligned} \]

Half a square. Cut a square of side 1 along a diagonal. Each half is a right triangle: its legs are two sides of the square, both 1, meeting in the square’s corner. Its other two angles are equal, because the half folds onto itself along the line through that corner and the middle of the diagonal, and by Step 3 they add up to \(90^\circ\), so each is \(45^\circ\). The hypotenuse is the diagonal:

\[ \begin{aligned} c^2 &= 1^2 + 1^2 = 2, \\ c &= \sqrt{2} \approx 1.4142 . \end{aligned} \]

Half an equilateral triangle. An equilateral triangle has three equal sides. Take sides of length 2. It looks the same from each corner, so its three angles are equal, and since they add up to \(180^\circ\) each is \(60^\circ\). Cut it in half with the line from the top corner to the middle of the base. Folding along that line swaps the two halves, so the cut meets the base at two equal angles that make a straight line, \(90^\circ\) each. Each half is a right triangle with hypotenuse 2, a short leg of 1 (half the base) and angles of \(30^\circ\), \(60^\circ\) and \(90^\circ\). Its tall leg \(h\) comes from the theorem:

\[ \begin{aligned} 1^2 + h^2 &= 2^2 \\ h^2 &= 4 - 1 = 3 \\ h &= \sqrt{3} \approx 1.7321 . \end{aligned} \]

Two panels. Left panel, titled Half a square: a square of side 1 drawn dashed, cut along its diagonal. The lower half is shaded: a right triangle with legs 1 and 1, angles of 45 degrees at both ends of the diagonal, and the diagonal labelled square root of 2, about 1.4142. Right panel, titled Half an equilateral triangle: an equilateral triangle with sides 2, cut by a dashed upright line from its top corner to the middle of its base. The right half is shaded: a right triangle with hypotenuse 2, base 1 and tall side labelled square root of 3, about 1.7321, with angles of 60 degrees at the base corner and 30 degrees at the top.
M01.2.2-F4

The two special triangles. Half a square has sides \(1\), \(1\), \(\sqrt{2}\) and angles \(45^\circ\), \(45^\circ\), \(90^\circ\). Half an equilateral triangle has sides \(1\), \(\sqrt{3}\), \(2\) and angles \(30^\circ\), \(60^\circ\), \(90^\circ\).

Keep these two triangles. Lesson M01.5.1 reads the exact sine and cosine of \(30^\circ\), \(45^\circ\) and \(60^\circ\) straight off their sides.

Code

From scratch first: the theorem as a function, with math.sqrt for the square root (importing a module is P01.5.1).

import math

def hypotenuse(a, b):
    """The long side of a right triangle whose legs are a and b."""
    return math.sqrt(a ** 2 + b ** 2)     # c is the square root of a squared plus b squared

print("3-4-5:", hypotenuse(3, 4))
print("half a square:", round(hypotenuse(1, 1), 4))
print("tall leg of half an equilateral triangle:", round(math.sqrt(2 ** 2 - 1 ** 2), 4))
3-4-5: 5.0
half a square: 1.4142
tall leg of half an equilateral triangle: 1.7321

The proof counted the big square in two ways. A loop can compare the two counts for a few triangles. This is evidence, not proof, and the two counts may differ in the last digit, because a float is an approximation (M01.1.1), so they are compared with math.isclose.

for a, b in [(3, 4), (1, 1), (1, 2.5), (0.3, 7)]:
    c = hypotenuse(a, b)
    big_square = (a + b) ** 2                  # the area of the square of side a + b
    four_and_inner = 4 * (a * b / 2) + c ** 2  # four triangles plus the inner square
    print(a, b, round(big_square, 4), round(four_and_inner, 4),
          math.isclose(big_square, four_and_inner))
3 4 49 49.0 True
1 1 4 4.0 True
1 2.5 12.25 12.25 True
0.3 7 53.29 53.29 True

The library has the theorem built in. math.hypot(a, b) returns \({\sqrt{a^2 + b^2}}\); its documentation calls it the hypotenuse of a right triangle.

print(math.hypot(3, 4), math.hypot(5, 12))
5.0 13.0

This one line is behind every distance in the next lesson, and so behind the nearest-neighbour methods of ML01.3, which compare a new example with stored ones by exactly this kind of distance.

Explore

The module’s interactive, the point and arrow explorer, lives in lesson M01.2.4. Drag its two points and the right triangle between them redraws, with its two legs and its hypotenuse given as numbers.

Pitfalls

Two panels showing the same right triangle with legs 3 and 4. The left panel is marked with a cross and titled Add the sides: wrong. Its two legs are drawn thick in purple and labelled 3 + 4 = 7, and a dashed purple line of length 7 runs from the start along the direction of the long side, overshooting the far corner, labelled 7 overshoots. The right panel is marked with a tick and titled Add the squares: right. Its long side is drawn thick in vermillion and labelled the square root of 3 squared plus 4 squared equals 5.
M01.2.2-F5

Wrong beside right. Adding the two legs measures the walk round the corner, 7, which is longer than the straight side. Adding their squares gives the square of the straight side.

“The hypotenuse is the two legs added: \({3 + 4 = 7}\).”

That is the length of the walk round the corner, and the straight line is shorter: 5. Add the squares, then take the square root. The walk along the legs is a real distance too, the Manhattan distance of ML01.3.3, named after the grid of streets a taxi has to follow. It is just not the straight-line distance.

“\({\sqrt{9 + 16}}\) is \({\sqrt{9} + \sqrt{16}}\).”

A square root does not split over a sum:

\[ \begin{aligned} \sqrt{9 + 16} &= \sqrt{25} = 5, \\ \sqrt{9} + \sqrt{16} &= 3 + 4 = 7 . \end{aligned} \]

“Pythagoras’ theorem works for every triangle.”

Only for right triangles. An equilateral triangle with sides of 2 fails it:

\[ 2^2 + 2^2 = 8, \quad\text{but}\quad 2^2 = 4 . \]

The law of cosines in M01.5.4 deals with the other triangles.

“\(c\) is whichever side is unknown.”

\(c\) is always the hypotenuse, the side opposite the right angle. If the hypotenuse is 13 and one leg is 5, the other leg comes from

\[ \begin{aligned} b^2 &= 13^2 - 5^2 = 144, \\ b &= 12 . \end{aligned} \]

Adding the squares instead gives \({\sqrt{194} \approx 13.9284}\), a “leg” longer than the hypotenuse. That cannot be, because the hypotenuse is the longest side: \(c^2\) is \(a^2\) plus something positive.

Check yourself

Recall

1. How many degrees are there in a full turn, in a half turn and in a right angle?

Show answer

\(360^\circ\), \(180^\circ\) and \(90^\circ\).

2. A triangle has angles of \(50^\circ\) and \(70^\circ\). What is its third angle?

Show answer

The three add up to \(180^\circ\), so the third is

\[ 180^\circ - 50^\circ - 70^\circ = 60^\circ . \]

3. Which side of a right triangle is the hypotenuse?

Show answer

The side opposite the right angle. It is the longest side.

4. A right triangle has legs 6 and 8. How long is its hypotenuse?

Show answer

\[ c = \sqrt{36 + 64} = \sqrt{100} = 10 . \]

5. What are the sides of half a square of side 1, and of half an equilateral triangle of side 2?

Show answer

Half a square: \(1\), \(1\) and \(\sqrt{2}\). Half an equilateral triangle: \(1\), \(\sqrt{3}\) and \(2\).

Exercises

1. ★ A right triangle has legs 5 and 12. Find its hypotenuse. Another right triangle has an angle of \(35^\circ\). Find its third angle.

Show solution

\[ \begin{aligned} c &= \sqrt{25 + 144} \\ &= \sqrt{169} = 13 . \end{aligned} \]

The second triangle has a right angle and an angle of \(35^\circ\), and its angles add up to \(180^\circ\), so its third angle is

\[ 180^\circ - 90^\circ - 35^\circ = 55^\circ . \]

2. ★★ A ladder 5 metres long leans against an upright wall, with its foot 3 metres from the wall. How high up the wall does it reach?

Show solution

The wall and the ground meet at a right angle, so the ladder is the hypotenuse, \({c = 5}\), and the ground is one leg, \({a = 3}\). Take \(a^2\) from both sides of the theorem to find the other leg:

\[ \begin{aligned} b^2 &= c^2 - a^2 = 25 - 9 = 16, \\ b &= 4 . \end{aligned} \]

The ladder reaches 4 metres up the wall: a 3-4-5 triangle again.

3. ★★★ An equilateral triangle has sides of length 6. Find its height and its area, to four decimal places.

Show solution

Cut it in half from the top corner to the middle of the base, as in the worked example. Each half is a right triangle with hypotenuse 6 and short leg 3, so the height \(h\) satisfies

\[ \begin{aligned} 3^2 + h^2 &= 6^2 \\ h^2 &= 36 - 9 = 27 \\ h &= \sqrt{27} \approx 5.1962 . \end{aligned} \]

A check: this triangle is the one of the worked example with every length multiplied by 3, so \(h\) should be \(3\sqrt{3}\). Indeed,

\[ (3\sqrt{3})^2 = 9 \times 3 = 27 . \]

Each half is half of a rectangle 3 by \(h\), so its area is \({\tfrac{1}{2} \times 3h}\). The two halves together have area

\[ 3h = 3\sqrt{27} \approx 15.5885 . \]

Summary card

In a right triangle, the squares on the legs add up to the square on the hypotenuse.

The anchor figure again: a right triangle with sides 3, 4 and 5, with squares of 9, 16 and 25 unit cells built on its sides.
M01.2.2-F1

Nine plus sixteen is twenty-five.

  • Turns: a full turn is \(360^\circ\), a right angle \(90^\circ\); a triangle’s angles add up to \(180^\circ\).
  • Pythagoras: \({a^2 + b^2 = c^2}\), with \(c\) the side opposite the right angle.
  • The long side: \({c = \sqrt{a^2 + b^2}}\); in Python, math.hypot(a, b).
  • Special triangles: \(1, 1, \sqrt{2}\) and \(1, \sqrt{3}, 2\).

Sources and next steps

Sources. Each was opened and checked against this lesson on 12 November 2026.

  • Euclid, Elements, Book I, in David E. Joyce’s online edition (Clark University): Proposition 29 (a line falling on parallel lines makes the alternate angles equal; the commentary notes it is the first proposition that depends on the parallel postulate), Proposition 32 (the three angles of a triangle equal two right angles, proved with a parallel line through one corner) and Proposition 47 (Pythagoras’ theorem). Joyce’s commentary on Proposition 47 describes the hypotenuse diagram of the Chinese Zhou bi suan jing: four right triangles with legs 3 and 4 round a tilted square inside a 7-by-7 square, whose area is 49 less four triangles of 6, so 25. It is this lesson’s proof drawn for the 3-4-5 triangle.
  • Alexander Bogomolny, Pythagorean Theorem and its many proofs, Cut the Knot, Proof 4: four triangles form a square of side \({a + b}\) with a hole of side \(c\), and the area of that square is counted as four triangles of area \(ab/2\) plus the hole, \(c^2\).
  • OpenStax, Prealgebra 2e, Section 9.3. The angles of any triangle sum to \(180^\circ\); the side opposite the right angle is the hypotenuse and the other two are the legs; the theorem \({a^2 + b^2 = c^2}\).
  • Python 3.12 documentation, the math module: math.sqrt, and math.hypot, which for a point \((x, y)\) is “the hypotenuse of a right triangle using the Pythagorean theorem”.

Next. M01.2.3 Distance, from the plane to many dimensions turns this theorem into the distance between any two points.

This lesson unlocks

M01.2.3 Distance, from the plane to many dimensions M01.5.1 Sine, cosine and tangent as ratios

Your progress is saved in this browser only. No account, no tracking.
Back to top