Algebra

The identity that multiplies sums of squares

A sum of two squares times a sum of two squares is a sum of two squares, and the same is true of four and of eight. It is true of three of nothing: 3 and 5 are each a sum of three squares, 15 is not, and one small pair of numbers rules the case out forever.

Worth reading first: A multiplication that remembers the order · Two squares, and a lattice.

Every step of the previous rung used that the length of a product is the product of the lengths. Written out in coordinates, that innocuous sentence is an algebraic identity in eight variables, and it is one of the oldest useful facts in number theory.

The four-square identity, and how few squares a number needs. A product of two whole quaternions with both sides of the four-square identity evaluated, above a strip colouring every number by the fewest squares that add to it.
Fig. 1 A product of two whole quaternions with both sides of the four-square identity evaluated in integers, above a strip colouring every number to forty-eight by the fewest squares that add to it. None needs five, which is Lagrange’s theorem, and the identity is why only the primes ever had to be checked.

Take two sums of four squares, multiply them, and the answer is again a sum of four squares — with the four numbers written explicitly in terms of the eight given ones. That is Euler’s identity of 1748, and it is the quaternion product with the letters kept.

Where the identity comes from

The norm of a quaternion a=a0+a1i+a2j+a3ka = a_0 + a_1 i + a_2 j + a_3 k is a2=a02+a12+a22+a32|a|^2 = a_0^2 + a_1^2 + a_2^2 + a_3^2, which is a sum of four squares by construction. And the norm is multiplicative: ab=ab|ab| = |a||b|, so ab2=a2b2|ab|^2 = |a|^2|b|^2.

Write out abab from Hamilton’s rule and the four coordinates of the product are

c0=a0b0a1b1a2b2a3b3,c1=a0b1+a1b0+a2b3a3b2,c2=a0b2a1b3+a2b0+a3b1,c3=a0b3+a1b2a2b1+a3b0.\begin{aligned} c_0 &= a_0b_0 - a_1b_1 - a_2b_2 - a_3b_3,\\ c_1 &= a_0b_1 + a_1b_0 + a_2b_3 - a_3b_2,\\ c_2 &= a_0b_2 - a_1b_3 + a_2b_0 + a_3b_1,\\ c_3 &= a_0b_3 + a_1b_2 - a_2b_1 + a_3b_0. \end{aligned}

So (a02+a12+a22+a32)(b02+b12+b22+b32)=c02+c12+c22+c32(a_0^2+a_1^2+a_2^2+a_3^2)(b_0^2+b_1^2+b_2^2+b_3^2) = c_0^2+c_1^2+c_2^2+c_3^2, and every cic_i is a whole number whenever every aia_i and every bib_i is.

The identity is the multiplication table, and nothing else. That is why the four expressions look arbitrary written out and are obviously right derived: each is a coefficient of a product nobody had to invent.

The same construction one level down gives the two-square identity, which Diophantus knew: (a02+a12)(b02+b12)=(a0b0a1b1)2+(a0b1+a1b0)2(a_0^2+a_1^2)(b_0^2+b_1^2) = (a_0b_0 - a_1b_1)^2 + (a_0b_1 + a_1b_0)^2, and that is the complex product with the letters kept. Multiplication as turning and the two-square identity are the same statement.

Why the primes are the only hard case

Lagrange proved in 1770 that every positive integer is a sum of four squares. The identity reduces that theorem to a statement about primes.

Every integer factors into primes. If each prime is a sum of four squares, then multiplying them together — using the identity at each step — makes the product a sum of four squares too, since the identity produces whole numbers from whole numbers. And 2=1+1+0+02 = 1 + 1 + 0 + 0, so only the odd primes need attention.

That reduction is not a small saving. Proving every integer is a sum of four squares directly means dealing with numbers of every shape; proving it for primes means one argument, and the argument that works is a descent: show that some multiple mpmp with m<pm < p is a sum of four squares, then show mm can always be reduced, and land at m=1m = 1.

The four-square identity, and how few squares a number needs. A product of two whole quaternions with both sides of the four-square identity evaluated, above a strip colouring every number by the fewest squares that add to it.
Fig. 2 A different pair. Fifteen times twenty-five is three hundred and seventy-five, and the four coordinates of the quaternion product square and add to exactly that — checked in whole numbers rather than to a tolerance, because an identity in integers either holds or does not.

