The Pythagorean theorem is the oldest piece of mathematics most people still use: it turns the lengths of two sides of a right triangle into the third, and with it every distance in a plane or in space. This page proves it twice, proves its converse, finds all whole-number solutions and shows what replaces it when the angle is not right.

Statement

The Pythagorean theorem states that for a right triangle with legs aa and bb and hypotenuse cc:

a2+b2=c2a^2 + b^2 = c^2

The hypotenuse is the side opposite the right angle, and always the longest side. The legs are the two sides that form the right angle. Read as areas, the theorem says that the square built on the hypotenuse has exactly the area of the two squares built on the legs together — which is how Euclid states it in Proposition 47 of Book I of the Elements.

Proof by area rearrangement

Consider a large square with side length (a+b)(a + b). Its total area is (a+b)2(a + b)^2.

Place four identical right triangles (each with area ab2\frac{ab}{2}) inside this square. The remaining area equals:

(a+b)2−4⋅ab2=a2+2ab+b2−2ab=a2+b2(a + b)^2 - 4 \cdot \frac{ab}{2} = a^2 + 2ab + b^2 - 2ab = a^2 + b^2

In the first configuration, the remaining area forms a single square with side cc, so the remaining area is c2c^2.

In the second configuration, the remaining area forms two squares with sides aa and bb, so the remaining area is a2+b2a^2 + b^2.

Since both equal the same remaining area: a2+b2=c2a^2 + b^2 = c^2. ■\blacksquare

One step deserves a check rather than a glance: that the hole in the first configuration really is a square. Its four sides are hypotenuses, so they all have length cc. At each corner of the hole, the angles α\alpha and β\beta of two neighbouring triangles meet the hole's own angle along a straight side of the big square, so that angle is 180∘−α−β180^\circ - \alpha - \beta. The acute angles of a right triangle add up to 90∘90^\circ, so every angle of the hole is 90∘90^\circ: it is a square of side cc. A "visual proof" is a proof only when every such step can be justified like this.

Step through the rearrangement one triangle at a time, or click the square to move the next triangle. Drag the dot on the bottom edge to try other legs aa and bb — the numbers change, the equality does not:

A square of side a + b holding four copies of one right triangle, moved one triangle at a time from around the hypotenuse into two rectangles: the uncovered area is first one square of side c, then two squares of sides a and b, and it never changes.

The card keeps a+b=5a + b = 5 so the outer square stays the same size, and the handle only changes the shape of the triangle. It starts at a=2, b=3a = 2,\ b = 3: the big square has area 2525, the four triangles cover 1212, and the 1313 left over is c2=22+32c^2 = 2^2 + 3^2. Each step moves one triangle as a rigid piece — a turn and a slide — so no area is created or lost on the way.

Second proof: similar triangles

Drop the altitude from the right angle to the hypotenuse. It cuts cc into two pieces, mm next to leg aa and nn next to leg bb, with m+n=cm + n = c. Each of the two smaller triangles shares an acute angle with the original and has a right angle, so both are similar to it. Comparing the ratio of a leg to the hypotenuse in the original triangle and in each small one:

ma=ac  ⇒  a2=cm,nb=bc  ⇒  b2=cn.\frac{m}{a} = \frac{a}{c} \;\Rightarrow\; a^2 = cm, \qquad \frac{n}{b} = \frac{b}{c} \;\Rightarrow\; b^2 = cn.

Adding, a2+b2=c(m+n)=c2a^2 + b^2 = c(m + n) = c^2. ■\blacksquare This proof uses no area at all; it shows that the theorem is really a statement about similarity, which is why Euclid could generalise it in Book VI (Proposition 31): any similar figures drawn on the three sides, not only squares, satisfy the same relation.

Hundreds of other proofs are known. E. S. Loomis's The Pythagorean Proposition collects 367. One of the best known, by James A. Garfield in 1876 before he became US president, is half of the rearrangement above: a trapezoid made of two copies of the triangle and one isosceles right triangle with legs cc.

The converse

If a triangle has sides aa, bb, cc with a2+b2=c2a^2 + b^2 = c^2, then the angle opposite cc is a right angle (Euclid I.48). Proof: build a right triangle with legs aa and bb. By the theorem its hypotenuse c′c' satisfies c′2=a2+b2=c2c'^2 = a^2 + b^2 = c^2, so c′=cc' = c. The two triangles have the same three sides, so they are congruent, and the angle opposite cc equals the right angle opposite c′c'. ■\blacksquare

The converse is the practical half. A rope or tape with marks at 3, 4 and 5 units makes a right angle on a building site, because 32+42=523^2 + 4^2 = 5^2.

Pythagorean triples and Euclid's formula

A Pythagorean triple is three positive integers with a2+b2=c2a^2 + b^2 = c^2, such as (3,4,5)(3, 4, 5), (5,12,13)(5, 12, 13), (8,15,17)(8, 15, 17) and (20,21,29)(20, 21, 29). A triple is primitive when the three numbers share no common factor. Euclid's formula produces them: for integers m>n>0m > n > 0,

a=m2−n2,b=2mn,c=m2+n2.a = m^2 - n^2, \qquad b = 2mn, \qquad c = m^2 + n^2.

