]> Number Theory - Quadratic Residues

Number Theory

Quadratic Residues

Let a n. We say a is a quadratic residue if there exists some x such that x 2 =a. We shall focus on the case when n is prime.

Let p be a prime. From now assume p>2 . The case p=2 is easy anyway. Let g be a generator of p *. Any a p * can be written as g k for some k{1 ,...,p1 }.

Say k is even. Write k=2 m. Then (g m) 2 =a, so a is a quadratic residue. Exactly half of {1 ,...,p1 } is even (since p is odd), hence at least half of the elements of p * are quadratic residues.

Suppose we have b 2 =a. Then (b) 2 =a as well, and since bb (since p>2 ) every quadratic residue has at least two square roots (actually we know from before there can be at most two), thus at most half the elements of p * are quadratic residues. (Otherwise there are more square roots than elements!)

Thus exactly half of p * are quadratic residues, and they are the even powers of g.

Given a=g k, consider the effect of exponentiating by (p1 )/2 . If k is odd, say k=2 m+1 , we get a (p1 )/2 =g (2 m+1 )(p1 )/2 =g (p1 ) mg (p1 )/2 =g (p1 )/2

The square of g (p1 )/2 is g p1 =1 , so g (p1 )/2 is 1 or 1 . But g has order p1 (g is a generator) thus we must have g (p1 )/2 =1 .

If k is even, say k=2 m, then a (p1 )/2 =g (p1 ) m=1 .

Thus one way to tell if a is a quadratic residue is to compute a (p1 )/2 : if the result is 1 , then a is a quadratic residue, otherwise the result is 1 and a is a quadratic nonresidue.

Example: In p, if (p1 )/2 is even (so p=1 (mod4 )), then 1 is a quadratic residue, otherwise 1 is a quadratic nonresidue.

The Legendre Symbol

This fact (sometimes called Euler's Criterion) is so useful that we define the Legendre symbol for odd primes p and integers a by (ap)=a (p1 )/2 . The symbol can also be written as (ap).

Thus:

It is not hard to see that for any integer b (ap)(bp)=(abp) and for any r coprime to p (ap)(ar 2 p)=(ap)

Gauss' Lemma

There is a less obvious way to compute the Legendre symbol. This method allows us to easily evaluate (2 p), among other things. Before stating the method formally, we demonstrate it with an example.

Let p=17 , and a=7 . There are 16 nonzero elements {1,...,16 }. Consider the first half {1,...,8 } and multiply them all by 7 to get 7 ,14 ,4 ,11 ,1 ,8 ,15 ,5 . As integers, let us count the number of them that are greater than p/2 (that is, 9 or higher).

Note: even though there is no way to define inequalities modulo p, we can view elements of p as integers in {0 ,...,p1 } and look at sizes there, though it is not yet clear why we want to do this.

14 ,11 and 15 are the only ones in the set that are greater than p/2 , so there are exactly 3 of them. Then Gauss' Lemma states that if we take this 3 and raise 1 to this power, then we have (ap), that is: (7 17 )=(1 ) 3 =1 .

Theorem: Let p be an odd prime, q be an integer coprime to p. Consider the set {q,2 q,...,q(p1 )/2 } and view each member is an integer in {0 ,...,p1 }. Let u be the number of members in this set that are greater than p/2 . Then (qp)=(1 ) u.

Proof: Let b 1 ,...,b t be the members of the set less than p/2 , and c 1 ,...,c u be the members greater than p/2 . Then u+t=(p1 )/2 . Consider the sequence 0 <b 1 ,...,b t,pc 1 ,...,pc u<p/2

Each of these are distinct: clearly b ib j and c ic j whenever ij (since q is invertible), and if b i=pc j, then let b i=rq,c j=sq. Then r+s=0 , which is a contradiction since 0 <r,s<p/2 . Hence they must be precisely the numbers 1 ,...,(p1 )/2 in some order, thus q(2 q)...(q(p1 )/2 ) = b 1 ...b tc 1 ...c u = (1 ) ub 1 ...b t(pc 1 )...(pc u) = (1 ) u(p1 2 )! Dividing both sides by ((p1 )/2 ))! completes the proof.

For example, let p be an odd prime and take q=2 . Consider the sequence 2 ,2 ×2,...,2 (p1 )/2 . Note these are positive least residues. Now p=8 x+y for some integer x and y{1,3,5,7 }. By considering each case we see that the number of elements greater than p/2 is even when p=1 ,7 (mod8 ) and odd when p=3 ,5 (mod8 ). We can restate this as follows.

Theorem: Let p be an odd prime. (2 p)=(1 ) p 2 1 8 =(1 ) p+1 4

Proof: See the last paragraph, and note that (p 2 1 )/8 is even when p=±1 (mod8 ) and odd otherwise. Similarly for (p+1 )/4 .

Example: By Gauss' Lemma, (3 p)=1 if p=±1 (mod12 ) and 1 otherwise (p=±5 (mod12 )). Combining this with the above result for 1 (modp) we have (3 p)=1 if p=1 (mod6 ) and 1 otherwise (p=1 (mod6 )).