The same statement about lattice points

There is a geometric reading, and it makes the difference between the cases into a difference between shapes.

A sum of four squares is the squared distance from the origin to a point of the four-dimensional integer lattice. So n is a sum of four squares means the sphere of radius √n in four-space passes through a lattice point, and Lagrange’s theorem says every such sphere does — which is a statement that the four-dimensional lattice is dense enough that no sphere of integer squared radius misses it.

In two dimensions the corresponding statement is false, and visibly so: the circle of radius √3 passes through no lattice point, and circles that miss the lattice are common. In three dimensions it is false but only just, failing on the thin set the last section names. In four it is true with room to spare.

The identity, read geometrically, says that multiplying a point of one lattice by a point of another produces a point of the same lattice at the product of the distances. That is a closure property of the lattice under a multiplication, and it is exactly what a ring is.

The circle of radius √25 on the integer lattice. A circle drawn on the whole-number grid, with the lattice points it passes through marked.
Fig. 3 Two dimensions, for contrast: how many lattice points sit on each circle of squared radius as far as the thirty-second. Many circles hold none at all, which is what makes the two-square question interesting; the four-dimensional version of this chart would have no empty column anywhere.

Three squares will not do, and the reason is two numbers

The pattern invites an obvious guess: two squares work, four work, so surely three do.

They do not, and the disproof is a pair of small numbers. Three is 1+1+11 + 1 + 1. Five is 4+1+04 + 1 + 0. Their product is fifteen, and fifteen is not a sum of three squares — the largest square below it is nine, and 159=615 - 9 = 6, 154=1115 - 4 = 11, 151=1415 - 1 = 14, none of which is a sum of two squares.

So there is no identity expressing a product of two sums of three squares as a sum of three squares, because any such identity would apply to 3×53 \times 5 and produce a representation that does not exist.

One counterexample kills every possible identity at once, which is a much stronger conclusion than checking any particular candidate formula. That is what makes the argument worth stating carefully: it does not say nobody has found a three-square identity, it says none exists.

Which numbers really need four

The three-square case is not hopeless, merely conditional. Legendre and Gauss settled it: a positive integer is a sum of three squares exactly when it is not of the form 4a(8b+7)4^a(8b+7).

Fifteen is 8×1+78 \times 1 + 7, so it fails. Twenty-eight is 4×74 \times 7, so it fails. Seven, twenty-three, thirty-one — the numbers needing all four squares are exactly those, and the hero figure’s strip finds them by search and then checks them against the condition rather than colouring them from it.

The condition explains the failure of the identity in one line. The set of numbers that are sums of three squares is not closed under multiplication, because 33 and 55 are in it and 1515 is not; a set that is not closed under multiplication cannot be the value set of a multiplicative norm.

The four-square identity, and how few squares a number needs. A product of two whole quaternions with both sides of the four-square identity evaluated, above a strip colouring every number by the fewest squares that add to it.
Fig. 4 Ninety-six numbers coloured by how few squares they need. The ones needing four are 7, 15, 23, 28, 31, 39, 47, 55, 60, 63, 71, 79, 87, 92 and 95 — and each is four times a power away from being seven modulo eight, which is the condition the figure checks rather than quotes.

Eight squares, and where it stops

There is an eight-square identity too, found by Degen in 1818 and rediscovered by Graves and Cayley, and it comes from the octonions in exactly the way the four-square identity comes from the quaternions.

Then it stops. Hurwitz proved in 1898 that a bilinear identity expressing a product of two sums of nn squares as a sum of nn squares exists only for n=1,2,4,8n = 1, 2, 4, 8. The proof is a piece of linear algebra about the matrices such an identity would require, and it is one of the cleanest impossibility results in the subject.

So the list of dimensions is 1,2,4,81, 2, 4, 8, arrived at here from a question about integers with no algebra in sight. The same list arrives at the tower of division algebras from a question about dividing, and at the composition algebras from a question about norms. Three independent questions with one answer is a sign that they are one question.

The identity as a rule for combining representations

Set aside the theorems and there is a practical use, which is how the identity was actually employed for two centuries.

