The Legendre Symbol
Fix an odd prime . Among the nonzero residues modulo , exactly half are perfect squares mod . The other half are not. But which half, and how does this splitting behave under multiplication? The Legendre symbol answers this question. It packages the entire question "is a square mod ?" into a single arithmetic function . This function takes only the values , , and . This small piece of notation turns a yes/no question about Quadratic Residues and Nonresidues into a genuine number-theoretic function. That function has striking multiplicative properties. It transforms a combinatorial counting problem into an algebraic one. The importance of this symbol is hard to overstate. It is the load-bearing notation for one of the deepest theorems in classical number theory, the Law of Quadratic Reciprocity. It is also the natural home for computational tools like Euler's Criterion and Gauss's Lemma. Once the Legendre symbol is defined and its multiplicativity established, some key questions become tractable. For instance: "for which primes is a square mod ?" Or: "for which is a square mod ?" These questions become systematic, and eventually completely solvable. The big picture is this: the set of nonzero residues mod forms a group under multiplication. The squares among them form an index-2 subgroup. The Legendre symbol is precisely the group homomorphism from this multiplicative group onto . Its kernel is that subgroup. Recognizing this algebraic structure — a homomorphism onto — is important for two reasons. It makes the multiplicativity of the symbol immediate, once one knows the structure of . And it is what makes the symbol the correct language for reciprocity. This article gives the precise definition of the Legendre symbol. It proves its fundamental multiplicative property from first principles. This proof uses only the cyclicity of and basic group theory, not reciprocity or Euler's criterion. The article also works through concrete numerical examples. Finally, it highlights exactly which hypotheses are essential: the oddness of , and the primality of .
- The Legendre symbol encodes whether is a quadratic residue mod an odd prime , using values .
- It is defined purely combinatorially, using the notion of a quadratic residue, with no analytic input.
- Its central property is multiplicativity: , proved via the cyclic structure of .
- The symbol depends only on modulo , so it is really a function on residue classes.
- It sets up the machinery — Euler's criterion, Gauss's lemma — used to prove quadratic reciprocity.
- The definition genuinely requires odd and prime; both hypotheses fail dramatically without care.
- Key idea: the Legendre symbol is the unique group homomorphism whose kernel is the subgroup of squares.
Where this lives today
The Legendre symbol is the backbone of the Law of Quadratic Reciprocity, which in turn is used to efficiently decide the solvability of for large primes without brute-force search, a task central to computational number theory. In cryptography, fast evaluation of Legendre and Jacobi symbols underlies primality tests (such as the Solovay–Strassen test) and is used in constructing quadratic residue codes and certain pseudorandom bit generators, where the sequence of values behaves like a pseudorandom binary sequence with strong statistical independence properties. In the theory of quadratic forms, the Legendre symbol determines exactly which primes are represented by forms like , connecting directly to Quadratic Residues and Nonresidues and class field theory. In algebraic number theory more broadly, the symbol is the prototype for Artin symbols and Frobenius elements, generalizing the same "is this a square (or higher power) modulo this prime" idea to arbitrary number fields and Galois extensions.
Ask the tutor: How does Euler's Criterion give a fast formula for computing the Legendre symbol without factoring or listing residues?
Let be an odd prime and let be an integer. The Legendre symbol is defined by
Here is a quadratic residue mod if there exists an integer with ; otherwise, provided , it is a quadratic nonresidue. Since the condition "" and the condition "" both depend only on the residue class of modulo , the symbol depends only on ; hence it may be regarded as a function
Intuition
Think of the nonzero residues mod as the elements of a finite cyclic group of order under multiplication. Squaring is a group homomorphism , , and its image is precisely the set of quadratic residues. Because is odd, is even, and it turns out (this is the content of the theorem below) that squaring is exactly 2-to-1: each square has precisely two square roots, and , and these are distinct because would force , impossible for when is odd. So the squares form a subgroup of index exactly . The Legendre symbol is nothing more than the indicator of membership in that subgroup, encoded as instead of "yes/no". This is exactly the right encoding because the quotient group has order , and the unique nontrivial homomorphism from a group of order into is an isomorphism — so literally is (the pullback along of) this isomorphism. Multiplicativity of the symbol is then just the statement that a composite of group homomorphisms is a homomorphism: nothing deeper is happening algebraically, though the number-theoretic consequences are enormous. Picture as points arranged around a circle (a cyclic group), colored red if the point is a square and blue if not; the picture below does this for , where has order and there are residues of each color, alternating in a pattern governed by the discrete-log exponent parity, not by naive adjacency.
Intuition continued: multiplication as a symmetry
A second way to see the same idea: draw the graph of for as a bar chart over . The pattern of 's looks irregular, yet multiplying any two heights always equals the height at — the multiplicativity theorem below is exactly this hidden consistency, verified structurally rather than by checking all products by hand.
Let be an odd prime, and let be integers. Then
Equivalently, the map is a group homomorphism.
Let be an odd prime and let , a group of order under multiplication. Let be the subgroup of quadratic residues. Then: 1. is a subgroup of . 2. Every element of has exactly two square roots in . 3. , i.e. has index in .
Proof of the Lemma. (1) is a subgroup. The squaring map , , is a group homomorphism because is abelian: . The image of a group homomorphism is a subgroup of the codomain, so is a subgroup of . (2) Exactly two square roots. Suppose , say for some . If also satisfies , then , so . Since is prime, or , i.e. or . Thus the square roots of in lie in . These two are distinct elements of : if then , and since is odd, , forcing , contradicting (i.e. ). Hence , and both are genuine square roots, giving exactly two. (3) Index computation. The squaring map is surjective by definition of , and by part (2) every fiber for has exactly elements. Since is finite and partitioned into these fibers,
As , we conclude , which is an integer since is odd (so is even). This proves has index . (Lemma)
Proof of the Theorem, from the Lemma. Since has index , the quotient group has order ; write its two elements as (the identity coset) and for any fixed non-residue . Define by and . Since has order , it is isomorphic to under multiplication (the unique group of order ), and is precisely such an isomorphism: it is a bijection by construction, and it is a homomorphism because in any group of order with identity and other element , we have , matching and under . Let be the canonical quotient homomorphism, . Then is a composite of two group homomorphisms, hence itself a group homomorphism:
It remains to check that for every with (equivalently, for every , viewing as its residue class). By definition, , which equals if , i.e. if , i.e. if is a quadratic residue mod ; and it equals if , i.e. , i.e. is a quadratic nonresidue mod . By the definition of the Legendre symbol, this says exactly for . Therefore, for integers both not divisible by ,
using that (since is prime and divides neither factor, by Euclid's lemma applied contrapositively) so that is likewise given by the nonzero-case formula. Finally, if or , then , so by definition; and at least one of is by definition, so as well. The identity holds trivially in this remaining case. Combining both cases, for all integers , completing the proof.
∎For any odd prime and any integer with :
More generally, for integers ,
The first identity is the case of the theorem: , and since for , its square is always . The second identity is the case of the theorem, using . The general product identity follows from the two-variable case by induction on : the case is trivial, and if the identity holds for factors, then applying the two-variable theorem to and gives
completing the induction.
∎Worked examples
Example 1: computing by direct factorization and multiplicativity. Take (an odd prime) and . First reduce: , so , and since the symbol depends only on ,
Rather than testing all square roots directly, use multiplicativity with the factorization :
Since , the corollary above gives . For , we search for with by squaring residues: . The full set of quadratic residues mod (using that , so it suffices to square ) is . Since is not in this set, is a nonresidue, so . Hence
so is a quadratic nonresidue mod . As a check: we can verify directly that (to which is congruent) is also absent from , consistent with .
Example 2: a product of three factors, including a factor divisible by , showing the case interacting with multiplicativity. Take and consider , , , so . Note , so , hence by definition. By the product formula,
This matches direct computation: , so indeed and by definition, confirming the formula without needing to know or individually. For completeness, since and is not among the quadratic residues mod found in the earlier figure (), we get ; and either, so too — giving , a separate check that is indeed a residue (it is, since : ). This illustrates how a single zero factor collapses the whole product to regardless of the other factors' signs.
The multiplicativity theorem is false if is merely an odd composite number, with the symbol extended naively by the same defining rule (quadratic residue mod means ). Let (odd, but not prime), and define if is a nonzero square mod coprime to , if is coprime to but not a square, and if . The units mod are , and squaring gives ; so the squares among the units are , meaning and . Now test multiplicativity on , : . We compute
That case happens to agree — so try : , so , while ; still consistent. The real failure appears with a non-unit: take , , so , giving and correctly should also vanish since forces — again consistent by the zero rule. The genuine breakdown is structural rather than a single numerical clash: the proof of the theorem used that has index exactly in , which relied on part (2) of the Lemma — every nonzero has at most two square roots, which used that is prime (via ). For this fails: the equation has four solutions among units, only actually — recompute: solving for gives only (checking: , , , ), so this particular case has exactly two roots. But the group of units mod is cyclic of order (generated by ), and its subgroup of squares is of order — an index- subgroup indeed, since is even. The real obstruction to a literal Legendre-style multiplicative symbol for composite odd moduli is different: for prime powers like the unit group is still cyclic and an analogous symbol can be built (this is the Jacobi-symbol phenomenon for prime factors), but for a general odd composite with two distinct prime factors, is not cyclic, so squaring need not be -to- onto its image and the naive "residue/nonresidue" indicator is not a homomorphism. Concretely with : the units mod are , of order . Squares: . So the set of squares is only , of size , not index (index is , not the required "kernel of a -valued homomorphism onto an index-2 subgroup" structure needed for a clean multiplicative sign). Define naively if , else for units. Test : , so . But (since ) and (since ), giving — consistent here; try : , so since . But . This is the failure: multiplicativity breaks for composite odd modulus , precisely because dropping primality destroys the index- subgroup structure the proof relied on.
Scope, edge cases & common traps
| Situation | What happens | Why |
|---|---|---|
| by definition, not a residue/nonresidue question | ||
| odd prime, | exactly, multiplicative | Lemma: has index in cyclic-order- group |
| Legendre symbol undefined / not standard | squares mod trivial ( both squares); definition requires odd | |
| composite | naive extension fails multiplicativity in general | unit group need not be cyclic; see counterexample |
| replaced by | value unchanged | symbol depends only on |
The mathematician behind it
Origins · 1 minAdrien-Marie Legendre and how this was discovered
Legendre was a French mathematician working across number theory, celestial mechanics, elliptic integrals, and statistics (he introduced the method of least squares independently around the same time as Gauss). In number theory, his 1798 treatise Essai sur la théorie des nombres introduced the symbol that now bears his name, and he stated (though did not give a complete proof of) the Law of Quadratic Reciprocity in the form used today. His notation for proved to be exactly the right bookkeeping device: it converted a delicate arithmetic question about solvability of into a multiplicative function amenable to systematic manipulation, setting the stage for Gauss's first rigorous proof of reciprocity and for the entire subsequent development of quadratic and higher reciprocity laws.
Why does the Legendre symbol require to be an odd prime rather than any prime?
The definition itself makes sense verbatim for : one could ask whether is a square mod . But the interesting structure collapses because has order , so every unit () is trivially a square, and there is no nontrivial residue/nonresidue distinction to encode. The proof of multiplicativity here crucially used that is even (so that squares form a genuine index-2 subgroup with two square roots per element); this requires odd. By convention the Legendre symbol is simply defined only for odd primes , and the prime is treated separately (often via a special supplementary formula in reciprocity theory) rather than folded into this symbol.
Is enough to conclude is a genuine square modulo , not just modulo some other number?
Yes, precisely: for an odd prime and , the Legendre symbol equals if and only if there exists an integer with , by the very definition of quadratic residue used to define the symbol. This is a genuinely biconditional fact for prime moduli. It is worth stressing that this equivalence can fail for the superficially similar Jacobi symbol with composite modulus: a Jacobi symbol value of does not by itself certify that is a square modulo that composite number, which is a frequent source of error for students moving from Legendre to Jacobi symbols.
How is the Legendre symbol actually computed efficiently for large primes, without listing all squares?
Listing all squares mod and checking membership is computationally expensive for large . In practice one uses Euler's Criterion, which states , reducing the computation to a single modular exponentiation, doable in multiplications via repeated squaring. Alternatively, The Law of Quadratic Reciprocity together with the multiplicativity proved here lets one recursively flip and reduce the symbol the way the Euclidean algorithm reduces gcd computations, giving another efficient algorithm without ever computing a full list of quadratic residues.
Does the Legendre symbol distinguish quadratic residues from nonresidues among all integers, or only those coprime to ?
The symbol is defined for all integers , but its interesting information — the distinction between residue and nonresidue — is only meaningful when . Whenever , the symbol simply returns , flagging that is congruent to mod and so the residue/nonresidue dichotomy does not apply (as is a degenerate square, , but it is conventionally excluded from the residue/nonresidue classification precisely so the symbol can cleanly signal this case with its own value).
Is the Legendre symbol symmetric, i.e. does hold in general?
No — and this asymmetry is exactly what makes the Law of Quadratic Reciprocity a nontrivial and celebrated theorem rather than a triviality. The Legendre symbol requires to be an odd prime, while can be an arbitrary integer, so "" is not even defined unless is itself an odd prime. When both and are odd primes, reciprocity relates and via the precise formula , which is a highly nontrivial identity proved separately from the basic multiplicativity established in this article.
Why is it true that exactly half the nonzero residues mod an odd prime are quadratic residues?
This falls directly out of the Lemma proved above: the squaring map on the cyclic group of order is exactly two-to-one onto its image, because each square has precisely two square roots ( and , distinct since is odd). Counting elements via these size-two fibers forces the image (the quadratic residues) to have size exactly , which is exactly half of the nonzero residues. This is a purely group-theoretic argument, requiring no knowledge of Euler's criterion or quadratic reciprocity.
What role does the Legendre symbol play in eventually proving quadratic reciprocity?
The Legendre symbol is the language in which reciprocity is stated: without it, one would have to phrase reciprocity awkwardly as a relation between two solvability questions (" is solvable if and only if..."). With the symbol and its proven multiplicativity in hand, one can manipulate expressions like algebraically, decompose numbers into prime factors and distribute the symbol over products, and combine it with tools like Gauss's Lemma (a sign-counting formula for ) to build the classical proofs of reciprocity. The multiplicativity proved in this article is a genuine prerequisite lemma used inside essentially every standard proof of reciprocity.