Contents / Number Theory / Classical Theorems
Chapter 3
Classical Theorems
Fermat's little theorem proved twice, by rearranging residues and via Lagrange; Euler's generalisation; Wilson's theorem in both directions; why the Fermat primality test fails, with Korselt's criterion and 561 worked; and quadratic reciprocity proved in full through Gauss's lemma and Eisenstein's lattice-point count, with both supplementary laws.
Introduction
Three theorems carry most of the weight of elementary number theory, and this chapter proves all three. Fermat's little theorem says that raising to the power modulo a prime always returns ; Wilson's theorem evaluates the factorial modulo exactly, and does so in a way that detects primality; and quadratic reciprocity relates the solvability of to the solvability of , a symmetry between two unrelated-looking questions that Gauss called the theorema aureum and proved eight times.
What ties them together is a single technique, used over and over: take a finite set of residues, act on it by multiplication, and observe that the action only permutes the set. Nothing is created or destroyed, so the product of the set is unchanged, and comparing the two expressions for that product yields a congruence. Fermat's little theorem is that argument applied to multiplication by ; Wilson's theorem is that argument applied to inversion; Gauss's lemma is that argument applied to multiplication by on a half-system of residues. Once the pattern is visible, the chapter is one idea told three times, each time with a sharper conclusion.
The chapter is a proof showcase, so almost every statement below is proved rather than quoted. The two exceptions are flagged where they occur: the sign of the quadratic Gauss sum, which needs analysis outside the scope of these pages, and one alternative route to reciprocity that is given as an explicitly labelled sketch. Everything else — including quadratic reciprocity itself, via Gauss's lemma and Eisenstein's lattice-point count — is argued in full.
We assume the language of congruences and the structure of as developed in Modular Arithmetic, and the multiplicativity of Euler's totient from Arithmetic Functions. From abstract algebra we shall use Lagrange's theorem once, by name, and note carefully where the elementary argument replaces it.
Throughout, and denote odd primes unless stated otherwise, a positive integer, and the greatest common divisor.
3.1Fermat's Little Theorem: Statement and First Proof
The theorem has two forms. The first is the one that does the work; the second is the one that is true without exception, and the two are equivalent in a single line.
Theorem 3.1 (Fermat's little theorem). Let be a prime and let be an integer with . Then
Proof. Consider the numbers
reduced modulo . Two claims about this list.
Every entry is nonzero modulo . If for some then, being prime, or . The first is impossible because , and the second contradicts .
The entries are pairwise distinct modulo . If then , and as we get ; since this forces .
So the list consists of distinct nonzero residues modulo . There are exactly such residues, namely , so the list is that set, merely rearranged. Multiplying all the entries of a set does not depend on the order in which they are listed, so
that is,
Finally is a product of integers none of which is divisible by , so and we may cancel it from both sides, leaving .∎
The last step is where primality is used a second time, and it is worth pausing on: cancelling a factor from a congruence is legal only when that factor is invertible modulo the modulus. The argument is a template — permute, multiply, cancel — and every other theorem in this chapter is a variation on it.
Corollary 3.2 (Universal form). For every prime and every integer ,
Proof. If , multiply the congruence of the theorem Fermat's little theorem through by . If instead , then as well, so both sides are and the congruence holds trivially. Since is prime these two cases are exhaustive.∎
Pitfall. The first form genuinely needs : with , we have , not . Only the universal form survives without the hypothesis. A student who remembers "the exponent is " and forgets the coprimality has a statement that is false for a positive proportion of inputs.
Intuition. Multiplying by a fixed invertible shuffles the deck of nonzero residues without losing a card. Do it times and the running product of the whole deck has been multiplied by — but the deck is the same deck, so its product never changed. Hence must have been all along.
Example 3.3 (Both forms for , ). Verify and by hand.
Solution.
- Square up: , so , and .
- Multiplying by gives , the universal form.
- As a check on the proof, the shuffled list reduces mod to — the residues through in a new order, exactly as the argument claims.
3.2Fermat via Lagrange, and Euler's Generalisation
The elementary proof above is self-contained, but it hides the reason the exponent is . That reason is structural: is the size of a group, and a general theorem says the size of a group annihilates each of its elements.
Definition 3.4 (Multiplicative order). Let . The order of modulo , written , is the least positive integer with
It exists because the powers take finitely many values, so for some , and cancelling the invertible gives .
Proposition 3.5 (The order divides every annihilating exponent). Let and . For an integer ,
Proof. () If then .
() Divide with remainder: with . Then
So with . Minimality of among positive exponents forces , hence .∎
Theorem 3.6 (Fermat's little theorem, second proof). Let be prime and . Then .
Proof. The set of nonzero residue classes modulo is a group under multiplication: it is closed because is prime and therefore has no zero divisors, associativity and the identity are inherited from , and each class with has an inverse because gives for some integers , whence . Its order is .
The cyclic subgroup generated by has exactly elements, namely , which are pairwise distinct: if with then with , contradicting minimality.
By Lagrange's theorem, the order of a subgroup divides the order of the group, so . By the proposition The order divides every annihilating exponent applied with , we conclude .∎
Remark. Compare the two proofs. The elementary one shows that ; the group-theoretic one shows why the exponent is and immediately tells you more — that the true exponent for a given is a divisor of , and that is the size of the cyclic group generates. The elementary proof does not see the divisibility at all. This is the usual trade: the first argument is shorter, the second is a machine.
Once the exponent is identified as the size of the unit group, the generalisation to a composite modulus writes itself. Only the count changes.
Definition 3.7 (Euler's totient). For , is the number of integers in that are coprime to ; equivalently . For a prime power, , and is multiplicative on coprime arguments, as proved in Arithmetic Functions.
Theorem 3.8 (Euler's theorem). If then
Proof. We repeat the rearrangement argument, with the reduced residue system in place of . Let be the integers in coprime to , one from each invertible class.
The list again consists of classes coprime to : and give .
The entries are pairwise distinct modulo : if then, multiplying by an inverse of modulo (which exists since ), , so .
So is a set of distinct invertible classes, hence all of them, and is a permutation of modulo . Taking products,
Each is invertible modulo , hence so is the product, and cancelling it gives the claim.∎
Corollary 3.9 (Euler implies Fermat). Taking prime in Euler's theorem recovers Fermat's little theorem.
Proof. For prime every one of is coprime to , so , and the congruence becomes .∎
Example 3.10 (An order computation). Find and check the divisibility predicted by Lagrange's theorem.
Solution.
- The order must divide , so it lies in .
- . Since , the order is not or .
- From we get , so the order divides ; combined with step 2 it is exactly .
- Indeed , as required, and .
Example 3.11 (Inverses for free). Use Fermat's little theorem to invert modulo without the Euclidean algorithm.
Solution.
- Since is prime and , we have , so is the inverse of .
- Compute by squaring: , , , .
- Then , so . Step by step: ; ; .
- Check: . The inverse is .
3.3The Fermat Primality Test and Its Failure
Fermat's little theorem is a statement about primes, so its contrapositive is a test for compositeness: if for some coprime to , then is certainly not prime. The test is cheap — one modular exponentiation — and it never lies in that direction. The question is what a pass is worth.
Definition 3.12 (Fermat witness and Fermat liar). Let be composite and . The base is a Fermat witness for if
and a Fermat liar if . If is composite and is a liar, is called a Fermat pseudoprime to base .
Example 3.13 (The smallest pseudoprime to base 2). Show that is a Fermat pseudoprime to base , and find a witness.
Solution.
- , so .
- Since , we get : base is a liar and passes the test.
- Try base . Modulo , ; modulo , and , so . Now , , .
- So , hence : base is a witness and is exposed as composite.
That failure is repairable by trying more bases — provided witnesses are plentiful. The next proposition says that they are, in a strong sense, whenever there is even one.
Proposition 3.14 (Liars form a subgroup, so witnesses are abundant). Let be composite and let
Then is a subgroup of . Consequently either is the whole group, or at most half of all coprime bases are liars.
Proof. since . If then , so . And if with inverse , then , so . Hence is a subgroup.
By Lagrange's theorem the index divides and is at least as soon as is proper. Therefore whenever a single witness exists.∎
So the test is excellent — a single random base exposes a composite with probability at least , and independent bases with probability at least — except on the composites where is everything. Those exist.
Definition 3.15 (Carmichael number). A composite is a Carmichael number if
that is, if every coprime base is a liar and the Fermat test fails for no matter how many bases are tried.
Theorem 3.16 (Korselt's criterion). A composite is a Carmichael number if and only if is squarefree and
Proof. () Suppose with the distinct primes and for each . Let ; then for every . Write . By Fermat's little theorem,
for each . The are distinct primes whose product is , so a number congruent to modulo each of them is congruent to modulo . Hence for every coprime .
() Suppose is Carmichael. We use the existence of primitive roots modulo for odd , from Modular Arithmetic.
is squarefree. Suppose not, so with and . Choose a primitive root modulo , so , and use the Chinese remainder theorem to pick with and . Then , so and in particular modulo . By the proposition The order divides every annihilating exponent, , so (using ). But , so , absurd. (If the same contradiction arrives faster: forces odd while must divide it.) Hence is squarefree.
The divisibility. Let and write with , possible because is now known squarefree. Choose a primitive root modulo and, by the Chinese remainder theorem, an with and . Then , so and hence modulo . Since , the proposition The order divides every annihilating exponent gives .∎
Example 3.17 (Why fools every base). Verify by Korselt's criterion that is a Carmichael number, and check the conclusion directly on the base .
Solution.
- Factor: . The three primes are distinct, so is squarefree.
- . Check each prime: gives and ; gives and ; gives and . All three divide .
- By Korselt's criterion is a Carmichael number: for all coprime bases.
- Direct check for : modulo , ; modulo , ; modulo , . Congruent to modulo , and , hence modulo their product .
- Note that is nevertheless trivially composite — divides it. The Fermat test is blind to this because is not a coprime base, and the test only examines coprime bases.
Proposition 3.18 (A Carmichael number has at least three prime factors). No Carmichael number is a product of exactly two distinct primes.
Proof. Suppose with primes were Carmichael. By Korselt's criterion . Now
and , so . But , and a positive integer cannot divide a smaller positive integer. Contradiction. Since Korselt's criterion also forces squarefreeness, a Carmichael number is a product of at least three distinct primes.∎
Pitfall. Passing the Fermat test to many bases is evidence of primality, never a proof. The Carmichael numbers are infinite in number, so no fixed finite set of bases makes the Fermat test into a primality proof. The repair is the Miller–Rabin test, which examines square roots of along the way and has no analogue of the Carmichael numbers.
3.4Reducing Exponents with Fermat and Euler
The practical content of the two theorems is that exponents live modulo (or ), not modulo . This is the single most common working use of the chapter.
Proposition 3.20 (Exponent reduction). Let and let with . Then
In particular, for prime and , .
Proof. Say and write with . By Euler's theorem,
The prime case is .∎
Pitfall. The reduction is on the exponent modulo , and it needs . Reducing an exponent modulo instead is a common and disastrous slip: uses , not . The first gives , the second the wrong value .
Method 3.21 (Evaluating by hand).
- Check . If not, factor and work modulo each prime power separately.
- Compute — for prime this is .
- Replace by .
- Compute by repeated squaring, reducing after every multiplication.
Example 3.22 (A large power modulo a prime). Compute .
Solution.
- is prime and , so exponents reduce modulo .
- , so .
- , , .
- .
Example 3.23 (The last two digits of a tower). Find the last two digits of .
Solution.
- The last two digits are the value modulo , and , so we need the exponent modulo .
- and , so — no reduction yet, so compute directly: , , hence .
- So .
- Compute: , . Then , so .
- The last two digits are .
Proposition 3.24 (Inversion by exponentiation). If is prime and then is the inverse of modulo ; more generally, if then is the inverse of modulo .
Proof. by Euler's theorem, and an element with a right inverse in the commutative group has that element as its inverse. For prime, .∎
Remark. This is how a fixed-modulus implementation avoids the extended Euclidean algorithm: one exponentiation with a constant exponent is branch-free, which matters when the branches would leak the secret. It is also the identity that makes RSA decryption work — the decryption exponent satisfies , so by the proposition Exponent reduction.
3.5Wilson's Theorem: Statement
Fermat's theorem evaluates a power modulo . Wilson's theorem evaluates a factorial modulo — and unlike Fermat's, it is an exact characterisation of the primes, with no Carmichael numbers to spoil it.
Theorem 3.25 (Wilson's theorem). Let be an integer. Then
The two directions are genuinely different arguments and are proved separately below: the forward direction in the section on pairing residues with their inverses, the converse by showing that a composite makes divisible by outright. Before the proofs, some arithmetic to see what the statement is claiming.
Example 3.26 (Small cases by hand). Evaluate for and read off the pattern.
Solution.
- : . Prime, and here.
- : . Prime.
- : . Composite — and note the value is , neither nor .
- : . Prime.
- : . Composite.
- : . Prime.
- The pattern: primes give , composites give , and is the lone exception giving .
Remark. The case is a real exception and must be stated. It is the only composite for which is not divisible by , because contains the factor only once while needs it twice. Every composite above has enough room below it, as the proof of the theorem Composite moduli kill the factorial makes precise.
Intuition. In the list every element has a multiplicative partner that cancels it. Pair everyone off and the whole product collapses to — except that two elements, and , have no partner but themselves. Their product is , and that is the whole answer.
3.6Prime Implies the Congruence
The proof is the permute, multiply, cancel template again, with the permutation being inversion . The one thing to get right is which elements are fixed by that permutation.
Lemma 3.27 (Self-inverse residues modulo a prime). Let be prime and . Then
and for these are the two distinct residues and .
Proof. means . Since is prime, Euclid's lemma gives or , that is or . Conversely both of those clearly square to .
For the residues and are distinct, since would mean . For they coincide.∎
Pitfall. This lemma is exactly where primality enters, and it is exactly what fails for a composite modulus. Modulo the equation has four solutions, , because can be arranged by splitting the two factors between and . A pairing argument run modulo therefore leaves four unpaired elements, not two, and gives a different answer.
Theorem 3.28 (Prime implies Wilson's congruence). If is prime then
Proof. For the claim is , true. Assume is odd.
Every is coprime to , hence invertible modulo , and its inverse is again a residue in that range; write it . The map is a bijection of the set onto itself, being its own inverse.
By the lemma Self-inverse residues modulo a prime, the only fixed points of this map — the with , equivalently — are and . Therefore the remaining elements
are partitioned into unordered pairs with , each pair having product . Note is even because is odd, so the partition uses up every element.
Multiplying everything in therefore gives
since .∎
Corollary 3.30 (Value of ). For every prime ,
Proof. . By the theorem Prime implies Wilson's congruence the left side is , so and, multiplying by , .∎
Example 3.31 (Wilson in reverse). Compute and .
Solution.
- is prime and , so by the corollary Value of , .
- For the second, is prime, so and .
- Modulo : , , , so .
- Thus , i.e. , so is the inverse of .
- , so .
3.7The Converse: Composite Moduli
For the converse it is easier to prove something stronger than the negation of : for composite the factorial is not merely different from , it is .
Theorem 3.32 (Composite moduli kill the factorial). Let be composite. Then
Proof. Since is composite, write with . Two cases.
Case 1: . Then and are two distinct integers, both lying in , so both occur as separate factors in the product . Hence divides .
Case 2: , so with . If then , excluded by hypothesis, so . Then
because . So and are two distinct integers in the range , and both appear as factors of . Their product therefore divides , and in particular .
In both cases .∎
Remark. The hypothesis is used only in Case 2, and only to get . At the argument breaks exactly where the arithmetic does: and is not below , so the second copy of the factor is unavailable, and indeed .
Corollary 3.33 (Wilson's theorem, both directions). For , if and only if is prime.
Proof. () Suppose and were composite. If , the theorem Composite moduli kill the factorial gives , so , i.e. , impossible for . The only composite is , where . So is prime.
() This is the theorem Prime implies Wilson's congruence.∎
Corollary 3.34 (A primality criterion). The function
distinguishes primes from composites for : it equals when is prime and when is composite.
Proof. If is prime then and , since any common divisor divides their difference . If is composite then by the theorem Composite moduli kill the factorial, and .∎
Pitfall. Wilson's criterion is a perfect primality test and a useless one. Computing takes about multiplications, which is exponential in the number of digits of — far worse than trial division to . Its value is theoretical: it is the statement that primality is detectable by a single congruence, with no exceptional composites.
Example 3.35 (Composite cases in detail). Verify the theorem Composite moduli kill the factorial for and for , identifying the factors the proof uses.
Solution.
- with , so Case 1 applies: the factors and both appear in , hence .
- Indeed , so .
- , so Case 2 applies with : the factors and both appear in and is a multiple of .
- Indeed , so .
3.8Relations to Fermat, Euler and Quadratic Residues
Wilson's theorem is not an isolated curiosity. Combined with Fermat's little theorem it produces the criterion that governs the whole second half of this chapter, and it produces, out of nowhere, an explicit square root of modulo any prime .
Definition 3.36 (Quadratic residue). Let be an odd prime and . Then is a quadratic residue modulo if the congruence has a solution, and a quadratic non-residue otherwise.
Proposition 3.37 (Exactly half the residues are squares). For an odd prime , exactly of the residues are quadratic residues modulo .
Proof. Consider the squaring map , . Its image is exactly the set of quadratic residues. For nonzero, means , hence by Euclid's lemma. Since is odd, (that would force ), so each fibre has exactly two elements. A map from a set of size all of whose fibres have size has image of size .∎
Theorem 3.38 (Euler's criterion). Let be an odd prime and . Then
Proof. Put . By Fermat's little theorem , so by the lemma Self-inverse residues modulo a prime, or , and these are distinct because is odd. So the only question is which.
Residues give . If with , then by Fermat's little theorem.
Nothing else gives . The polynomial has degree over the field , so it has at most roots there — a nonzero polynomial over a field has at most many roots, as proved in Polynomial Rings and Unique Factorization. By the previous paragraph every one of the quadratic residues is a root, and by the proposition Exactly half the residues are squares there are exactly that many of them. So the residues exhaust the roots, and every non-residue has , hence .∎
Corollary 3.39 (Wilson produces a square root of ). Let be prime and set . Then
so is an explicit square root of modulo .
Proof. Group the factors of in pairs and for :
By the theorem Prime implies Wilson's congruence the left side is . Since , is even, so and we get .∎
Remark. For the same computation gives , so — no square root of appears, and by the corollary about to be proved in the section on supplementary laws, none can: is a non-residue there. Wilson's theorem therefore knows the first supplementary law already.
Example 3.40 (An explicit square root of ). Find a square root of modulo using the corollary Wilson produces a square root of , and check it.
Solution.
- , so the corollary applies with .
- . Reduce: , so .
- Check: . Correct.
- The other square root is , and indeed .
3.9Quadratic Reciprocity: The Statement
Euler's criterion turns the yes/no question "is a square mod ? " into a -valued computation. Naming that value makes the answer multiplicative, and multiplicativity is what makes a fast algorithm possible.
Definition 3.41 (Legendre symbol). Let be an odd prime. For an integer define
Proposition 3.42 (Basic properties of the Legendre symbol). Let be an odd prime and integers. Then
Proof. The first is exactly Euler's criterion when , and both sides are when .
For multiplicativity, if divides or both sides are . Otherwise, by the first property,
Both sides are , so their difference is , or ; it is divisible by the odd prime , hence it is and the two sides are equal as integers.
The third property holds because whether is solvable depends only on the class of modulo .∎
Remark. Multiplicativity says non-residues behave like : residue times residue is a residue, non-residue times non-residue is a residue, and residue times non-residue is a non-residue. The last is a small surprise the first time one meets it — the non-residues are not closed under multiplication.
Theorem 3.43 (Quadratic reciprocity, with both supplements). Let and be distinct odd primes. Then
and the two supplementary laws hold:
The supplements are proved in the next section and the main law in the section Proving Reciprocity. Read the exponent concretely: it is odd exactly when both and are . So the law says
Intuition. Two questions that look unrelated — is a square mod ? is a square mod ? — have the same answer, unless both primes are of the awkward type , in which case the answers are opposite. There is no elementary reason to expect the two questions to be connected at all, which is why the theorem was conjectured by Euler, and why Gauss returned to it eight times.
Example 3.44 (Flipping a symbol). Evaluate and and check the law.
Solution.
- Both and are , so the law predicts .
- Compute , since and is a square.
- So the law predicts .
- Check by listing squares mod : — and is not among them, so . The law holds.
3.10The Supplementary Laws and Gauss's Lemma
The first supplement is one line from Euler's criterion. The second is not, because is not a residue class we can reduce away, and it needs the sharper tool that will also carry the main theorem.
Theorem 3.45 (First supplementary law). For an odd prime ,
so is a quadratic residue modulo exactly when .
Proof. By the proposition Basic properties of the Legendre symbol, . Both sides are and differ by or ; since is odd and divides the difference, the difference is and the two are equal.
For the restatement: is even exactly when and odd exactly when .∎
Remark. This matches the corollary Wilson produces a square root of exactly, and the two proofs are independent: Wilson's construction gives the square root when , and Euler's criterion certifies that none exists when .
Lemma 3.46 (Gauss's lemma). Let be an odd prime, , and put . For let be the least positive residue of modulo , and let
Then
Proof. Define, for each ,
(No equals , which is not an integer.) In both cases .
The are pairwise distinct. Suppose . Then , that is . Cancelling the invertible gives . The case is impossible: , so . Hence , and as , .
So are distinct elements of , hence a permutation of it, and
On the other hand , with the minus sign taken exactly for the indices where . Therefore
Since is a product of integers less than , it is invertible modulo and may be cancelled:
By Euler's criterion the left side is , and both sides are differing by a multiple of the odd prime , so they are equal as integers.∎
Intuition. Gauss's lemma counts how many times multiplication by pushes a residue from the bottom half of into the top half. Each such crossing costs a sign. The character is nothing but the parity of the number of crossings.
Theorem 3.47 (Second supplementary law). For an odd prime ,
so is a quadratic residue modulo exactly when .
Proof. Apply Gauss's lemma with and . For we have , so the least positive residue of is itself: . Hence
Now run the four odd residue classes modulo , writing .
- : , , so , even.
- : , , so , odd.
- : , , so , odd.
- : , , so , even.
So for and for , which is the stated case split since and .
Finally has the same four values: writing gives , whose parity is that of , equal to for — even, odd, odd, even.∎
Example 3.48 (Gauss's lemma computed). Use Gauss's lemma to evaluate .
Solution.
- Here , , . The multiples are .
- Least positive residues mod : .
- Those exceeding are and , so .
- Hence : is a quadratic residue mod . Check: .
3.11Evaluating Legendre Symbols Fast
Reciprocity is not only beautiful; it is an algorithm. Euler's criterion evaluates in about modular multiplications, but reciprocity does it in about divisions, with no arithmetic larger than the inputs, and it is the method to use by hand.
Method 3.49 (Evaluating by reciprocity).
- Reduce the top modulo the bottom, choosing the representative in . If it is , the symbol is and you are done.
- Factor out all powers of : each factor contributes by the second supplementary law, read off .
- What remains is a product of odd primes . For each, flip to , inserting a sign exactly when .
- Repeat from step 1 on each smaller symbol. The bottom strictly decreases at every flip, so the process ends at a symbol with top , whose value is .
Proposition 3.50 (The algorithm terminates). Each pass of the recipe Evaluating by reciprocity strictly decreases the modulus, so the procedure halts after finitely many steps.
Proof. After step 1 the top satisfies . Any odd prime appearing in its factorisation satisfies . Step 3 replaces the symbol with , whose modulus is . A strictly decreasing sequence of positive integers is finite, and the descent stops only when no odd prime remains on top, i.e. the top is or a power of , both of which are evaluated outright.∎
Example 3.51 (A first evaluation). Compute , given that is prime.
Solution.
- , and , so .
- and , so the flip costs a sign: , since .
- , so and therefore .
- , so no sign: , since .
- , so . As , this is .
- Multiplying, : is a quadratic residue modulo .
Example 3.52 (A negative top). Compute .
Solution.
- Split: , so .
- , so ; and , so .
- , so , since .
- , so .
- , so , using .
- Hence : the congruence has no solution.
Pitfall. Reciprocity flips only between odd primes. Before flipping you must pull out the sign and every factor of , and you must factor the top into primes — the naive flip is meaningless, because is not prime and the Legendre symbol is defined only for a prime bottom. (The Jacobi symbol repairs this and lets the algorithm run without factoring, at the cost that no longer certifies a square.)
3.12Quadratic Gauss Sums: Definition and Magnitude
The Legendre symbol is a function on residues taking values . Weighting the -th roots of unity by it produces a single complex number that encodes the whole symbol, and whose square turns out to be — the arithmetic of reciprocity written as an identity between complex numbers.
Definition 3.53 (Quadratic Gauss sum). Let be an odd prime and . The quadratic Gauss sum attached to is
the term vanishing because .
Proposition 3.54 (The symbol sums to zero). For an odd prime ,
Proof. By the proposition Exactly half the residues are squares, among exactly values give and the remaining give . Their sum is , and the term is .∎
Lemma 3.55 (Ramanujan-style root-of-unity sum). Let and let be an integer. Then
Proof. If then for every and the sum has terms equal to . Otherwise is a -th root of unity, so it is a root of , and since it is a root of the second factor. That says , and subtracting the term gives .∎
Theorem 3.56 (The Gauss sum has absolute value ). For every odd prime ,
Proof. Since and the Legendre symbol is real,
For each fixed the map is a bijection of modulo , by the argument already used in the proof of Fermat's little theorem. Substituting and using multiplicativity from the proposition Basic properties of the Legendre symbol,
since , while . Therefore
By the lemma Ramanujan-style root-of-unity sum the inner sum is when and otherwise. Splitting off , where ,
using the proposition The symbol sums to zero for the total .∎
Example 3.57 (The Gauss sum for ). Compute explicitly and check its magnitude.
Solution.
- Modulo the squares are , so and .
- With , .
- Writing and , we get .
- So , as the theorem The Gauss sum has absolute value requires, and .
3.13The Square, and the Sign
Knowing leaves the argument of undetermined. The square is elementary; the sign is not, and the gap between the two is one of the famous stories in the subject.
Theorem 3.58 (The square of the Gauss sum). For every odd prime ,
In particular when and when .
Proof. Conjugating term by term and then substituting , which permutes the nonzero residues modulo ,
using multiplicativity of the symbol. Multiplying by and applying the theorem The Gauss sum has absolute value ,
Since is its own reciprocal, , and the first supplementary law identifies that symbol as .∎
Theorem 3.59 (Gauss's sign determination, quoted). With ,
Remark. This theorem is quoted, not proved here. The theorem The square of the Gauss sum pins down to one of two values, or , and no purely algebraic manipulation of the definition distinguishes them: every identity used above is invariant under the substitution for a quadratic residue , which is exactly the symmetry that would have to be broken. Gauss reported that the sign resisted him for four years. All known proofs use something analytic or topological — a limiting argument on theta functions, a contour integral, or a clever telescoping product — and none is elementary enough to belong here.
Example 3.60 (Confirming the sign for ). Check the theorem Gauss's sign determination, quoted numerically for .
Solution.
- The squares mod are and , so and .
- With , .
- Numerically and , so .
- And . Since , the quoted theorem predicts exactly , confirmed. Note came out real and positive — the content of the theorem is that the sign is never the other one.
3.14Proving Reciprocity
We now prove the main law. The route is Eisenstein's: convert Gauss's lemma from a count of crossings into a count of lattice points, then observe that two such counts fill one rectangle between them.
Lemma 3.61 (Eisenstein's form of Gauss's lemma). Let be an odd prime, , and let be an odd integer with . Then
Proof. Keep the notation of Gauss's lemma: is the least positive residue of , and counts the with . Division with remainder gives
Write . In the proof of Gauss's lemma the numbers (equal to when and to otherwise) were shown to be a permutation of , so . Splitting that sum by which case applies,
because each of the large terms contributes in place of . Subtracting this from the previous display,
Now reduce modulo . The left side is even because is odd, and the last term is even, so is even; is odd, hence . Therefore by Gauss's lemma.∎
Lemma 3.62 (The lattice-point count). Let be odd primes. Then
Proof. Let be the set of lattice points with integer coordinates satisfying
so . Split by the line .
No point of lies on the line. If then , and forces , impossible for .
Points below the line. For a fixed , the condition says , so the admissible are — and every one of them is in range, since gives , hence . So the count below the line is , the first sum.
Points above the line. By the same argument with the roles of and exchanged, the count is , the second sum.
Every point of is below or above the line and in exactly one of the two groups, so the two sums add to .∎
Theorem 3.64 (Quadratic reciprocity). For distinct odd primes and ,
Proof. Both and are odd and neither divides the other, so the lemma Eisenstein's form of Gauss's lemma applies in both directions:
Multiplying and applying the lemma The lattice-point count,
Example 3.65 (The lattice count for , ). Verify both Eisenstein sums and the reciprocity sign for , .
Solution.
- .
- .
- , as the lemma The lattice-point count requires.
- So , agreeing with the direct computation in the example Flipping a symbol, where the two symbols came out and .
Remark. A second route, given as a sketch. Reciprocity also drops out of the Gauss sum, and it is worth seeing why, though the argument below is a sketch and is not a proof as it stands. Work in the ring , , and reduce modulo the prime . Then
the first step because in characteristic , the last by substituting . On the other hand by the theorem The square of the Gauss sum, and Euler's criterion evaluates that last factor as . Cancelling and comparing gives the law.
What this sketch assumes, and what would have to be supplied to make it a proof: that is a ring in which reduction modulo makes sense and in which the freshman's-dream congruence is valid; that is cancellable modulo , which needs to be invertible modulo — true since — together with a precise statement of what "modulo " means for the ideal ; and that a congruence between the integers modulo is an equality. None of these is hard, but all of them need the algebraic number theory of cyclotomic rings, which is why the Eisenstein argument above is the one given in full.
- Dropping the coprimality in Fermat's little theorem. needs ; only the universal form is unconditional.
- Reducing an exponent modulo instead of modulo . For the right reduction is , not .
- Using Euler's exponent as if it were the order. always works, but the true order of may be a proper divisor of it, as .
- Treating a passed Fermat test as a proof of primality. Carmichael numbers such as , and pass for every coprime base.
- Forgetting that the Fermat test only examines coprime bases. is divisible by , so base says nothing; the test's blindness is confined to .
- Forgetting the exception in Wilson's converse. Every composite gives , but .
- Assuming has only two solutions at a composite modulus. Modulo it has four, which is precisely why the Wilson pairing argument needs a prime.
- Claiming non-residues are closed under multiplication. Two non-residues multiply to a residue, since in the Legendre symbol.
- Flipping a symbol whose top is composite or even. Reciprocity relates and for odd primes only; pull out and all factors of first, using the supplementary laws.
- Getting the reciprocity sign backwards. The sign is only when ; in every other case the two symbols are equal.
- Reading as " has a square root you can write down". The symbol certifies existence, not a construction; finding the root is a separate algorithm (though for the root is simply ).
- Assuming settles the Gauss sum. The magnitude is elementary; the sign is the theorem Gauss's sign determination, quoted and is not proved by any manipulation of the definition.