The idea: three squares, one equation
A right triangle has one 90° angle. The two sides that meet there are the legs a and b; the long side across from the right angle is the hypotenuse c. Build a square on each side. The Pythagorean theorem says the two small squares together have exactly the area of the big one:
With legs 3 and 4 the squares hold 9 and 16 unit cells, and the tilted square on the hypotenuse holds 25, so c = 5 (Demo: squares on 3-4-5). For legs 1 and 2 the big square has area 5 and c = √5 ≈ 2.24: the theorem still holds, but c is not a whole number. Turned around, the theorem finds any side from the other two: c = √(a² + b²) and a = √(c² − b²).
Proof 1: rearrange four triangles
Take a square of side a + b and four copies of the triangle. Put one copy in each corner, each turned a quarter turn from the last: the uncovered middle is a tilted square of side c, area c². Now slide three of the tiles (no turning) so they pair up into two a × b rectangles: the uncovered part is now a square a² and a square b². Same big square, same four tiles, so the uncovered areas are equal: c² = a² + b² (Demo: rearrangement proof).
In numbers, for 3-4-5: the big square is 7² = 49, the four tiles cover 4 × 6 = 24, and both arrangements leave 25. The algebra version is (a + b)² − 2ab = a² + b². More algebra read off areas like this (the square of a sum, the difference of squares, AM ≥ GM) is on the proofs without words page.
Proof 2: similar triangles (Euclid's figure)
Lay the hypotenuse flat and drop the altitude from the right angle to it. It cuts c into two parts p and q and the triangle into two smaller ones. Each small triangle has the same angles as the whole one (they share an angle and both have a right angle), so they are similar and their sides are in the same ratio:
| piece | ratio | so | 3-4-5 |
|---|---|---|---|
| left triangle (side a) | p / a = a / c | a² = c·p | 9 = 5 × 1.8 |
| right triangle (side b) | q / b = b / c | b² = c·q | 16 = 5 × 3.2 |
Extend the altitude down through the square on c: it splits that square into a c × p rectangle with the area of a² and a c × q rectangle with the area of b². Adding them, a² + b² = c(p + q) = c² (Demo: similar triangles proof). This is the figure of Euclid's Elements I.47, where the same equal areas are shown by shearing triangles instead.
The distance formula
Two points P = (x₁, y₁) and Q = (x₂, y₂) are the ends of a hypotenuse whose legs are the horizontal step Δx = x₂ − x₁ and the vertical step Δy = y₂ − y₁. So the straight-line distance is
From (1, 1) to (7, 9): Δx = 6, Δy = 8, d = √100 = 10 (Demo: distance between two points). In 3D, apply the theorem twice: d = √(Δx² + Δy² + Δz²), and in n dimensions keep adding squares. This Euclidean distance is the length of the vector Q − P, |v| = √(v·v) (see vectors and the dot product), and it is the distance k-nearest neighbours uses to find the closest training points.
Pythagorean triples
A Pythagorean triple is three whole numbers with a² + b² = c²: 3-4-5, 5-12-13, 8-15-17, 7-24-25, … Any multiple of a triple is a triple (6-8-10 is 3-4-5 doubled: the same shape), so the interesting ones are the primitive triples with no common factor (Demo: Pythagorean triples). Euclid's formula produces all of them: pick whole numbers m > n > 0, then
| m, n | m² − n² | 2mn | m² + n² |
|---|---|---|---|
| 2, 1 | 3 | 4 | 5 |
| 3, 2 | 5 | 12 | 13 |
| 4, 1 | 15 | 8 | 17 |
| 4, 3 | 7 | 24 | 25 |
It works because (m² − n²)² + (2mn)² = m⁴ + 2m²n² + n⁴ = (m² + n²)². Builders have used the 3-4-5 rope (12 equal knots) to lay out right angles for thousands of years.
When the angle is not 90°: the law of cosines
Keep a = 3 and b = 4 but change the angle γ between them. Closing the angle pulls the ends together, opening it pushes them apart:
| angle γ | compare | 3, 4 example |
|---|---|---|
| acute, γ < 90° | c² < a² + b² | γ = 60°: c² = 13 |
| right, γ = 90° | c² = a² + b² | c² = 25 |
| obtuse, γ > 90° | c² > a² + b² | γ = 120°: c² = 37 |
The exact gap is the law of cosines:
Drop the far end B straight onto the line of side b: the foot is a cos γ from the corner, and applying Pythagoras to the two right triangles that appear gives the formula. At 60°, cos γ = 0.5 and c² = 25 − 24 × 0.5 = 13; at 120°, cos γ = −0.5 and c² = 25 + 12 = 37 (Demo: angle not 90°). At 90°, cos γ = 0 and the law of cosines is just Pythagoras. The cosine here is the one from the unit circle, and in vector form the same identity is |a − b|² = |a|² + |b|² − 2 a·b (dot product). The converse is useful too: if a² + b² = c² then the angle is exactly 90°.
Every right triangle fits in a circle with its hypotenuse as a diameter (Thales, on the circle theorems page), so the midpoint of the hypotenuse is the circumcentre; where the other centres sit is on the triangle centres page.
What the page leaves out
Only a few leg lengths are drawn, and only two of the hundreds of known proofs (others use shearing, dissections such as Perigal's, or algebra with the area of a trapezoid). The page does not cover the converse proof, distance on curved surfaces (great circles) or other metrics such as Manhattan distance, Fermat's Last Theorem (no whole solutions to aⁿ + bⁿ = cⁿ for n > 2), or the generalisation to inner-product spaces. See also complex numbers, where |x + iy| = √(x² + y²) is this same distance.