The Supplementary Laws: (-1/p) and (2/p)
Fix an odd prime . For which primes can you write as a perfect square modulo ? For which can you write as a perfect square modulo ? These two questions look elementary. They concern only two fixed integers, and . Yet the answers turn out to be governed by a single elegant rule. Reduce modulo in the first case, and modulo in the second. This is the content of the supplementary laws to the Law of Quadratic Reciprocity. They are so named because they complete the reciprocity law. They handle the two cases (the residue and the prime ) that the main reciprocity statement between two odd primes does not directly cover. The stakes are higher than they first appear. Whether is a quadratic residue mod decides whether divides a sum of two squares with . This is the arithmetic engine behind Fermat's theorem on Sums of Two Squares. Whether is a quadratic residue mod governs the factorization of over . It also governs the splitting of primes in . It appears throughout the theory of quadratic forms and continued fractions. Both questions are special cases of the general reciprocity law. But they are proved independently, using Euler's Criterion and Gauss's Lemma. Historically, they were discovered and proved before the general law was fully established by Gauss. The big picture is this: Legendre introduced the symbol to encode quadratic residuacity. The quadratic reciprocity program asks how and relate for two odd primes . The supplementary laws answer the two questions that reciprocity between odd primes leaves open. What happens when one of the two numbers is (not itself a prime) or (the one prime reciprocity excludes)? Both laws admit slick, self-contained proofs via Gauss's Lemma. Both are indispensable tools used constantly in later theory. This article proves both supplementary laws completely, from Euler's Criterion and Gauss's Lemma, with full case analysis. It works out two nontrivial numerical examples. It explains exactly why each hypothesis (oddness of , primality) is needed. It previews how these laws feed into the full reciprocity law and the two-squares theorem.
- The first supplementary law says is a QR mod odd prime iff .
- The second supplementary law says is a QR mod odd prime iff .
- Both follow cleanly from Euler's Criterion (for ) and Gauss's Lemma (for ), with no need for the full reciprocity machinery.
- The formulas can be unified: and .
- These laws are the engine behind Fermat's Sums of Two Squares theorem and behind determining which primes split in and .
- They are the two special cases needed to complete the Law of Quadratic Reciprocity into a full algorithm for any Legendre symbol.
- Key idea: counting sign changes in Gauss's Lemma reduces both questions to simple congruence conditions on .
Where this lives today
The first supplementary law is the arithmetic core of Fermat's theorem on <a class="wiki-link" href="/wiki/math-numthy-sums-of-two-squares" data-track="wiki_article.body.wiki_link">Sums of Two Squares</a>: an odd prime is expressible as if and only if , and the "only if" direction, plus the key existence step in "if", both hinge on knowing when is a QR mod . This propagates into the theory of Gaussian integers , where a prime splits as a product of two conjugate Gaussian primes while remains inert — a basic case of splitting of primes in number fields. The second supplementary law governs splitting in the real quadratic ring and determines when factors mod , which matters for factoring polynomials over finite fields and for constructing explicit quadratic residue codes in coding theory. Both laws appear as base cases inside the full statement and every proof of the Law of Quadratic Reciprocity, and both are used as elementary building blocks in algorithms that compute Legendre and Jacobi symbols efficiently (used inside primality tests such as the Solovay–Strassen test and inside quadratic sieve / index calculus methods in computational number theory and cryptography). In cryptography specifically, fast Legendre-symbol evaluation via reciprocity (including these supplementary cases) underlies efficient square-root extraction modulo primes, which is a subroutine in some digital signature and key-exchange constructions. In physics and combinatorics, quadratic residues mod (whose basic behavior these laws pin down) appear in constructions of Paley graphs and difference sets with strong pseudorandomness properties.
Ask the tutor: How do the supplementary laws combine with the full reciprocity law to compute for a completely general integer ?
Let be an odd prime and let be an integer with . We say is a quadratic residue (QR) modulo if the congruence
has a solution ; otherwise is a quadratic non-residue (NQR) modulo . The Legendre symbol is defined by
The two supplementary laws determine and for every odd prime .
Intuition
Think of the nonzero residues modulo as forming a cyclic group of order under multiplication. Squaring is a group homomorphism from this cyclic group to itself, and its image — the quadratic residues — is exactly the unique subgroup of index . So exactly half of the nonzero residues are QRs and half are NQRs. The question "is a QR?" becomes: does , an element of order exactly (since and for odd), lie in that index- subgroup? Because the group is cyclic of order , the unique element of order lies in the subgroup of squares precisely when the group has an element of order dividing evenly — equivalently when . This is the group-theoretic shadow of the first supplementary law; Euler's Criterion makes it computational. The second law, about , has no such one-line group-theoretic shortcut — is just some element of the cyclic group, with no special algebraic distinction the way has order . Instead the proof goes through Gauss's Lemma, which counts how many of the "least positive residues" of modulo exceed ; the parity of that count is . This turns a group-theoretic question into an explicit counting problem, whose answer depends on because the count of "large" residues among depends on where falls relative to multiples of , and that pattern repeats with period in .
Central theorems
Let be an odd prime. Then
Equivalently: is a quadratic residue mod if and only if .
We use Euler's Criterion: for any odd prime and any integer with ,
(This is itself proved from Fermat's Little Theorem together with the fact that is cyclic of order , so that exactly for the quadratic residues, and for the rest, since satisfies hence , and the polynomial has at most one root class dividing residues evenly by Lagrange's theorem on polynomial roots mod .) Apply Euler's Criterion with :
Both sides of this congruence lie in , and is odd with , so ; two elements of that are congruent mod (with ) must be equal as integers, since their difference is or , and when is odd. Hence
Finally, is even iff , and odd iff (write or and compute or respectively). This gives the stated case formula.
∎Let be an odd prime and let be an integer with . Consider the integers
and let be their least positive residues mod (each ). Let be the number of these that satisfy . Then
(Gauss's Lemma is assumed known as a prerequisite; we use it as a black box below, together with a standard counting sublemma proved from it.)
Let be an odd prime. Then
Equivalently: is a quadratic residue mod if and only if .
We apply Gauss's Lemma with . Consider the integers
i.e. the even numbers . Since each of these already lies strictly between and , each one is its own least positive residue mod — no reduction is needed. So in the notation of Gauss's Lemma, the multiset is exactly the set of even integers in , and
We must count how many even integers lie strictly between and . Write , so the even numbers under consideration are and we want how many of exceed .
Case . Write . Then , and . The even numbers that exceed are , which is numbers. So , even, giving .
Case . Write . Then , and . Even numbers among exceeding are , which is numbers. So , odd, giving .
Case . Write . Then , and . Even numbers among exceeding are , which is numbers. So , odd, giving .
Case . Write . Then , and . Even numbers among exceeding are , which is numbers. So , even, giving . Combining the four cases: exactly when , and exactly when . Since every odd prime falls into exactly one of these four residue classes mod (odd numbers mod are ), this is a complete case analysis and proves the case formula.
The closed formula. It remains to check matches this in all four cases; note is always an integer here since is odd so (indeed any odd square is : and is even). Compute in each class:
- : , so , even. Matches .
- : , so , odd (since is even). Matches .
- : , so quotient , odd. Matches .
- : , so quotient , even. Matches .
All four cases agree with the case-by-case result above, so for every odd prime .
∎Worked examples
Example 1: Is a QR mod ? First check is prime: it is not divisible by (indeed , so trial division up to suffices), and one checks , , , , , , , , none integral, so is prime. Now , so . By the First Supplementary Law, : is a quadratic residue mod . Concretely this means there is an with . We can even locate it via Euler's Criterion by trial (or Tonelli–Shanks in practice), but the supplementary law guarantees existence without any search: since , Fermat's two-square theorem (whose proof uses exactly this fact) further guarantees for some integers ; indeed , matching . This is a preview of how the first supplementary law feeds directly into Sums of Two Squares.
Example 2: Is a QR mod ? First, is the Mersenne prime (a known prime, confirmed since has no small factors: not divisible by — checking so trial division to suffices, and one may directly verify is prime via known Mersenne prime tables). Compute . Since (check: , and ), we get . By the Second Supplementary Law, since , we get : is a quadratic residue mod . As a check via the closed formula: . Since we showed above this exponent is even, consistent with . This tells us, for instance, that is solvable — relevant to factoring over and to the splitting of in the ring : since is a nonzero square mod , the prime splits into two distinct prime ideals in rather than remaining inert.
Both supplementary laws require to be an odd prime. Drop oddness and let . The Legendre symbol is only conventionally defined for odd primes in the first place, precisely because the proof machinery (Euler's Criterion, the cyclicity of , Gauss's Lemma) all use that has even order so that "squares" form an index- subgroup and the sign dichotomy makes sense. For , is trivial (order ), every nonzero residue (just ) is trivially a square, and there is no even/odd dichotomy: the formula isn't even defined since . Concretely: is a "QR" mod ? We'd need , and indeed works — but this is vacuous, not governed by any condition (there's only one class mod among odd residues once you fix , the whole framework collapses). Similarly the Second Law's formula needs for , so the exponent isn't even an integer — the statement is simply not meaningful. This shows the hypothesis " odd" is not a technical nicety but load-bearing: it is what makes and integers and what makes have the right group structure (even order, hence an index-2 subgroup of squares) for the entire theory to make sense.
Scope, edge cases & common traps
| Situation | What happens | Correct handling |
|---|---|---|
| Legendre symbol undefined / laws not applicable | Treat separately; ramification of handled by different (discriminant) methods | |
| Legendre symbol is by convention | Not a QR or NQR; excluded from both laws | |
| Composite modulus | Legendre symbol not directly meaningful | Use the Jacobi symbol generalization instead, with care since Jacobi does not imply QR |
| Confusing "" with "" | Common mixing of the two laws' moduli | First law uses mod ; second law uses mod — they are genuinely different conditions |
| Assuming | False correlation | E.g. and (both ), but gives — independent conditions |
The mathematician behind it
Origins · 1 minCarl Friedrich Gauss and how this was discovered
Gauss gave the first fully rigorous proof of the Law of Quadratic Reciprocity in his Disquisitiones Arithmeticae (1801), eventually producing eight distinct proofs over his lifetime. The supplementary laws for and were known in special or conjectural form to Fermat and Euler earlier, but Gauss placed them on rigorous footing as part of his broader reciprocity program and introduced the lemma-based counting technique (Gauss's Lemma) used above.
Why do we need Euler's Criterion at all if Gauss's Lemma can handle any ?
Gauss's Lemma works for any including , but Euler's Criterion gives a one-line proof for specifically, since is trivial to compute, whereas running Gauss's Lemma's counting argument for requires tracking negative residues and is more cumbersome. Using the shortest correct tool for each case is standard practice: Euler's Criterion is optimal for , while Gauss's Lemma's residue-counting is the natural tool for , where there is no analogous instant algebraic shortcut. Both are legitimate; the choice reflects efficiency, not necessity.
Does knowing and let me compute for any ?
Not by themselves. These two laws only pin down the Legendre symbols of and . To compute for a general integer , factor into primes (and sign, and powers of ), use multiplicativity of the Legendre symbol, apply the supplementary laws to the and parts, and apply the full Law of Quadratic Reciprocity to relate to for each odd prime factor of . The supplementary laws are indispensable pieces of that larger algorithm, not substitutes for it.
Is there a slicker way to remember the second supplementary law's condition ?
Yes: note actually holds whenever (and when ), but the cleanest mnemonic is simply that are the two residue classes symmetric about and , i.e. "closest to a multiple of 8," while are "furthest." A common memory aid: is a QR; is a NQR. Pairing and (each pair summing to ) is the fastest way to recall the split.
Can both supplementary laws be derived as corollaries of the full quadratic reciprocity law instead?
The first supplementary law is genuinely independent and is proved directly from Euler's Criterion, as shown above; it is not a corollary of reciprocity between odd primes since reciprocity as usually stated concerns two odd primes, not . The second law, about the prime , is traditionally proved separately (via Gauss's Lemma, as here) precisely because is excluded from the "two odd primes" reciprocity statement. In the "supplemented" formulation of reciprocity, these two laws together with the odd-prime-pair law form a complete package; none is logically downstream of the others.
What happens if fails, i.e. we ask about divisible by ?
Then by convention , and neither supplementary law applies since both are statements about and specifically as nonzero residues mod an odd prime not dividing them. Since is odd, automatically (as ), and always, so this edge case never actually arises for the two specific values under the hypothesis " is an odd prime" — it is only a concern if you try to generalize the laws' proof technique (Gauss's Lemma) to other values of that might share a factor with .
How do these laws relate to continued fractions and Pell's equation?
Whether is a QR mod affects the factorization type of primes in , the ring of integers relevant to the Pell equation . Primes split in , which is tied to the existence of nontrivial solutions and to periodicity phenomena in the continued fraction expansion of modulo such primes. This is a preview connection into algebraic number theory and the theory of Sums of Two Squares and their real quadratic analogues, developed more fully once reciprocity is established in full generality.