Can we differentiate Fermat's little theorem?

Solution 1:

To be able to differentiate, you need to prove that your equality is not just true point wise, but as an equality of polynomials (which is strictly stronger).

Namely, let us denote $P \equiv Q \pmod p$ if all the coefficients of $P-Q$ are multiples of $p$ (we'll call that polynomial equality mod $p$). Notice that polynomial equality implies point wise equality :

$$P \equiv Q \pmod p \implies \forall x \in \mathbb{Z}, P(x) \equiv Q(x) \pmod p$$

But beware the converse isn't true in general (take for example $P=X^p-X$ and $Q=0$). Now we prove that the polynomial equality can be differentiated (while point wise equality cannot, using the same counter example) : indeed, if we assume $P \equiv Q \pmod p$, then we can write $P(X)-Q(X) = p R(X)$ with $R \in \mathbb{Z}[X]$. And by differentiating, we get $P'(X) - Q'(X) = p R'(X)$, so $P' \equiv Q' \pmod p$.

Now let's denote $P = X(X-1)(X-2)\ldots (X-p+1)$ and $Q = X^p -X$. And let's prove that $P \equiv Q \pmod p$, which will allow us to differentiate. Let us consider $R = P-Q$ and notice that $\deg R = p-1$ because the terms of degree $p$ of $P$ and $Q$ cancel out. Now remember that $k = \mathbb{Z}/p\mathbb{Z}$ is a field, and that $R(a) = 0$ for all $a \in k$. In other words, the polynomial $R \in k_{p-1}[X]$ has $p$ roots in $k$, so it must be $0$. Which means $P-Q \equiv 0 \pmod p$.