ArticleslgStudy

mathematics

Lagrange's four-square theorem

Lagrange's four-square theorem is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Lagrange's four-square theorem rather than just read about it. In short: 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. That is, the squares form an additive basis of order four: p=a2+b2+c2+d2, where the four numbers a,b,c,d are integers.

Lagrange's four-square theorem — main illustration
Lagrange's four-square theorem — illustration

Key takeaways

  • Lagrange's four-square theorem belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Lagrange's four-square theorem to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Lagrange's four-square theorem from memory before moving on to harder problems.

Reference excerpt

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. That is, the squares form an additive basis of order four: p=a2+b2+c2+d2, where the four numbers a,b,c,d are integers. For illustration, 3, 31, and 310 can be represented as the sum of four squares as follows: 3=12+12+12+0231=52+22+12+12310=172+42+22+12=162+72+22+12=152+92+22+02=122+112+62+32. This theorem was proven by Joseph-Louis Lagrange in 1770. It is a special case of the Fermat polygonal number theorem.

Historical development 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. 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 4k(8m+7) 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.

Proofs

The classical proof Several very similar modern versions 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.

Proof using the Hurwitz integers Another way to prove the theorem relies on Hurwitz quaternions, which are the analog of integers for quaternions.

Generalizations 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 a,b,c,d, can we solve n=ax12+bx22+cx32+dx42 for all positive integers n in integers x1,x2,x3,x4? The case a=b=c=d=1 is answered in the positive by Lagrange's four-square theorem. The general solution was given by Ramanujan. He proved that if we assume, without loss of generality, that a≤b≤c≤d then there are exactly 54 possible choices for a,b,c,d such that the problem is solvable in integers x1,x2,x3,x4 for all n. (Ramanujan listed a 55th possibility a=1,b=2,c=5,d=5, but in this case the problem is not solvable if n=15.)

Algorithms In 1986, Michael O. Rabin and Jeffrey Shallit proposed randomized polynomial-time algorithms for computing a single representation n=x12+x22+x32+x42 for a given integer n, in expected running time O(log2(n)). It was further improved to O(log2(n)log⁡(log⁡(n))−1) by Paul Pollack and Enrique Treviño in 2018.

Number of representations

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. r4(n)={8∑m∣nmif n is odd24∑m|nm oddmif n is even. Equivalently, it is eight times the sum of all its divisors which are not divisible by 4, i.e. r4(n)=8∑m:4∤m∣nm. We may also write this as r4(n)=8σ(n)−32σ(n/4) , 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). 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 8√log n.

Uniqueness 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 2(4k),6(4k) or 14(4k). 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 2(4k),6(4k) or 14(4k).

Further refinements Lagrange's four-square theorem can be refined in various ways. For example, Zhi-Wei Sun 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 |S|=O(n1/4log1/4n) such that every positive integer smaller than or equal to n can be written as a sum of at most 4 elements of S.

See also Fermat's theorem on sums of two squares Fermat's polygonal number theorem Waring's problem Legendre's three-square theorem Sum of two squares theorem Sum of squares function 15 and 290 theorems

Notes

… excerpt ends here. Continue reading the full article.

Illustrations

Lagrange's four-square theorem: 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
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

Worked examples

Example 1 — a first encounter with Lagrange's four-square theorem

Start with the simplest possible case. Write down what Lagrange's four-square theorem claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Lagrange's four-square theorem before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Lagrange's four-square theorem ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Lagrange's four-square theorem

In research
Lagrange's four-square theorem appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Lagrange's four-square theorem in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Lagrange's four-square theorem is common in secondary-school and first-year university syllabi. It links to neighbouring topics Additive number theory, Squares in number theory, Theorems in number theory, so understanding it makes those chapters shorter.
In everyday life
Look for Lagrange's four-square theorem outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Lagrange's four-square theorem” →

How to study Lagrange's four-square theorem in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Lagrange's four-square theorem means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Lagrange's four-square theorem out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Lagrange's four-square theorem in simple terms?

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. That is, the squares form an additive basis of order four: p=a2+b2+c2+d2, where the four numbers a,b,c,d are integers.

Why does Lagrange's four-square theorem matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Lagrange's four-square theorem?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Lagrange's four-square theorem.

Tags

  • Additive number theory
  • Squares in number theory
  • Theorems in number theory

Keep exploring