Quadratic residues are just a fancy way of talking about whether an element is a square or not:
We say that \(0\neq \bar a\in\mathbb{Z}_n\) is a quadratic residue modulo \(n\) if there is a \(b\) such that \(\bar b^2 = \bar a\).
A non-zero number that is not a quadratic residue is called a quadratic nonresidue modulo \(n\).
\(0\) is considered neither.
Our main goal in this section is to develop ways to determine when a number is a quadratic residue. We start with a simple observation:
If \(p > 2\) is a prime and \(\bar a\in\mathbb{Z}_p\) is a quadratic residue, then there are exactly two elements in \(\mathbb{Z}_p\) such that \(\bar x ^2 = \bar a\).
As a consequence, exactly \(\frac{p-1}{2}\) quadratic residues modulo \(p\), therefore exactly \(\frac{p-1}{2}\) quadratic nonresidues.
To prove this:
The Legendre Symbol is defined as follows:
\[\left(\frac{a}{p}\right) = \begin{cases}\phantom{-}1 &\textrm{if }\bar a \textrm{ quadratic residue modulo }p\\ -1 &\textrm{if }\bar a \textrm{ quadratic nonresidue modulo }p\\ \phantom{-}0 &\textrm{if }\bar a = 0\end{cases}\]
Note that this only depends on \(a\bmod p\), and not on \(a\) itself.
It essentially captures the information as to whether \(a\) is a quadratic residue or not.
Examples:
\(\left(\frac{13}{7}\right) = \left(\frac{6}{7}\right) = -1\) because the only squares modulo \(7\) are 1, 2, 4.
Similarly \(\left(\frac{11}{7}\right) = \left(\frac{4}{7}\right) = 1\).
One really important property of the Legendre Symbol is that it is multiplicative:
\[\left(\frac{ab}{p}\right) = \left(\frac{a}{p}\right)\left(\frac{b}{p}\right)\]
This will follow from the following results:
- If \(a\) or \(b\) is divisible by \(p\), then so is their product.
- If \(a\) and \(b\) are quadratic residues, then so is their product.
- If \(a\) is a quadratic residue and \(b\) is a quadratic nonresidue, then their product is a quadratic nonresidue.
- If \(a\) and \(b\) are quadratic nonresidues, then \(ab\) is a quadratic residue.
Let us prove these:
Euler's identity offers us another way to determine the quadratic residues.
Let \(p > 2\) and \(0 \neq \bar a\in\mathbb{Z}_p\).
- If \(\bar a\) is a quadratic residue, then \(\bar a ^{\frac{p-1}{2}} = \bar 1\).
- If \(\bar a\) is a quadratic nonresidue, then \(\bar a ^{\frac{p-1}{2}} = -\bar 1\).
- (Euler's identity) We have: \[\left(\frac{a}{p}\right) = \bar a ^{\frac{p-1}{2}}\bmod p\]
Let us prove these:
Use this method to determine the quadratic residues modulo \(7\).
There are two important consequences of Euler's identity. The first is that, as we saw previously in a more complicated way, the Legendre symbol behaves multiplicatively. This follows directly as it relates to a (fixed) power of \(a\), and raising to a power behaves multiplicatively on the base.
The other is the determination of when \(-1\) is a quadratic residue.
Euler's identity gives us a way to find when \(-1\) is a quadratic residue. We have:
\[\left(\frac{-1}{p}\right) = (-1)^{\frac{p-1}{2}}\]
So:
- If \(p =1\bmod 4\), i.e. \(\frac{p-1}{2}\) is even, then \(-1\) is a quadratic residue modulo \(p\).
- If \(p =3\bmod 4\), i.e. \(\frac{p-1}{2}\) is odd, then \(-1\) is a quadratic nonresidue modulo \(p\).