Hubbry Logo
Lagrange's four-square theoremLagrange's four-square theoremMain
Open search
Lagrange's four-square theorem
Community hub
Lagrange's four-square theorem
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Lagrange's four-square theorem
Lagrange's four-square theorem
from Wikipedia
Unlike in three dimensions in which distances between vertices of a polycube with unit edges excludes √7 due to Legendre's three-square theorem, Lagrange's four-square theorem states that the analogue in four dimensions yields square roots of every natural number

Lagrange's four-square theorem, also known as Bachet's conjecture, states that every nonnegative integer can be represented as a sum of four non-negative integer squares.[1] That is, the squares form an additive basis of order four: where the four numbers are integers. For illustration, 3, 31, and 310 can be represented as the sum of four squares as follows:

This theorem was proven by Joseph-Louis Lagrange in 1770. It is a special case of the Fermat polygonal number theorem.

Historical development

[edit]

From examples given in the Arithmetica, it is clear that Diophantus was aware of the theorem. This book was translated in 1621 into Latin by Bachet (Claude Gaspard Bachet de Méziriac), who stated the theorem in the notes of his translation. But the theorem was not proved until 1770 by Lagrange.[2]

Adrien-Marie Legendre extended the theorem in 1797–8 with his three-square theorem, by proving that a positive integer can be expressed as the sum of three squares if and only if it is not of the form for integers k and m. Later, in 1834, Carl Gustav Jakob Jacobi discovered a simple formula for the number of representations of an integer as the sum of four squares with his own four-square theorem.

The formula is also linked to Descartes' theorem of four "kissing circles", which involves the sum of the squares of the curvatures of four circles. This is also linked to Apollonian gaskets, which were more recently related to the Ramanujan–Petersson conjecture.[3]

Proofs

[edit]

The classical proof

[edit]

Several very similar modern versions[4][5][6] of Lagrange's proof exist. The proof below is a slightly simplified version, in which the cases for which m is even or odd do not require separate arguments.

The classical proof

It is sufficient to prove the theorem for every odd prime number p. This immediately follows from Euler's four-square identity (and from the fact that the theorem is true for the numbers 1 and 2).

