logo

Quadratic Residues and Non-Quadratic Residues 📂Number Theory

Quadratic Residues and Non-Quadratic Residues

Definition 1

For primes p2p \ne 2 and a<pa < p, if there exists a solution to the congruence equation x2a(modp)x^{2} \equiv a \pmod{p}, then aa is called a Quadratic Residue QR modulo pp. If aa is not a quadratic residue, it is called a Non-Quadratic Residue NR.

Explanation

Simply put, a quadratic residue is a number for which a square root exists in (modp)\pmod{p}.

For example, consider the prime 77 121(mod7)224(mod7)322(mod7)422(mod7)524(mod7)621(mod7) 1^2 \equiv 1 \pmod{7} \\ 2^2 \equiv 4 \pmod{7} \\ 3^2 \equiv 2 \pmod{7} \\ 4^2 \equiv 2 \pmod{7} \\ 5^2 \equiv 4 \pmod{7} \\ 6^2 \equiv 1 \pmod{7} 1,2,41,2,4 is a QR and 3,5,63,5,6 is an NR. Considering the prime 1111 121(mod11)224(mod11)329(mod11)425(mod11)523(mod11)623(mod11)725(mod11)829(mod11)924(mod11)1021(mod11) 1^2 \equiv 1 \pmod{11} \\ 2^2 \equiv 4 \pmod{11} \\ 3^2 \equiv 9 \pmod{11} \\ 4^2 \equiv 5 \pmod{11} \\ 5^2 \equiv 3 \pmod{11} \\ 6^2 \equiv 3 \pmod{11} \\ 7^2 \equiv 5 \pmod{11} \\ 8^2 \equiv 9 \pmod{11} \\ 9^2 \equiv 4 \pmod{11} \\ 10^2 \equiv 1 \pmod{11} 1,3,4,5,91,3,4,5,9 is a QR and the rest 2,6,7,8,102,6,7,8,10 are NR. Interestingly, QRs appear symmetrically, which is natural because (pq)2p22pq+q2q2(modp) (p-q)^2 \equiv p^2-2pq+q^2 \equiv q^2 \pmod{p} Also, there are always exactly the same number of QRs and NRs.

Theorem

For primes larger than 22, pp, there are exactly (p1)2\displaystyle {(p-1) \over 2} QRs and NRs.

Proof

The list of all numbers squared from 11 to p1p-1 is as follows. 12,22,,(p1)2 1^2, 2^2, \cdots , (p-1)^2 However, as we’ve seen (pq)2p22pq+q2q2(modp) (p-q)^2 \equiv p^2-2pq+q^2 \equiv q^2 \pmod{p} so whether we look at 11 or p1p-1, it’s the same, and whether we look at 22 or p2p-2, it’s the same. Therefore, it is sufficient to only look at half of the original number 12,22,,(p12)2 1^2, 2^2, \cdots , \left( {{ p-1 } \over { 2 }} \right)^2 These numbers are all QRs by the definition of QRs, so if we can show that all these numbers are different, then we can say that there are exactly (p1)2\displaystyle {(p-1) \over 2} QRs. Similarly, since a natural number smaller than pp in (modp)\pmod{p} is either a QR or an NR, if there are exactly (p1)2\displaystyle {(p-1) \over 2} QRs, then there must also be exactly (p1)2\displaystyle {(p-1) \over 2} NRs. The formal proof uses reductio ad absurdum. Let b1b_1 and b2b_2 be two different natural numbers smaller than (p1)2\displaystyle {{(p-1)} \over {2}}.

Assuming b12b22(modp){b_1}^2 \equiv {b_2}^2 \pmod{p} holds, then b12b220(modp) {b_1}^2 - {b_2}^2 \equiv 0 \pmod{p} Therefore, for some integer kk, b12b22=pk{b_1}^2 - {b_2}^2 = pk, and the prime pp is a divisor of (b1+b2)(b1b2)({b_1} + {b_2})({b_1} - {b_2}). However, since b1b_1 and b2b_2 are assumed to be smaller than (p1)2\displaystyle {{(p-1)} \over {2}}, (b1+b2)({b_1} + {b_2}) is smaller than (p1)(p-1). Hence, pp cannot be a divisor of (b1+b2)({b_1} + {b_2}), and must therefore be a divisor of (b1b2)({b_1} - {b_2}). However, by the same reasoning b1b2|{b_1} - {b_2}| is smaller than (p1)(p-1), so it must be 00 to be divided by pp. That means, b1=b2{b_1} = {b_2}, but we assumed b1b_1 and b2b_2 to be two different natural numbers smaller than (p1)2\displaystyle {{(p-1)} \over {2}}, so this is a contradiction. Therefore, b12b22(modp){b_1}^2 \neq {b_2}^2 \pmod{p} and there are exactly (p1)2\displaystyle {(p-1) \over 2} QRs.


  1. Silverman. (2012). A Friendly Introduction to Number Theory (4th Edition): p143. ↩︎