Section 16.5 Euler's Criterion
ΒΆAs it happens, Fact 16.4.5 is a terrible way to actually find quadratic residues for a given p in general, since it involves finding a primitive root and listing lots of powers. We need both theory and practice. There is a much easier way. First recall our observation in Theorem 12.3.2:
xxxxxxxxxx
import matplotlib.pyplot as plt
from matplotlib.ticker import IndexLocator, FuncFormatter
def power_table_plot(p=(13,prime_range(50))):
mycmap = plt.get_cmap('gist_earth',p-1)
myloc = IndexLocator(floor(p/5),.5)
myform = FuncFormatter(lambda x,y: int(x+1))
cbaropts = { 'ticks':myloc, 'drawedges':True, 'boundaries':srange(.5,p+.5,1)}
P=matrix_plot(matrix(p-1,[mod(a,p)^b for a in range(1,p) for b in srange(p+1)]), cmap=mycmap,colorbar=True, colorbar_options=cbaropts, ticks=[myloc,myloc], tick_formatter=[None,myform])
show(P,figsize=6)
Theorem 16.5.2. Euler's Criterion.
If p is an odd prime, then for all integers a not a multiple of p, the sign of the following expression determines whether a is a QR.
We obtain +1 if a is a QR, otherwise β1.
Proof.
Let \(g\) be a primitive root of \(p\text{,}\) so that \(a\equiv g^i\) for some \(i\text{.}\) Then if we let \(h=g^{(p-1)/2}\text{,}\) Fermat's Little Theorem shows that
Since \(g\) is a primitive root, \(h\equiv 1\) is impossible, so \(h\equiv -1\text{.}\) But then
This is \(+1\) when \(i\) is even and \(-1\) when \(i\) is odd. Finally, according to Fact 16.4.5, this is precisely when \(a\) is a quadratic residue and nonresidue, respectively.
Example 16.5.3.
This immediately gives the result in Fact 16.1.2 that β1 has a square root modulo an odd prime p precisely when pβ‘1 (mod 4), because (β1)(pβ1)/2=+1 precisely when (pβ1)/2 is even, or pβ‘1 (mod 4). That is much easier than our previous ad-hoc way of doing it!