Image: Columbia University, Rare Book and Manuscript Library (public domain)Pythagorean triples, the formula that finds them all
The triangle with sides 3, 4, and 5 has a right angle, because 9 + 16 = 25. So does the triangle with sides 5, 12, 13, and the one with 8, 15, 17, and the one with 119, 120, 169. Whole-number solutions of a² + b² = c² are called Pythagorean triples, and the question of how to find all of them is one of the oldest in number theory. The answer is a formula with two parameters, and the proof that the formula misses nothing is a model of how Diophantine equations are solved.
Reducing to the primitive case
If (a, b, c) is a triple then so is (2a, 2b, 2c), and (ka, kb, kc) for any k. These multiples are not interesting, so we look for primitive triples, those in which a, b, and c have no common factor. Every triple is a multiple of a primitive one, obtained by dividing out the greatest common divisor.
In a primitive triple, a and b cannot both be even, since then c would be even too and 2 would be a common factor. They cannot both be odd either: an odd square leaves remainder 1 on division by 4, so a² + b² would leave remainder 2, and no square does that. So exactly one of a and b is even. Call the even one b. Then a and c are both odd.
The formula and its proof
Rewrite the equation as b² = c² - a² = (c - a)(c + a). Since a and c are odd, both c - a and c + a are even; write c - a = 2u and c + a = 2v. Then b² = 4uv, so (b/2)² = uv, with b/2 a whole number because b is even.
The two factors u and v are coprime. A prime dividing both would divide their sum v + u = c and their difference v - u = a, contradicting the primitivity of the triple. Now comes the step that uses unique factorization: if two coprime numbers multiply to a perfect square, each of them is a perfect square. Every prime in uv appears to an even power, and since no prime is shared between u and v, every prime in u appears to an even power in u alone, and likewise for v. So u = n² and v = m² for some positive integers m and n with m greater than n.
Back-substituting, c = m² + n², a = m² - n², and b = 2mn. Since a and c are odd, m and n have opposite parity, and since the triple is primitive, m and n are coprime. Conversely, any coprime m and n of opposite parity with m greater than n give a primitive triple, as you can check by expanding (m² - n²)² + (2mn)² = (m² + n²)². The theorem reads: the primitive Pythagorean triples are exactly the triples (m² - n², 2mn, m² + n²) with m and n coprime, of opposite parity, and m greater than n.
The pair m = 2, n = 1 gives (3, 4, 5). The pair m = 3, n = 2 gives (5, 12, 13). The pair m = 4, n = 1 gives (15, 8, 17). Two different pairs can give triples with the same hypotenuse: m = 8, n = 1 gives (63, 16, 65) and m = 7, n = 4 gives (33, 56, 65). The number 65 = 5 × 13 is a product of two primes of the form 4k + 1, and Unit 11 of the masterclass explains why that is exactly the condition for two representations.
Plimpton 322
The formula is modern in its notation and ancient in its content. Plimpton 322 is a clay tablet, about 13 cm wide, written in Mesopotamia around 1800 BC and now in the Rare Book and Manuscript Library of Columbia University. It has four columns and fifteen rows of numbers in the base-60 notation of the Babylonians. Two of the columns contain, for each row, the short side and the hypotenuse of a right triangle with whole-number sides. The first row gives 119 and 169, with the missing side 120; the fourth row gives 12709 and 18541, with the missing side 13500.
Those are not numbers anyone finds by trial. In the language of the formula, the first row is m = 12, n = 5, and the fourth is m = 125, n = 54. The scribe worked with numbers whose only prime factors are 2, 3, and 5, which have finite reciprocals in base 60, and the rows are sorted by the ratio of the two sides, so the tablet looks like a systematic table rather than a collection. How it was computed is still argued about, with proposals ranging from a version of the parametrization to a method based on reciprocal pairs, which fits the Babylonian habits better. What is not argued about is that these are Pythagorean triples, written down more than a thousand years before Pythagoras was born.
Euclid, around 300 BC, gave a version of the formula in Book X of the Elements. Diophantus, in the third century AD, used it freely in the Arithmetica, and it was in the margin of a Diophantus problem about splitting a square into two squares that Fermat, around 1637, wrote the note that became Fermat's Last Theorem: for cubes and higher powers, there are no such triples at all.
The circle behind the formula
There is a second way to see the result, and it is the one that leads somewhere. Divide a² + b² = c² by c². Then (a/c)² + (b/c)² = 1, so every Pythagorean triple gives a point with rational coordinates on the circle x² + y² = 1, and every such point gives a triple when you clear denominators. The question becomes: where are the rational points on the circle?
Take the point (-1, 0), which is on the circle, and draw a line through it with slope t. The line meets the circle in one more point. Substituting y = t(x + 1) into x² + y² = 1 gives a quadratic in x with the known root x = -1, and the other root comes out as x = (1 - t²)/(1 + t²), with y = 2t/(1 + t²). If t is rational, so is the point. Conversely, the line from (-1, 0) to any rational point of the circle has rational slope. So the rational points on the circle are exactly the points ((1 - t²)/(1 + t²), 2t/(1 + t²)) with t rational, plus (-1, 0) itself. Write t = n/m and clear denominators, and the parametrization (m² - n², 2mn, m² + n²) falls out.
The method has nothing to do with circles in particular. It works on any conic with one rational point, and it is the reason the equation x² + y² = 1 has infinitely many rational solutions while x² + y² = 3 has none: the second circle has no rational point to start from, which Unit 7 of the masterclass proves by looking at remainders modulo 3. For cubic curves such as y² = x³ + ax + b the line through two rational points gives a third, and from that single observation grows the theory of elliptic curves, in which Wiles's proof of Fermat's Last Theorem lives.
Two things to try
Project Euler's Problem 9 asks for the one Pythagorean triple with a + b + c = 1000. The sum of the formula's three terms is 2m² + 2mn = 2m(m + n), so you need m(m + n) = 500 (with the formula allowed to produce non-primitive triples as well), and a minute of checking the divisors of 500 finds m = 20, n = 5, giving 375, 200, 425, which is five times the primitive triple 75, 40, 85. A search over all triples finds the same answer and teaches you nothing.
Then take the triples with hypotenuse 65 and look at 5 × 13 = 65, with 5 = 1² + 2² and 13 = 2² + 3². The identity (p² + q²)(r² + s²) = (pr - qs)² + (ps + qr)² = (pr + qs)² + (ps - qr)² gives the two representations of 65 as a sum of two squares, 8² + 1² and 7² + 4², which are the two pairs (m, n) above. Which numbers are sums of two squares, and in how many ways, is a question Fermat answered in a letter on Christmas Day 1640, and it is the subject of Unit 11.


