Recall from the Chinese Remainder Theorem lecture, we looked at solving polynomial congruences of the form
And we saw that we have a few cases:
- When \(m\) is arbitrary, then we can use \(m\)'s prime factorization to write \(m=p_1^{n_1}p_2^{n_2}\cdots\) and then solve this congruence using the Chinese Remainder Theorem (CRT) (Lecture 13).
- When \(m\) is a prime power so \(m=p^n\), then we can be reduce this to modulo \(p\) using Newton's method or Hansel's Lemma (Lecture 19).
- The third case is when \(m\) is just a prime. (Today's lecture)
So consider
where \(p\) is prime. Obviously the stupid method is to check every \(x\) from \(0\) to \(p-1\). If \(p\) is small, then this is fine. However, if \(p\) is large, then this isn’t feasible. So the question now is what advantages do we get from \(p\) being prime?
Advantages When \(p\) is Prime
- No zero divisors. This means that if \(ab \equiv 0 \pmod{p}\), then either \(a \equiv 0 \pmod{p}\) or \(b \equiv 0 \pmod{p}\).
- Inverses exist. So if \(a \equiv 0 \pmod{p}\), then \(ab \equiv 1 \pmod{p}\)for some \(b\).
- Polynomials of degree \(n\) have at most \(n\) roots. (This isn't guaranteed when \(p\) isn't prime. For example, \(x^2 - 1 \pmod{8}\) has 4 roots.
- We can use Fermat's Theorem \(x^p \equiv x \pmod{p}\).
- Primitive roots exist modulo \(p\). Primitive roots will be discussed in a later lecture.
Polynomial Roots When \(n\) is Prime
Let’s look at (3) specifically. Why is this true when \(p\) is prime. Let’s suppose that \(f(x)\) is a polynomial of degree \(n\) (over a field). Let \(a \in \mathbb{R}\) or \(\mathbb{C}\). By the division algorithm for polynomials, then there exists unique polynomials \(g(x)\) and a constant \(r \in \mathbb{R}\) such that
Now suppose that \(a\) was a root of \(f\) so \(f(a)=0\). Then
So when \(a\) is a root, we must have \(r = 0\). Therefore,
This means that when \(a\) is a root, \(f(x)\) is divisible by \((x-a)\). Using this idea, we can prove that \(f\) has at most \(n\) roots using induction. (TODO…).
Example
Consider the polynomial
What are the roots of this polynomial? \(a\) is a root of \(x^p - x \pmod{p}\) if
But then if \(p\) is prime and if \(a \not\equiv 0 \pmod{p}\), then we know by Fermat’s Little Theorem that
If we multiply both sides with \(a\), we get
Then \(a\) is a root of \(x^p - x \pmod{p}\). But this means that \(0,1,2,\cdots,p-1 \pmod{p}\) are all roots of this polynomial. This implies that the polynomial factors into
Now, we can get some nice identities by expanding this factorization. Consider several values of \(p\). For example
Observe here that all the coefficients in the middle are divisible by \(p\) and hence vanish modulo \(p\). Also observe that the last coefficient is exactly \((p-1)!\) so consider the case when \(p = 5\).
But this is just Wilson’s theorem
Application: Wolstenholme's Theorem
For example when \(p=5\). Then
Proof? [TODO]
The General Case
Now that we’ve looked at a few specific examples, let’s look at a more general problem. Given the congruence
- Does it have solutions? For example we saw that \(x^2 \equiv -1 \pmod{p}\) has solutions only if \(p \equiv 1,2 \pmod{4}\).
- How many solutions?
- How do we find them?
To answer question \(2\), we can find the gcd of \(f(x)\) and \((x^p - x)\). Recall that
So if we take any polynomial \(f\), then
But we know that \((x - a)\) divides \(x^p - x\). So any common factor of \(f\) and \(x^p - x\) must be a root of \(f\). The gcd of \(x^p - x\) and \(f(x)\) modulo \(p\) will in fact be of the form
So to answer question \(2\), we can just find the degree of \(\gcd(f(x),x^p-x)\) which is very neat.
Example
Consider the polynomial
So we want to find the gcd of \((x^3 - x^2 - x + 1)\) and \(x^p-x\). We can use Euclid’s method.
Then, the gcd is \((x-1)\) and the degree is \(1\). So we should have \(1\) distinct root. Warning: This method only counts distinct roots. It will not tell us if this root is of multiplicity greater than \(1\).
Even though this is a neat method, the time taken to find the gcd of \(f\) and \(g\) is roughly \(\deg f + \deg g\). But the degree of \(x^p - x\) might be huge if \(p\) is a large prime. So this is not better than finding the actual roots one by one. Fortunately we can speed things up. The key point is that even if the degree is huge, \(x^p - x\) is a sparse polynomial where most coefficients are zero. And since \(x^p -x\) is a sparse polynomial and \(f(x)\) is a polynomial of a small degree, then we can use the Russian Peasant method to speed up finding the gcd. How? We want to find \(x^p \pmod{f(x)}\). So now we can write \(p\) in binary and we calculate
until we reach \(x^p\).
Example
Suppose we take
We want to know when is \(a\) a square modulo \(p\)? This means that we want the solutions to
In this case, \(a\) is called a quadratic residue modulo \(p\), a number that can be expressed as the square of some integer in \(\mathbb{Z}_p\). To do this, we will use the method of the previous section and find the gcd of \(x^2-a\) and \(x^p-x\). To do this, we will use Euclid again. We will divide \(x^p-x\) by \(x^2-a\). Notice that \(x^p - x = x(x^{p-1} - 1)\). So we can divide
The remainder is \((a^{(p-1)/2} - 1)\). Now if \(a^{(p-1)/2} - 1 \not\equiv 0 \pmod{p}\), then we don’t have a root. Otherwise, \(a^{(p-1)/2} - 1 \equiv 0 \pmod{p}\) and we have a root. In general, we know by Euler’s Criterion that when \(a \not\equiv 0 \pmod{p}\), then we get
So this gives us a fast method to check if \(a\) is a square (quadratic residue) modulo \(p\). This isn’t the best method. Later in the class, we’ll have a better method called Jacobi.
Application
Proof
Since \(d \mid (p-1)\). Then we can write \(p - 1 = dk\) for some integer \(k\). Then we can re-write \(x^{p-1}\) as follows
Recall now that we can factor any polynomial \(y^t - 1\) as
So we can use this to factor \(x^{p-1} - 1\) as follows
But this shows that \((x^d - 1)\) divides \(x^{p-1} - 1\). However, we saw earlier that by Fermat, we know the roots of \(x^{p-1} - 1\) is a product of linear factors and we can write
But since we showed that \(x^d - 1\) divides the product of linear factors, then \(x^d-1\) itself must be a product of some of these linear factors. Let \(S \subseteq \{1,...,p-1\}\) such that \(S\) contains the roots of \(x^{d-1}\). Then
Since \(x^d - 1\) is a product of linear factors, then we must have \(d\) factors and so \(|S| = d\).