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.
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)\)?
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.
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\).
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.
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
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.
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:
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:
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 mathdef 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 squaredprint("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 squareprint(a, b, round(big_square, 4), round(four_and_inner, 4), math.isclose(big_square, four_and_inner))
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
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}}\).”
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
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:
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
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.
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”.