The residues of a2 modulo p are distinct for every a between 0 and (p − 1)/2 (inclusive). To see this, take some a and define c as a2 mod p. a is a root of the polynomial x2c over the field Z/pZ. So is pa (which is different from a). In a field K, any polynomial of degree n has at most n distinct roots (Lagrange's theorem (number theory)), so there are no other a with this property, in particular not among 0 to (p − 1)/2.

Similarly, for b taking integral values between 0 and (p − 1)/2 (inclusive), the b2 − 1 are distinct. By the pigeonhole principle, there are a and b in this range, for which a2 and b2 − 1 are congruent modulo p, that is for which

Now let m be the smallest positive integer such that mp is the sum of four squares, x12 + x22 + x32 + x42 (we have just shown that there is some m (namely n) with this property, so there is a least one m, and it is smaller than p). We show by contradiction that m equals 1: supposing it is not the case, we prove the existence of a positive integer r less than m, for which rp is also the sum of four squares (this is in the spirit of the infinite descent[7] method of Fermat).

For this purpose, we consider for each xi the yi which is in the same residue class modulo m and between (–m + 1)/2 and m/2 (possibly included). It follows that y12 + y22 + y32 + y42 = mr, for some strictly positive integer r less than m.

Finally, another appeal to Euler's four-square identity shows that mpmr = z12 + z22 + z32 + z42. But the fact that each xi is congruent to its corresponding yi implies that all of the zi are divisible by m. Indeed,

It follows that, for wi = zi/m, w12 + w22 + w32 + w42 = rp, and this is in contradiction with the minimality of m.

In the descent above, we must rule out both the case y1 = y2 = y3 = y4 = m/2 (which would give r = m and no descent), and also the case y1 = y2 = y3 = y4 = 0 (which would give r = 0 rather than strictly positive). For both of those cases, one can check that mp = x12 + x22 + x32 + x42 would be a multiple of m2, contradicting the fact that p is a prime greater than m.

Proof using the Hurwitz integers

[edit]

Another way to prove the theorem relies on Hurwitz quaternions, which are the analog of integers for quaternions.[8]

Proof using the Hurwitz integers

The Hurwitz quaternions consist of all quaternions with integer components and all quaternions with half-integer components. These two sets can be combined into a single formula where are integers. Thus, the quaternion components are either all integers or all half-integers, depending on whether is even or odd, respectively. The set of Hurwitz quaternions forms a ring; that is to say, the sum or product of any two Hurwitz quaternions is likewise a Hurwitz quaternion.

The (arithmetic, or field) norm of a rational quaternion is the nonnegative rational number where is the conjugate of . Note that the norm of a Hurwitz quaternion is always an integer. (If the coefficients are half-integers, then their squares are of the form , and the sum of four such numbers is an integer.)

Since quaternion multiplication is associative, and real numbers commute with other quaternions, the norm of a product of quaternions equals the product of the norms:

For any , . It follows easily that is a unit in the ring of Hurwitz quaternions if and only if .

The proof of the main theorem begins by reduction to the case of prime numbers. Euler's four-square identity implies that if Lagrange's four-square theorem holds for two numbers, it holds for the product of the two numbers. Since any natural number can be factored into powers of primes, it suffices to prove the theorem for prime numbers. It is true for . To show this for an odd prime integer p, represent it as a quaternion and assume for now (as we shall show later) that it is not a Hurwitz irreducible; that is, it can be factored into two non-unit Hurwitz quaternions

The norms of are integers such that and . This shows that both and are equal to p (since they are integers), and p is the sum of four squares

If it happens that the chosen has half-integer coefficients, it can be replaced by another Hurwitz quaternion. Choose in such a way that has even integer coefficients. Then

Since has even integer coefficients, will have integer coefficients and can be used instead of the original to give a representation of p as the sum of four squares.

As for showing that p is not a Hurwitz irreducible, Lagrange proved that any odd prime p divides at least one number of the form , where l and m are integers.[8] This can be seen as follows: since p is prime, can hold for integers , only when . Thus, the set of squares contains distinct residues modulo p. Likewise, contains residues. Since there are only p residues in total, and , the sets X and Y must intersect.

The number u can be factored in Hurwitz quaternions:

The norm on Hurwitz quaternions satisfies a form of the Euclidean property: for any quaternion with rational coefficients we can choose a Hurwitz quaternion so that by first choosing so that and then so that for . Then we obtain

It follows that for any Hurwitz quaternions with , there exists a Hurwitz quaternion such that

The ring H of Hurwitz quaternions is not commutative, hence it is not an actual Euclidean domain, and it does not have unique factorization in the usual sense. Nevertheless, the property above implies that every right ideal is principal. Thus, there is a Hurwitz quaternion such that

In particular, for some Hurwitz quaternion . If were a unit, would be a multiple of p, however this is impossible as is not a Hurwitz quaternion for . Similarly, if were a unit, we would have so p divides , which again contradicts the fact that is not a Hurwitz quaternion. Thus, p is not Hurwitz irreducible, as claimed.

Generalizations

[edit]

Lagrange's four-square theorem is a special case of the Fermat polygonal number theorem and Waring's problem. Another possible generalization is the following problem: Given natural numbers , can we solve

for all positive integers n in integers ? The case is answered in the positive by Lagrange's four-square theorem. The general solution was given by Ramanujan.[9] He proved that if we assume, without loss of generality, that then there are exactly 54 possible choices for such that the problem is solvable in integers for all n. (Ramanujan listed a 55th possibility , but in this case the problem is not solvable if .[10])

Algorithms

[edit]

In 1986, Michael O. Rabin and Jeffrey Shallit[11] proposed randomized polynomial-time algorithms for computing a single representation for a given integer n, in expected running time . It was further improved to by Paul Pollack and Enrique Treviño in 2018.[12]

Number of representations

[edit]

The number of representations of a natural number n as the sum of four squares of integers is denoted by r4(n). Jacobi's four-square theorem states that this is eight times the sum of the divisors of n if n is odd and 24 times the sum of the odd divisors of n if n is even (see divisor function), i.e.

Equivalently, it is eight times the sum of all its divisors which are not divisible by 4, i.e.

We may also write this as where the second term is to be taken as zero if n is not divisible by 4. In particular, for a prime number p we have the explicit formula r4(p) = 8(p + 1).[13]

Some values of r4(n) occur infinitely often as r4(n) = r4(2mn) whenever n is even. The values of r4(n)/n can be arbitrarily large: indeed, r4(n)/n is infinitely often larger than 8log n.[13]

Uniqueness

[edit]

The sequence of positive integers which have only one representation as a sum of four squares of non-negative integers (up to order) is:

1, 2, 3, 5, 6, 7, 8, 11, 14, 15, 23, 24, 32, 56, 96, 128, 224, 384, 512, 896 ... (sequence A006431 in the OEIS).

These integers consist of the seven odd numbers 1, 3, 5, 7, 11, 15, 23 and all numbers of the form or .

The sequence of positive integers which cannot be represented as a sum of four non-zero squares is:

1, 2, 3, 5, 6, 8, 9, 11, 14, 17, 24, 29, 32, 41, 56, 96, 128, 224, 384, 512, 896 ... (sequence A000534 in the OEIS).

These integers consist of the eight odd numbers 1, 3, 5, 9, 11, 17, 29, 41 and all numbers of the form or .

Further refinements

[edit]

Lagrange's four-square theorem can be refined in various ways. For example, Zhi-Wei Sun[14] proved that each natural number can be written as a sum of four squares with some requirements on the choice of these four numbers.

One may also wonder whether it is necessary to use the entire set of square integers to write each natural as the sum of four squares. Eduard Wirsing proved that there exists a set of squares S with such that every positive integer smaller than or equal to n can be written as a sum of at most 4 elements of S.[15]

See also

[edit]

Notes

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
Lagrange's four-square theorem asserts that every can be represented as the sum of four squares of integers. Formally, for any positive integer nn, there exist integers a,b,c,da, b, c, d such that n=a2+b2+c2+d2n = a^2 + b^2 + c^2 + d^2. This result, a cornerstone of , was first proved by the French mathematician . The theorem originated from earlier conjectures in Diophantine problems, notably Bachet's 1621 claim that every number is a sum of at most four squares, which Fermat claimed to have proved using his method of infinite descent, though no proof was published. Euler extended this by establishing an identity showing that the product of two sums of four squares is itself a sum of four squares, facilitating multiplicative properties. Lagrange submitted his complete proof to the Berlin Academy in 1770, with publication following in 1772; his approach combined Euler's identity with a descent argument and analysis of quadratic residues modulo primes to handle prime cases before extending to all naturals. Beyond its statement, the theorem has profound implications in quadratic forms and , influencing later results like for the number of representations and connections to quaternions via Hurwitz integers. It exemplifies the power of identities in and remains a benchmark for algorithms finding such representations, with applications in .

Statement and background

The theorem

Lagrange's four-square theorem states that every non-negative nn can be expressed as the sum of four squares of , that is, there exist a,b,c,da, b, c, d such that n=a2+b2+c2+d2.n = a^2 + b^2 + c^2 + d^2. This representation holds for n=0n = 0 as well, with 0=02+02+02+020 = 0^2 + 0^2 + 0^2 + 0^2, and the a,b,c,da, b, c, d may be positive, negative, or zero; however, since squaring eliminates the sign, it is equivalent to using non-negative . The theorem provides a complete solution to the x12+x22+x32+x42=nx_1^2 + x_2^2 + x_3^2 + x_4^2 = n in for any non-negative nn, affirming that such equations always possess integer solutions. A direct is that every can be written as the sum of four squares, as primes are a subset of the non-negative integers.

Historical context

The concept of representing numbers as sums of squares has roots in ancient mathematics. The Pythagoreans, in the 6th century BCE, explored right-angled triangles through the , which equates the square of the hypotenuse to the sum of the squares of the other two sides, laying early groundwork for integer solutions involving two squares. In the 3rd century CE, of , in his Arithmetica, investigated Diophantine equations and sums of squares, solving problems such as expressing specific numbers as sums of two or three squares using rational numbers; he also appears to have been aware that every can be expressed as a sum of four squares, though without a formal proof. The problem gained prominence in the early modern period through Claude-Gaspar de Bachet de Méziriac. In his 1621 French translation and commentary on Diophantus's Arithmetica, Bachet posed the four-square representation as a conjecture—now known as Bachet's conjecture—verifying it empirically for all integers from 1 to 325 but leaving a general proof unresolved. Around 1640, Pierre de Fermat encountered Bachet's conjecture and claimed in private correspondence—such as letters to Bernard Frénicle de Bessy in 1658 and Pierre de Carcavi in 1659—that every natural number is the sum of at most four squares, asserting a proof via his method of infinite descent, though he provided no details and only applied descent to special cases like certain primes. Leonhard Euler took up the challenge in the mid-18th century, motivated by exchanges with dating back to 1729–1730. In memoirs published between 1749 and 1751 in the Commentarii Academiae Scientiarum Imperialis Petropolitanae, Euler established partial results, proving the theorem for numbers of specific forms (such as those not divisible by primes congruent to 3 4) and employing continued fractions alongside descent methods, but he could not complete the general case despite further efforts in the 1750s, including work related to primes of the form 4k+1. Joseph-Louis Lagrange resolved the conjecture in 1770 by submitting a complete proof to the Berlin Academy, which was published two years later in the academy's Nouveaux mémoires. Titled "Démonstration d'un théorème d'arithmétique," Lagrange's work built on Euler's partial advances and Fermat's descent techniques, providing the first rigorous general proof after over a century of intermittent progress since Bachet.

Proofs

Classical proof by Lagrange

Lagrange's proof reduces the problem to showing that every is a sum of four squares, leveraging the multiplicativity of the set of sums of four squares. This multiplicativity follows from Euler's four-square identity, which states that the product of two sums of four squares is itself a sum of four squares: (a2+b2+c2+d2)(e2+f2+g2+h2)=(aebfcgdh)2+(af+be+chdg)2+(agbh+ce+df)2+(ah+bgcf+de)2.(a^2 + b^2 + c^2 + d^2)(e^2 + f^2 + g^2 + h^2) = (ae - bf - cg - dh)^2 + (af + be + ch - dg)^2 + (ag - bh + ce + df)^2 + (ah + bg - cf + de)^2. The identity can be verified by direct expansion and was established by Euler in 1748. Since every factors uniquely into primes (up to units), and 1 = 1^2 + 0^2 + 0^2 + 0^2 is trivially a sum of four squares, it suffices to verify the theorem for the prime 2 and all odd primes p.[](Lagrange, J.-L. (1772). Démonstration d'un théorème d'arithmétique. Nouveaux mémoires de l'Académie royale des sciences et belles lettres de Berlin, 123–133.) For the prime 2, observe that 2=12+12+02+022 = 1^{2} + 1^{2} + 0^{2} + 0^{2}. Higher powers of 2 follow immediately from the identity: for example, 4=224 = 2 \cdot 2 yields a representation by substituting the values for 2 into the identity, and induction extends this to 2k2^{k} for any k1k \geq 1. A lemma handles even cases more generally: if n is even and a sum of four squares, then n/2n/2 is also a sum of four squares by pairing terms according to parity and applying algebraic identities for halves.[](Lagrange, 1772) For an odd prime p, the argument proceeds by infinite descent. First, establish that there exists a positive integer m with 0<m<p0 < m < p such that mp is a sum of four squares. This relies on a key lemma: there exist integers u and v, not both zero modulo p, such that u2+v21(modp)u^2 + v^2 \equiv -1 \pmod{p}. Setting a = u, b = v, c = 1, d = 0 then gives a2+b2+c2+d20(modp)a^2 + b^2 + c^2 + d^2 \equiv 0 \pmod{p}, with the representation nontrivial modulo p. The existence of such u and v follows from a pigeonhole principle argument establishing solutions to u2+v2+10(modp)u^2 + v^2 + 1 \equiv 0 \pmod{p}. Choosing representatives u, v between 0 and p-1 ensures the sum s=u2+v2+12+02s = u^2 + v^2 + 1^2 + 0^2 satisfies 0<s<2p2+10 < s < 2p^2 + 1, so s = mp with 1m<2p+1/p1 \leq m < 2p + 1/p, and m not divisible by p since the representation is nontrivial modulo p. Refinements using smaller representatives or additional pigeonhole applications can bound m<p/2m < p/2, but the descent handles larger initial m.[](Lagrange, 1772) Now suppose m is the smallest positive integer such that mp = x12+x22+x32+x42x_1^2 + x_2^2 + x_3^2 + x_4^2 for some integers x_i. The goal is to derive a contradiction if m > 1. Consider the residues of the x_i modulo m and select integers b_i with bim/2|b_i| \leq m/2 such that xibi(modm)x_i \equiv b_i \pmod{m} for each i (choosing the signed representative closest to zero). Then bi2xi20(modm)\sum b_i^2 \equiv \sum x_i^2 \equiv 0 \pmod{m}, so bi2=rm\sum b_i^2 = rm for some integer r with 0r4(m/2)2/m=m0 \leq r \leq 4(m/2)^2 / m = m. If r = 0, then all b_i = 0, so all xi0(modm)x_i \equiv 0 \pmod{m}, implying m^2 divides mp and thus m divides p; since p is prime and 1 < m < 2p, this is impossible. Hence r > 0 and r < m (strict inequality holds unless all |b_i| = m/2, which leads to a similar divisibility contradiction for odd m \geq 3 or even cases via the even lemma).[](Lagrange, 1772) To obtain a representation for rp, apply Euler's identity to the pairs (x_1, x_2, x_3, x_4) and (b_1, b_2, b_3, b_4), but with signs chosen on the b_i to ensure each bilinear term in the expansion is divisible by m (possible because the x_i generate the residues and m is minimal). The resulting four terms, say z_1, z_2, z_3, z_4, satisfy zk0(modm)z_k \equiv 0 \pmod{m} for each k, so zk2=(mp)(rm)=rm2p\sum z_k^2 = (mp)(rm) = r m^2 p is divisible by m^2, yielding integers y_k = z_k / m such that yk2=rp\sum y_k^2 = r p. This expresses rp as a sum of four squares with r < m, contradicting the minimality of m. Therefore, m = 1, and p itself is a sum of four squares. The process extends multiplicatively to all natural numbers.[](Lagrange, 1772)

Algebraic proof using Hurwitz integers

The Hurwitz integers form a subring of the Lipschitz quaternions, consisting of all quaternions of the form q=a+bi+cj+dkq = a + bi + cj + dk, where a,b,c,da, b, c, d are either all integers or all half-integers (i.e., integers plus 12\frac{1}{2}). This ring, denoted H\mathbb{H}, embeds naturally into the Hamilton quaternions over the rationals, providing an algebraic structure for extending integer arithmetic to four dimensions. The norm of an element qHq \in \mathbb{H} is defined as N(q)=a2+b2+c2+d2N(q) = a^2 + b^2 + c^2 + d^2, which is a non-negative integer and multiplicative: N(q1q2)=N(q1)N(q2)N(q_1 q_2) = N(q_1) N(q_2). A fundamental property of H\mathbb{H} is that it is a Euclidean domain with respect to the norm, meaning for any nonzero α,βH\alpha, \beta \in \mathbb{H}, there exist μ,ρH\mu, \rho \in \mathbb{H} such that α=μβ+ρ\alpha = \mu \beta + \rho with N(ρ)<N(β)N(\rho) < N(\beta). Consequently, H\mathbb{H} is a principal ideal domain (PID) and a unique factorization domain (UFD), allowing every nonzero element to factor uniquely into primes up to units. The units of H\mathbb{H} are the 24 elements with norm 1: the 8 integer units ±1,±i,±j,±k\pm 1, \pm i, \pm j, \pm k, and the 16 half-integer units of the form ±12±12i±12j±12k\pm \frac{1}{2} \pm \frac{1}{2} i \pm \frac{1}{2} j \pm \frac{1}{2} k (all sign combinations). The proof that every natural number nn is a sum of four squares proceeds by showing that n=N(q)n = N(q) for some qHq \in \mathbb{H}, leveraging the multiplicative norm and unique factorization. Since H\mathbb{H} is a PID, the principal ideal generated by a rational prime pp factors as (p)=(π1)(πr)(p) = (\pi_1) \cdots (\pi_r) for prime elements πi\pi_i, and taking norms yields p2=N(p)=N(πi)p^2 = N(p) = \prod N(\pi_i). Thus, each N(πi)=pN(\pi_i) = p (up to units of norm 1), so p=N(π)p = N(\pi) for some πH\pi \in \mathbb{H}. For composite nn, factor nn in Z\mathbb{Z} and use multiplicativity: if n=p1e1pkekn = p_1^{e_1} \cdots p_k^{e_k}, then n=N(q)n = N(q) where qq is a product of elements with norms pieip_i^{e_i}. Base cases confirm this for 1 (N(1)=1N(1) = 1) and primes. To establish that every rational prime pp has norm pp in H\mathbb{H}, classify the primes as follows: the prime 2 is ramified, since 2=i(1+i)22 = -i (1 + i)^2 (up to units), and N(1+i)=2N(1 + i) = 2. For odd primes, all split: no odd prime remains inert (i.e., prime) in H\mathbb{H}. Primes congruent to 1 modulo 4 factor as p=N(α)p = N(\alpha) for some Gaussian integer α=a+bi\alpha = a + bi extended by units to a Hurwitz integer, yielding p=a2+b2+02+02p = a^2 + b^2 + 0^2 + 0^2. For primes congruent to 3 modulo 4, there exist integers ll and mm such that 1+l2+m20(modp)1 + l^2 + m^2 \equiv 0 \pmod{p} (provable using the pigeonhole principle on the (p+1)/2(p+1)/2 quadratic residues to show 1-1 is a sum of two squares modulo pp). Thus, pp divides N(1+li+mj)N(1 + l i + m j). However, pp does not divide 1+li+mj1 + l i + m j (as its norm is pp), so pp is not prime in H\mathbb{H} and factors into elements of norm pp. This approach connects directly to Hamilton quaternions, where the norm preservation under multiplication reflects Euler's four-square identity: the product of two sums of four squares is again a sum of four squares, arising from N(q1q2)=N(q1)N(q2)N(q_1 q_2) = N(q_1) N(q_2). Unlike Lagrange's classical descent proof, which relies on elementary identities and infinite descent, the Hurwitz integer method offers algebraic elegance through ring-theoretic factorization, providing deeper insight into quadratic forms and composition algebras while avoiding tedious case analysis.

Representations

Number of representations

The number of integer solutions (a,b,c,d)Z4(a, b, c, d) \in \mathbb{Z}^4 to the equation a2+b2+c2+d2=na^2 + b^2 + c^2 + d^2 = n, counting all orders and signs (including zeros), is denoted by r4(n)r_4(n). This counts all possible ways to express nn as a sum of four squares of integers. In the 1830s, Carl Gustav Jacob Jacobi proved an exact formula for r4(n)r_4(n) in terms of the divisors of nn. Specifically, if nn is odd, then r4(n)=8dndr_4(n) = 8 \sum_{d \mid n} d; if nn is even, then r4(n)=24dnd odddr_4(n) = 24 \sum_{\substack{d \mid n \\ d \ odd}} d. Equivalently, r4(n)=8dn4ddr_4(n) = 8 \sum_{\substack{d \mid n \\ 4 \nmid d}} d for all positive integers nn. This formula arises from the generating function n=0r4(n)qn=θ3(q)4\sum_{n=0}^\infty r_4(n) q^n = \theta_3(q)^4, where θ3(q)=k=qk2\theta_3(q) = \sum_{k=-\infty}^\infty q^{k^2} is the Jacobi theta function of order 3. As a modular form of weight 2 for the congruence subgroup Γ0(4)\Gamma_0(4), θ3(q)4\theta_3(q)^4 expands via the of that group, yielding the divisor sum after equating coefficients. The function r4(n)r_4(n) is multiplicative: if gcd(m,n)=1\gcd(m,n)=1, then r4(mn)=r4(m)r4(n)r_4(mn) = r_4(m) r_4(n). Its average order is asymptotic to π22n\frac{\pi^2}{2} n, reflecting the geometric interpretation as the number of Z4\mathbb{Z}^4-lattice points inside a 4-dimensional ball of radius n\sqrt{n}
Add your contribution
Related Hubs
User Avatar
No comments yet.