Chap6 PDF
Chap6 PDF
Chap6 PDF
Quadratic Residues
The very structural theory of congruences we have built thus far leads us
to the next level: quadratic congruences. The existence question of square
roots modulo a prime will be consummated in the celebrated law of quadratic
reciprocity. Our approach toward this goal will follow closely that of the text
[NZM91]. Meanwhile, actual algorithms needed to solve quadratic congru-
ences will be treated only briefly in this chapter, but to be continued and
settled in Appendix D.
52
ISBN 1419687352 53
for any integer a and prime p > 2. Some authors prefer the notation (a|p)
for the Legendre symbol. We shall use both interchangeably, mainly for
the sake of readabilitythe vertical mode in a displayed equation and the
horizontal mode for intext. For example, we have earlier seen that (19|5) = 1
and (7|5) = 1. Note also that (a|p) = (b|p) whenever a b (mod p) and,
in particular,
a a%p
=
p p
54 Theory of Numbers
Proof. Assume p ab to avoid triviality. In each equation, left and right are
congruent modulo p > 2, by Theorem 6.1. But each quantity is 1; the only
way this can happen is when both sides are 1 or both 1.
Note that the second equality gives (1|p) = 1 if p % 4 = 1, and (1|p) =
1 if p % 4 = 3. This result agrees with that given earlier in Exercise 5.22.
Example. Let us apply the above properties in evaluating (75|17). We
have (75|17) = (1|17)(5|17)2 (3|17) = (1)8 (1)2 (3|17) = (3|17). And
then (3|17) 38 (mod 17) according to Eulers criterion (Theorem 6.1). Suc-
cessive squaring algorithm gives us 38 % 17 = 16, hence (75|17) = 1.
There really are different ways to arrive at this same result. For instance,
since 75 27 (mod 17) then (75|17) = (27|17) = (3|17)3 = (3|17). Or by
the fact that 75 % 17 = 10, we have (75|17) = (10|17) = (2|17)(5|17). Or
Eulers criterion alone, (10|17) 108 (mod 17), etc.
Exercise 6.6. Evaluate the Legendre symbol (a|p) in several ways.
a) (35|11)
b) (54|13)
c) (28|19)
d) (11|23)
ISBN 1419687352 55
Exercise 6.7. Let p be an odd prime relatively prime to a. Prove that the
quadratic congruence ax2 + bx + c 0 (mod p) has a solution if and only if
(b2 4ac|p) 0. Then determine the solvability of the following.
a) x2 1 (mod 101)
b) x2 5x + 2 0 (mod 29)
c) 2x2 18x + 24 (mod 43)
d) 13x2 56x 44 (mod 79)
As a matter of fact, there are yet other ways by which we can evaluate
the Legendre symbol. The next two lemmas are not that practical, but they
carry some theoretical significance. The first of the two is that of Gauss.
Lemma 6.3 (Gausss Lemma). Consider the Legendre symbol (a|p) with
p a. Let d = (p 1)/2 and A = {a, 2a, 3a, . . . , da}. Then (a|p) = (1)n ,
where n is the number of elements x A such that x % p > d.
Proof. Since p a, elements of A are distinct modulo p. Now consider the
reduced residue system modulo p given by S = {1, 2, . . . , d}. Note that
the solutions to x % p > d in S are precisely given by the negative elements,1
exactly n of which are congruent to an element in A.
In S, only one number in each plus/minus pair can be congruent modulo
p to some element in A. If this claim were false, we would have ia, ja A,
with 1 i < j d, for which ia ja (mod p), and so i j (mod p).
This is impossible as both i and j belong to S, a reduced residue system.
It follows that, modulo p, the elements of A are reordering of the numbers
1, 2, . . . , donly that n of them are prefixed by the negative sign. Then,
a 2a da (1)n 1 2 d (mod p)
from which we claim (1)n ad (a|p) (mod p), by Eulers criterion.
Example. Let us illustrate Gausss lemma with a = 5 and p = 17, hence
d = 8. We have A = {5, 10, 15, 20, 25, 30, 35, 40}, reduced mod 17 to
{5, 10, 15, 3, 8, 13, 1, 6}. Three elements exceed 8, so (5|17) = (1)3 = 1.
Exercise 6.8. Redo Exercise 6.6 using Gausss lemma.
At this point we are able to derive the following formula for (2|p), a spe-
cial case of the Legendre symbol which will be encountered quite frequently
in computation.
Proposition 6.4. The following formula holds for (2|p).
2 (p2 1)/8 1 if p 1 (mod 8)
= (1) =
p 1 if p 3 (mod 8)
1 In fact, x % p > d if and only if x %% p < 0. See Exercise 1.8 for definition.
56 Theory of Numbers
Proof. We claim, as an easy exercise, that the exponent (p2 1)/8 is even
if and only if p 1 (mod 8).
Let us keep the same notation we use in Lemma 6.3 and its proof. We
repeat that elements of A are congruent modulo p to 1, 2, . . . , d, not nec-
essarily in this order, except that n of them should have the negative sign.
Denote by ri s those which should have been negative, and the rest by sj s.
Then, for 1 k d, the residue ka % p is either sj or p ri for some indices
i and j. Using the relation ka = ka
p p + ka % p, we take sums over k,
d d n dn
X X ka X X
ka = p+ p ri + sj (6.1)
p i=1 j=1
k=1 k=1
Proof. As a p 1 (mod 2), this time Equation (6.3) gives the congruence
0 m + n (mod 2). Again, this means that m is of the same parity as that
of the number n in Gausss lemma, and hence (1)m = (1)n = (a|p).
ISBN 1419687352 57
Exercise 6.13. Evaluate (a|p) with the help of the reciprocity law.
a) (37|83)
b) (71|103)
c) (69|127)
d) (1414|2063)
e) (19392|2939)
Exercise 6.14. Show that (3|p) = 1 if and only if p [1]12 . Similarly,
(3|p) = 1 if and only if p % 6 = 1.
Exercise 6.15. Modulo which odd prime is 5 is a quadratic residue?
Theorem 6.7. With the Jacobi symbol, for any odd number n > 0,
1) (ab|n) = (a|n)(b|n)
2) (1|n) = (1)(n1)/2
2
3) (2|n) = (1)(n 1)/8
The same conclusion, (4459|6247) = 1. But note that neither 4459 nor
447 is prime, and that the only factoring needed is for the even factors.
Exercise 6.17. Evaluate the Jacobi symbol (1939|29391).
60 Theory of Numbers
Exercise 6.18. Redo Exercise 6.13 with the help of Jacobi symbols.
Recall Exercise 6.3(b), which says that quadratic residues and non-
residues modulo n > 2 are equally many, provided that we have primitive
roots. The next problem claims that the Jacobi symbol (a|n) takes on the
values 1 equally many times, if n has no repeated prime factors.
Example. Let us apply Theorem 6.8 to x2 7 (mod 19). We first verify that
(7|19) = (19|7) = (5|7) = (7|5) = (2|5) = 1, and that 19 % 4 = 3.
A particular solution is x0 = 7(19+1)/4 = 75 = 16807. One solution class is
given by [16807]19 = [11]19 , and the other by [11]19 = [8]19 .
y 2 54 4 (mod 5) y 2 (mod 5)
2
z 54 8 (mod 23) z 13 (mod 23)