A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Lagrange's Four-Square Theorem

Graduate Depth 77 in the knowledge graph I know this Set as goal
1topic build on this
368prerequisites beneath it
See this on the map →
Fundamental Theorem of Arithmetic (Rigorous)Sum of Two Squares Theorem
representations quadratic-forms diophantine

Core Idea

Every non-negative integer can be expressed as a sum of four squares. While the sum-of-two-squares theorem characterizes which numbers require four squares, Lagrange's result guarantees that four always suffice, contrasting sharply with two-square representations.

Explainer

The question "which integers are sums of squares?" has a satisfying but incomplete answer for two squares, and a complete answer for four. A number is a sum of two squares if and only if every prime of the form 4k + 3 appears to an even power in its factorization — so 5 = 1² + 2² works, but 3 does not (and cannot). Many integers simply cannot be written as a sum of two squares. Three squares handle more cases, but still fail for numbers of the form 4ᵃ(8b + 7). Lagrange's four-square theorem closes the door entirely: four squares always suffice, no matter the integer.

The proof strategy centers on two key ingredients. First, it suffices to prove the theorem for prime numbers, because if n = a² + b² + c² + d² and m = e² + f² + g² + h², then the product nm is also a sum of four squares — this follows from the Euler four-square identity, an algebraic identity involving quaternion-like multiplication. So if every prime is a sum of four squares, every integer is too (via its prime factorization).

Second, every prime p is shown to be a sum of four squares by a counting argument. Consider the sets {a² mod p} and {−1 − b² mod p} for a, b ranging from 0 to (p−1)/2. Each set has (p+1)/2 elements, and together they contain more than p values, so by the pigeonhole principle they must overlap: there exist a, b with a² ≡ −1 − b² (mod p), giving a² + b² + 1 ≡ 0 (mod p). This produces mp = a² + b² + 0² + 1² for some m < p, and then a descent argument (reducing m step by step) shows p itself is a sum of four squares.

What makes this theorem philosophically satisfying is its universality. Unlike the two-square case, there are no exceptions, no congruence conditions, no special forms to check. Any positive integer you can name — whether it is 7 (= 4 + 1 + 1 + 1), or 15 (= 9 + 4 + 1 + 1), or any prime of the form 4k + 3 — can be expressed as four squares. The theorem also opens the door to Waring's problem: if four squares always suffice, what is the analogous result for cubes, fourth powers, and beyond? The four-square theorem is both a complete answer and a beginning.

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesSet Operations: Union, Intersection, and ComplementProof by CasesProving by Cases and ExhaustionVacuous Truth and Trivial CasesProof by Cases (Proof by Exhaustion)Mathematical InductionDivisibility and Greatest Common DivisorThe Fundamental Theorem of ArithmeticFundamental Theorem of Arithmetic (Rigorous)Lagrange's Four-Square Theorem

Longest path: 78 steps · 368 total prerequisite topics

Prerequisites (1)

Leads To (1)