Checking is algebra: (m2−n2)2+(2mn)2=m4+2m2n2+n4=(m2+n2)2(m^2 - n^2)^2 + (2mn)^2 = m^4 + 2m^2n^2 + n^4 = (m^2 + n^2)^2. Taking m=2,n=1m = 2, n = 1 gives (3,4,5)(3, 4, 5); m=3,n=2m = 3, n = 2 gives (5,12,13)(5, 12, 13); m=4,n=1m = 4, n = 1 gives (15,8,17)(15, 8, 17). When mm and nn are coprime and not both odd, the triple is primitive, and every primitive triple arises this way exactly once, up to swapping aa and bb. Every other triple is a multiple k(a,b,c)k(a, b, c) of a primitive one: (6,8,10)(6, 8, 10) and (9,12,15)(9, 12, 15) are (3,4,5)(3, 4, 5) scaled.

Triples are old. The Babylonian tablet Plimpton 322, from roughly 1800 BC, lists numbers that correspond to fifteen of them, some as large as (12709,13500,18541)(12709, 13500, 18541). Raise the exponent and the picture changes completely: ak+bk=cka^k + b^k = c^k has no solution in positive integers for any k≥3k \geq 3 — Fermat's Last Theorem, proved by Andrew Wiles in 1995.

Beyond right triangles: the law of cosines

For any triangle with angle γ\gamma opposite side cc,

c2=a2+b2−2abcos⁡γ.c^2 = a^2 + b^2 - 2ab\cos\gamma.

At γ=90∘\gamma = 90^\circ the cosine is zero and this is the Pythagorean theorem. The correction term tells which way a triangle leans: if c2>a2+b2c^2 > a^2 + b^2, then cos⁡γ<0\cos\gamma < 0 and γ\gamma is obtuse; if c2<a2+b2c^2 < a^2 + b^2 for the longest side cc, the triangle is acute. Euclid has both cases, without cosines, as Propositions 12 and 13 of Book II.

The theorem also extends to more dimensions. The diagonal of a box with edges xx, yy, zz has length x2+y2+z2\sqrt{x^2 + y^2 + z^2} — apply the theorem twice — and the distance between two points in Rn\mathbb{R}^n is ∑(xi−yi)2\sqrt{\sum (x_i - y_i)^2}. In any inner product space, ∥u+v∥2=∥u∥2+∥v∥2\|u + v\|^2 = \|u\|^2 + \|v\|^2 exactly when uu and vv are orthogonal. On curved surfaces it fails: on a unit sphere a right triangle obeys cos⁡c=cos⁡acos⁡b\cos c = \cos a \cos b, which approaches the familiar form only for small triangles.

A note on history

The relation was known and used long before Pythagoras, in Babylonia, and early in China and India, where the Chinese text Zhoubi Suanjing gives a dissection diagram for it. No writing by Pythagoras survives; the attribution of the theorem, and of a proof, to him or his school comes from much later authors. Euclid's I.47 is the oldest surviving proof in the Greek tradition.

Common pitfalls

  • Using the wrong side as cc. cc is the hypotenuse, the side opposite the right angle and the longest one. With legs 5 and 12 the hypotenuse is 13, not 122−52\sqrt{12^2 - 5^2}.
  • Applying it to a triangle that is not right. For other triangles use the law of cosines.
  • Adding lengths instead of squares. a2+b2\sqrt{a^2 + b^2} is not a+ba + b: with legs 3 and 4 the hypotenuse is 5, not 7. The hypotenuse is always shorter than the two legs together, and longer than either one.
  • Mixing up the theorem and its converse. The theorem goes from a right angle to a2+b2=c2a^2 + b^2 = c^2; checking whether a triangle is right needs the converse.
  • Trusting the picture. In a rearrangement proof, the claim that the pieces fit and the hole is a square is part of the proof and has to be argued.

Short answers

What does the Pythagorean theorem say?

In a right triangle, the square of the hypotenuse equals the sum of the squares of the two legs: a² + b² = c², where c is the side opposite the right angle.

How do you prove the Pythagorean theorem?

One proof places four copies of the triangle inside a square of side a + b. Arranged one way they leave a square of side c uncovered; arranged another way they leave squares of sides a and b. The uncovered area is the same both times, so c² = a² + b². Another proof uses the altitude to the hypotenuse, which splits the triangle into two triangles similar to it.

Does the Pythagorean theorem work for any triangle?

No, only for right triangles. For any triangle the law of cosines holds, c² = a² + b² − 2ab·cos γ, which reduces to the Pythagorean theorem when the angle γ opposite c is 90°.

How do you know if a triangle is a right triangle?

By the converse of the theorem: if the sides satisfy a² + b² = c², the angle opposite c is a right angle. If c² is larger than a² + b² that angle is obtuse; if smaller, every angle is acute.

How do you find all Pythagorean triples?

Euclid's formula gives a = m² − n², b = 2mn, c = m² + n² for integers m > n > 0. Taking m and n coprime and not both odd gives every primitive triple exactly once (up to swapping a and b); every other triple is a multiple k·(a, b, c) of a primitive one.

Further reading

  • Euclid, Elements, Book I, Propositions 47 and 48 (the theorem and its converse); Book II, 12–13 (the law of cosines); Book VI, 31 (similar figures).
  • E. S. Loomis, The Pythagorean Proposition, 2nd ed., 1940; reprinted by the National Council of Teachers of Mathematics, 1968. A collection of 367 proofs.
  • E. Maor, The Pythagorean Theorem: A 4,000-Year History, Princeton University Press, 2007.
  • G. H. Hardy, E. M. Wright, An Introduction to the Theory of Numbers, 6th ed., Oxford University Press, 2008. Pythagorean triples and the equation x² + y² = z².