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:

a2+b2=c2
A right triangle with legs 3 and 4 and hypotenuse 5. A blue 3 by 3 square of 9 unit cells hangs below leg a, an orange 4 by 4 square of 16 cells sits left of leg b, and a tilted green square of 25 cells sits on the hypotenuse
On the 3-4-5 triangle the squares hold 9, 16 and 25 unit cells, and 9 + 16 = 25.

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).

Two 7 by 7 squares. Left: four purple triangles in the corners leave a tilted green square labelled c squared = 25 in the middle. Right: the same four triangles form two 3 by 4 rectangles, leaving a blue 3 by 3 square a squared = 9 and an orange 4 by 4 square b squared = 16
The same four triangles in the same (a + b) square leave c² uncovered in one arrangement and a² + b² in the other.

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:

pieceratioso3-4-5
left triangle (side a)p / a = a / ca² = c·p9 = 5 × 1.8
right triangle (side b)q / b = b / cb² = c·q16 = 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

d=Δx2+Δy2

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, nm² − n²2mnm² + n²
2, 1345
3, 251213
4, 115817
4, 372425

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:

Three triangles with sides a = 3 and b = 4. Acute, gamma = 60 degrees: c squared = 13, less than 25. Right, gamma = 90 degrees: c squared = 25. Obtuse, gamma = 120 degrees: c squared = 37, more than 25
Same a and b: c² is less than, equal to or more than a² + b² as the angle between them is acute, right or obtuse.
angle γcompare3, 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:

c2=a2+b2−2abcosγ

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.