# L'Hospital rules in finite fields
**Warning.** "I have only proved it correct, not tried it."
$$
\def\F{\mathbb{F}}
\def\diff#1{\frac{\delta}{\delta #1}}
$$
Given $P,Q ∈ \F[X]$. Consider the fraction
$$
\frac{P(X)}{Q(X)}
$$
If this fraction is $\frac 00$ indeterminate in some value $𝛼 ∈ \F$, we can elliminate the zeros we found:
$$
\frac{P(X)/(X - 𝛼)}{Q(X)/(X - 𝛼)}
$$
If necessary we can repeat this untill the fraction is no longer indeterminate.
In real numbers, there is an alternative trick, where instead we differentiate the numbers:
$$
\frac{\diff X P(X)}{\diff X Q(X)}
$$
again, repeated as necessary. This trick can be applied in Finite Fields too, if we use formal derivatives.
Intuition suggest that L'Hospital's rule should give the same result at $X = 𝛼$. This essentially boils down to the following identity:
---
**Lemma.** *Given $P,Q ∈ \F[X]$ and $𝛼 ∈ \F$, then*
$$
\left. \frac{\diff X P(X)}{\diff X Q(X)} \right\vert_{X = 𝛼} =
\left. \frac{P(X)/(X - 𝛼)}{Q(X)/(X - 𝛼)} \right\vert_{X = 𝛼}
$$
*Proof.* Follows directly from below lemma.
---
**Lemma.** *Given $P ∈ \F[X]$ and $𝛼 ∈ \F$ with $P(𝛼) = 0$ then*
$$
\left. \diff X P(X) \right\vert_{X = 𝛼} =
\left. \frac{P(X)}{X - 𝛼} \right\vert_{X = 𝛼}
$$
*Proof.* Substitute $X = U + 𝛼$ with $\diff X = \frac{\delta U}{\delta X}\diff U = \diff U$:
$$
\left. \diff U P(U + 𝛼) \right\vert_{U = 0} =
\left. \frac{P(U + 𝛼)}{U} \right\vert_{U = 0}
$$
Write $S(U) = P(U + 𝛼)$ such that $S(0) = 0$ and $S(U) = s_1 U + s_2 U^2 + ⋯$.
$$
\begin{aligned}
\left. \diff U S(U) \right\vert_{U = 0} &=
\left. \frac{S(U)}{U} \right\vert_{U = 0}
\\
\left. \diff U \left(s_1 U + s_2 U^2 + ⋯ \right) \right\vert_{U = 0} &=
\left. \frac{s_1 U + s_2 U^2 + ⋯}{U} \right\vert_{U = 0}
\\
\left. \left(s_1 + 2 s_2 U + 3 s_3 U^2 ⋯ \right) \right\vert_{U = 0} &=
\left. \left(s_1 + s_2 U + s_3 U^2 ⋯ \right) \right\vert_{U = 0}
\\
s_1 &= s_1
\end{aligned}
$$
□
**Note.** The left-hand side expression does not depend on $𝛼$, so the differentiated polynomial will give the divided out values wherever $P(X) = 0$. $P$ of $\deg P = n$ has at most $n$ roots and interpolates $n + 1$ points. $P'(X)$ has $\deg P' = n - 1$ and interpolates the $n$ roots and their associated divided out values.
**Corrolary.** *The formal derivative of a polynomial is the polynomial that interpolates all the 'divided out zeros'.*
**To do.** What if the the original polynomial contains zeros of higher multiplicity?
**To do.** What if the original polynomial contains irreducible factors of higher degree?
---
The above suggest a more general theorem:
**Lemma.** *Given $P ∈ \F[X]$ and $z ∈ \F$, the following holds:*
$$
\left. \diff X P(X) \right\vert_{X = z} =
\left. \frac{P(X) - P(z)}{X - z} \right\vert_{X = z}
$$
---
$$
P(X) = \prod_i (X - a_i)
$$
Can this be evaluated using dual numbers? See https://en.wikipedia.org/wiki/Dual_number .
Evaluate over $\F[\bar X,Ε]/(Ε^2)$ with $X = \bar X + Ε$:
$$
P(X) = \prod_i (\bar X + Ε - a_i)
$$
The result will be $P(\bar X) + \left(\diff {\bar X} P(\bar X)\right) E$, i.e. the first derivative will be the coefficient of $E$.
Using a higher cut-off $\F[\bar X,Ε]/(Ε^n)$, higher order derivates can be obtained.
The division function can be modified to automatically apply L'Hospital's rule when it faces a $\frac 00$ indeterminate. This allows an evaluation strategy that would normally fail suceed anyway when executed over the dual numbers.
Take for example the $i$-th Lagrange interpolants over $⟨𝜔⟩$
$$
\frac{X^n - 1}{X - 𝜔^i}
$$