Given a number written as a sum of four squares, and another, the identity produces a representation of their product without any search. Since 30=1+4+9+1630 = 1+4+9+16 and 39=4+1+25+939 = 4+1+25+9 — the hero’s pair — the identity produces 11701170 as 729+36+81+324729 + 36 + 81 + 324 directly, with no trial division and no hunting.

Before computers that mattered a great deal. Tables of representations were built multiplicatively, and the identity is the multiplication step. The same is true of the two-square identity, which is how tables of numbers as sums of two squares were assembled from the primes upward.

A constructive identity is worth more than an existence theorem when somebody has to produce an answer, and this is a case where the constructive version came first and the existence theorem was built on it.

Jacobi’s count, which the identity makes possible

Existence is the theorem everybody quotes; the count is the theorem that is actually used, and it is prettier.

Jacobi proved in 1829 that the number of ways to write nn as an ordered sum of four squares, signs and orders counted separately, is eight times the sum of the divisors of nn that are not divisible by four. For n=1n = 1 that is 8×1=88 \times 1 = 8, which is the four coordinates times two signs. For n=2n = 2 the divisors are 11 and 22, neither divisible by four, so 8×3=248 \times 3 = 24 — and indeed 2=1+1+0+02 = 1+1+0+0 has six arrangements times four sign choices.

No integer has zero such divisors, so the count is never zero, and Lagrange’s theorem falls out of the formula as a corollary. That is a much more satisfying proof than a descent, because it explains rather than merely establishes: the number of representations is a divisor sum, and a divisor sum is positive.

The reason such a formula exists at all traces back to the identity. Counting representations of nn counts elements of norm nn in a ring of quaternions, and elements of a given norm are counted by looking at how the norm factors — which is possible exactly because the norm is multiplicative. The divisor structure of a number is doing the work, as it does in every count of this kind.

The divisors of 24. Every divisor as a lattice point, one axis per prime, joined when one divides the other by a single prime.
Fig. 5 Twenty-four’s divisors, arranged by which prime powers divide them. Jacobi’s count is a sum over the divisors not divisible by four — here 1, 2, 3 and 6, adding to twelve, so twenty-four is an ordered sum of four squares in ninety-six ways.

The order matters, and what that costs

One subtlety separates the four-square identity from the two-square one, and it is the non-commutativity again.

For complex numbers abab and baba are equal, so the two-square identity has one form. For quaternions they differ, so there are two four-square identities — one from abab and one from baba — giving generally different representations of the same product.

That is not a defect. It is the reason the number of representations of an integer as a sum of four squares is large: Jacobi’s formula says it is eight times the sum of the divisors not divisible by four, which grows, and the multiplicity comes from exactly this kind of freedom.

The quaternion multiplication table, from i² = j² = k² = ijk = −1. A four-by-four multiplication table of the quaternion units, with the row giving the left factor, every entry computed from Hamilton's rule, and the pair that differs between the two orders marked.
Fig. 6 The multiplication table of the four units, with ji picked out. Every asymmetry in the table is a place where the identity built from ab and the identity built from ba differ, and there are six such places among the sixteen products.

The count of asymmetric entries is worth having: of the sixteen products of basis units, six differ from their reverse and ten do not, since anything involving 11 commutes and the three squares are equal to their own reverses. Six differences is what makes two identities rather than one, and each of those six is a sign.

Compare the two-square case, where the count is small and rigid — four times a difference of divisor counts — and the difference traces back to Z[i]\mathbb{Z}[i] having four units and the integer quaternions having twenty-four. The number of units in a ring controls how many ways its elements factor, and the counts above are that principle in two instances.

Doing the descent, at seventeen

The reduction to primes is worth seeing once, because it is where the identity does its work.

Seventeen is 16+116 + 1, a sum of two squares, so nothing is needed. Take 2323 instead, which is 7mod87 \bmod 8 and so needs four: 23=9+9+4+123 = 9 + 9 + 4 + 1. Now 17×23=39117 \times 23 = 391, and rather than search for a representation of 391391, feed the two into the identity.

Writing 17=42+12+02+0217 = 4^2 + 1^2 + 0^2 + 0^2 and 23=32+32+22+1223 = 3^2 + 3^2 + 2^2 + 1^2, the quaternion product (4+i)(3+3i+2j+k)(4 + i)(3 + 3i + 2j + k) is 123+(12+3)i+(81)j+(4+2)k12 - 3 + (12 + 3)i + (8 - 1)j + (4 + 2)k, which is 9+15i+7j+6k9 + 15i + 7j + 6k. And 81+225+49+36=39181 + 225 + 49 + 36 = 391.

