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 Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Set Operations: Union, Intersection, and Complement → Proof by Cases → Proving by Cases and Exhaustion → Vacuous Truth and Trivial Cases → Proof by Cases (Proof by Exhaustion) → Mathematical Induction → Divisibility and Greatest Common Divisor → The Fundamental Theorem of Arithmetic → Fundamental Theorem of Arithmetic (Rigorous) → Lagrange's Four-Square Theorem

Longest path: 78 steps · 368 total prerequisite topics

Prerequisites (1)

Leads To (1)