Section 17.4 Quadratic Reciprocity
ΒΆSubsection 17.4.1 The theorem
ΒΆTheorem 17.4.1. Quadratic Reciprocity.
If p and q are odd primes not equal to each other, then
Proof.
See Section 17.6.
Remark 17.4.2.
We can multiply the fractions to rewrite it in a way some authors prefer:
Example 17.4.3. Computing with QR.
We immediately apply this to vastly simplify the calculations in Section 17.3. Let q=3 and p>3.
Let's write the theorem out for this case. Since (3β1)/2=1, we have
There are two parts to this:
-
Since 1βQ3 and 2βQ3, the Legendre symbol on the right is:
(p3)=1 if pβ‘1 (mod 3) and (p3)=β1 if pβ‘2 (mod 3). -
We can also compute the power of β1:
(β1)(pβ1)/2=1 if pβ‘1 (mod 4) and (β1)(pβ1)/2=β1 if pβ‘3 (mod 4).
Combine these together and we get that (3p)=1 exactly when one of these two cases occurs:
pβ‘1 (mod 3) and mod (4)
pβ‘3 (mod 4) and β‘2 (mod 3)
This is precisely pβ‘1,11β‘Β±1 (mod 12) as in Proposition 17.3.4!
Subsection 17.4.2 Why is this theorem different from all other theorems?
ΒΆSubsubsection 17.4.2.1 What does it mean?
ΒΆWhat does the term βquadratic reciprocityβ even mean? It means that there is a reciprocating relationship between Legendre symbols, and hence between whether there is a square root of two primes modulo each other. One way to think of this relation is to assert that the following matrix is almost symmetric β and that we have a simple formula for finding where it isn't.xxxxxxxxxx
ls=prime_range(3,50)
M=matrix(len(ls),[legendre_symbol(a,b) for a in ls for b in ls])
show(block_matrix(2,[0, matrix(1,len(ls),ls), matrix(len(ls),1,ls), M]))
Remark 17.4.4.
Here is another way to say it. For odd primes p and q,
except when pβ‘qβ‘3 (mod 4). Or see Remark 17.4.2 for yet another way; both are often how Theorem 17.4.1 is stated in texts.
Subsubsection 17.4.2.2 What does it do?
ΒΆWhat does quadratic reciprocity do? It makes computation of Legendre symbols (ap) very, very easy if you have a prime factorization of a (and all the intermediate steps). You just need to use the following facts we already proved, in addition to quadratic reciprocity.(β1p)=1βΊpβ‘1 (mod 4)
(2p)=1βΊpβ‘Β±1 (mod 8)
Algorithm 17.4.5.
Any Legendre symbol can be computed using the following steps, not necessarily in this order and often multiple times:
Factor the top and use Proposition 16.4.7, then computing each one separately.
Reduce modulo the bottom and/or use Proposition 17.1.3 to get convenient tops (especially perfect squares).
When you get to an odd prime on the top and bottom, use Theorem 17.4.1.
When the top is β1 or 2, use Example 16.6.2 or Theorem 16.7.1 to finish your computation.
Proof.
Read the chapter up to this point, plus the proof of Theorem 17.4.1.
Example 17.4.6.
Let's calculate (99167).
Since they are coprime factors, (99167)=(9167)β (11167).
Since both 11 and 167 are prime and congruent to 3 modulo four, (9167)β (11167)=(32167)β β(16711)
Reducing, we get (32167)β β(16711)=β1β (211)
Finally, we use Theorem 16.7.1 and note that 11β‘3 (mod 8) to get β1β (211)=β1β β1=1 and we see that ninety-nine is a QR modulo one hundred sixty-seven.
Example 17.4.7.
In a classroom experience, try these. (Else, see Exercise 17.7.16.)
(83103)
(219383)
(646877)
And we can check them, of course.
xxxxxxxxxx
print(legendre_symbol(83,103))
print(legendre_symbol(219,383))
print(legendre_symbol(646,877))
Subsubsection 17.4.2.3 The Jacobi symbol
ΒΆWhat else does quadratic reciprocity do? Indirectly, it allows us to compute Legendre symbols (ap) without factoring a.Definition 17.4.8.
Let n be an odd number which factors as
Then the Jacobi symbol, (an), is just the product of the relevant Legendre symbols:
Fact 17.4.9.
If n is not prime, then (an)=1 does not necessarily imply a is a QR of n.
Sage note 17.4.10. Names of functions may vary.
In Sage, this is named after yet another generalization called the Kronecker symbol.
xxxxxxxxxx
print(kronecker_symbol(8,15))
print(quadratic_residues(15))
Example 17.4.11.
And we can check this out with Sage:
xxxxxxxxxx
kronecker_symbol(943,997)
Example 17.4.12.
To put this into practice, let's redo (646877):
Check again with Sage:
xxxxxxxxxx
kronecker_symbol(646,877)