No search, and the answer is exact. The whole cost was one quaternion multiplication, and the guarantee that it would work was the multiplicativity of the norm.

Why a norm has to be a quadratic form

There is a reason all of this is about squares rather than about cubes or higher powers, and it is short.

A norm that multiplies has to satisfy N(ab)=N(a)N(b)N(ab) = N(a)N(b), and if NN is a polynomial of degree dd in the coordinates then the two sides have degree dd in each of aa and bb — which forces the norm to come from a bilinear multiplication. Requiring in addition that NN be positive definite, so that only zero has norm zero and division is possible, forces d=2d = 2: a positive definite form of odd degree does not exist, and one of degree four or more cannot be multiplicative for a bilinear product.

So sums of squares is not one case among many. It is the only kind of expression that can behave this way at all, and the question of which nn admit an identity is the whole question rather than a first instance of a family.

Who found what, and how long the gap was

The chronology is worth a paragraph because the pieces arrived in an order nobody would design.

Diophantus had the two-square identity in the third century, as a rule for combining representations, with no algebra behind it. Fibonacci restated it in 1225. Euler wrote down the four-square identity in a letter to Goldbach in 1748 — ninety-five years before Hamilton found the quaternions — and he found it by algebraic experiment, looking for an expression that would work, not by deriving it from a multiplication.

So the identity that is the quaternion product was known for a century before the quaternions were, and used throughout that century for exactly the purpose it is used for here: reducing Lagrange’s theorem to the primes. Lagrange’s proof came in 1770 and leaned on Euler’s identity; Euler completed the descent in 1773.

The structure came last. Hamilton’s discovery in 1843 did not produce the identity; it explained one that had been in use for three generations, and the explanation is the whole of this essay’s first section. That is a common shape in mathematics and it is worth naming: a formula that works for no visible reason usually means a structure has not been found yet, and finding it converts a trick into a consequence.

The eight-square identity followed the same pattern in miniature. Degen wrote it down in 1818; Graves constructed the octonions in 1843, days after hearing of the quaternions, and found that the identity was their norm. Twenty-five years of a formula with no home.

What the pictures cannot show

An identity in eight variables is not a picture. The hero evaluates it at one pair of quaternions and checks both sides in exact integers, which is a demonstration and not a proof. The proof is the multiplication table, which is four lines of algebra and no geometry.

The strip stops at forty-eight, and the theorem does not. Every number in it needs at most four squares, and the pattern of which need exactly four is visible; that the pattern continues forever is Legendre’s theorem and nothing here bears on it.

And the non-existence of a three-square identity is shown by two numbers. That is a complete proof, and it is the one thing on this page that a figure could not have made more convincing — a picture of fifteen failing to be three squares is a picture of an absence.

Where the ladder goes next

The identity above worked in whole numbers because the quaternion product of whole quaternions is whole. The next rung asks what ring those whole quaternions form, and finds that the obvious answer is the wrong one: the integers among the quaternions include sixteen with half-integer coordinates, and without them there is no division algorithm and Lagrange’s theorem loses its cleanest proof.

Sideways: the primes that are sums of two squares is the two-dimensional case done properly, and what the coefficients already know is where identities of this kind live in the algebra of polynomials.

What is worth carrying away

An algebraic structure’s arithmetic properties are usually its geometric ones written in coordinates.

The quaternions were built to rotate space, and the fact making that work — the length of a product is the product of the lengths — becomes, on writing out coordinates, a theorem about which integers are sums of four squares. Neither statement mentions the other and they are the same statement.

So the way to find an identity is often to find a structure whose norm is the expression wanted. Sums of two squares need the complex numbers, four need the quaternions, eight need the octonions, and three need something that does not exist — which is why there is no identity, and why two small numbers are enough to say so.

What links here

Computed from the collection, not written here: the essays that point at this one.

Reads more easily once this is understood

Essays that name this one as worth reading first.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Complex numbersDivision algebraIdentityMultiplicative functionNormPrimesQuaternionSums of two squares