Tutorials › Linear Algebra › Polynomial Evaluation Over Finite Fields

Linear Algebra Beyond the Reals · Tutorial 979 of 1000

Polynomial Evaluation Over Finite Fields

Learn how polynomial evaluation over \(\mathbb{F}_p\) relates formal polynomials to functions, and why distinct polynomials can have identical values everywhere.

Intermediate 9 min read

What You'll Learn

  • Distinguish coefficientwise polynomial equality from equality at every field input.
  • Prove that each \(a\in\mathbb{F}_p\) satisfies \(a^p=a\).
  • Explain why the nonzero polynomial \(x^p-x\) evaluates to zero throughout \(\mathbb{F}_p\).
  • Use the root bound to identify when two polynomials define the same function.
  • Construct and verify a polynomial of degree less than \(p\) for any function on \(\mathbb{F}_p\).

Polynomials and the Functions They Define

Over the real numbers, a nonzero polynomial cannot vanish at every input. Over a finite field, however, the field has only finitely many inputs. A polynomial can be nonzero as a formal expression and still evaluate to zero at every element of the field. Understanding this distinction is essential whenever polynomials over finite fields are used to describe data or build algebraic constructions.

Fix a prime \(p\). The field \(\mathbb{F}_p\) consists of the residue classes \(0,1,\dots,p-1\), with addition and multiplication performed modulo \(p\). A polynomial in \(\mathbb{F}_p[x]\) is a formal expression \(f(x)=a_0+a_1x+\cdots+a_dx^d\) with coefficients \(a_i\in\mathbb{F}_p\). Two polynomials are formally equal exactly when their coefficients of each power of \(x\) are equal. Evaluating \(f\) at \(a\in\mathbb{F}_p\) gives an element \(f(a)\in\mathbb{F}_p\); this defines a function from \(\mathbb{F}_p\) to itself.

Definition: Polynomials \(f,g\in\mathbb{F}_p[x]\) are formally equal if their corresponding coefficients are equal. They are equal as functions on \(\mathbb{F}_p\) if \(f(a)=g(a)\) for every \(a\in\mathbb{F}_p\). Formal equality always implies equality as functions, but the converse need not hold.

The reason the converse can fail is that evaluation records only the values at the \(p\) elements of the field. A polynomial has coefficients at every power of \(x\), so the formal expression contains more information than its list of evaluations may preserve.

Why \(x^p-x\) Vanishes Everywhere

The key arithmetic fact is that every element of \(\mathbb{F}_p\) satisfies \(a^p=a\). Here is a proof that includes both zero and nonzero elements.

Theorem: For every \(a\in\mathbb{F}_p\), \(a^p=a\).

Proof. If \(a=0\), then \(a^p=0=a\). Now suppose \(a\ne0\). Multiplication by \(a\) sends the nonzero elements of \(\mathbb{F}_p\) to nonzero elements. It is one-to-one: if \(au=av\), then multiplying by \(a^{-1}\) gives \(u=v\). Since the set \(\mathbb{F}_p\setminus\{0\}\) is finite, this one-to-one map permutes its elements. Let \(P\) be the product of all \(p-1\) nonzero elements. Since none of those elements is zero, \(P\ne0\). The permutation gives \(P=\prod_{u\ne0}(au)=a^{p-1}P\). Multiplying by \(P^{-1}\) gives \(a^{p-1}=1\), and hence \(a^p=a\). \(\square\)

Consequently, the polynomial \(x^p-x\) evaluates to zero at every field element. But as a formal polynomial it has coefficient \(1\) on \(x^p\), so it is not the zero polynomial.

Worked Example: Evaluating \(x^5-x\) Over \(\mathbb{F}_5\)

Consider \(f(x)=x^5-x\in\mathbb{F}_5[x]\). Its coefficient of \(x^5\) is \(1\), so \(f\) is formally nonzero. Evaluate at every element of \(\mathbb{F}_5\):

$$ \begin{aligned} f(0)&=0^5-0=0,\\ f(1)&=1^5-1=0,\\ f(2)&=2^5-2=32-2=30\equiv0\pmod 5,\\ f(3)&=3^5-3=243-3=240\equiv0\pmod 5,\\ f(4)&=4^5-4=1024-4=1020\equiv0\pmod 5. \end{aligned} $$

Thus \(f\) is not the zero formal polynomial, but its evaluation is the zero function on \(\mathbb{F}_5\). Each computed value agrees with the theorem \(a^5=a\).

How Many Roots Can a Polynomial Have?

A root of \(f\) is an element \(a\) for which \(f(a)=0\). The usual root bound remains valid over a finite field: a nonzero polynomial of degree \(d\) has at most \(d\) distinct roots. The bound does not say that a polynomial cannot have more roots than there are elements in its field; it says only that the number of roots cannot exceed its degree.

Theorem (Root bound): If \(f\in\mathbb{F}_p[x]\) is nonzero and has degree \(d\), then \(f\) has at most \(d\) distinct roots in \(\mathbb{F}_p\).

Proof. We use induction on \(d\). If \(d=0\), then \(f\) is a nonzero constant and has no roots. Suppose \(d\ge1\), and assume the result holds for degree \(d-1\). If \(f\) has no roots, the claim holds. Otherwise choose a root \(a\). For each integer \(k\ge1\), the identity \(x^k-a^k=(x-a)(x^{k-1}+x^{k-2}a+\cdots+a^{k-1})\) shows that \(x^k-a^k\) is divisible by \(x-a\). Applying this to each term of \(f(x)-f(a)\), and using \(f(a)=0\), gives \(f(x)=(x-a)q(x)\) for a polynomial \(q\) of degree \(d-1\). If \(b\ne a\) is another root of \(f\), then \(0=f(b)=(b-a)q(b)\). Because \(b-a\ne0\) in the field, \(q(b)=0\). Thus all roots other than \(a\) are roots of \(q\), which has at most \(d-1\) roots by induction. Including \(a\), \(f\) has at most \(d\) distinct roots. \(\square\)

In the example over \(\mathbb{F}_5\), \(x^5-x\) has degree \(5\) and has exactly five roots. This reaches the bound; it does not violate it.

Characterizing Polynomials with the Same Values

Two polynomials define the same function on \(\mathbb{F}_p\) exactly when their difference is divisible by \(x^p-x\). To see why divisibility is the right condition, first note that \(x^p-x\) vanishes at every field element. Therefore any polynomial multiple of it also vanishes everywhere. For the converse, we need to know that vanishing at all field elements forces divisibility by this particular polynomial.

For a polynomial \(f\), the identity used in the root-bound proof shows that \(f(x)-f(a)\) is divisible by \(x-a\). Thus, if \(f(a)=0\), then \(x-a\) divides \(f\). If \(f\) vanishes at every element of \(\mathbb{F}_p\), we can successively factor out one linear factor for each field element: after factoring out \(x-a\), the remaining quotient still vanishes at every other element \(b\), since \(0=f(b)=(b-a)q(b)\) and \(b-a\ne0\).

Theorem: For \(f,g\in\mathbb{F}_p[x]\), the polynomials \(f\) and \(g\) define the same function on \(\mathbb{F}_p\) if and only if \(x^p-x\) divides \(f-g\).

Proof. First, \(x^p-x\) has degree \(p\), is monic, and vanishes at all \(p\) elements of \(\mathbb{F}_p\), by the theorem \(a^p=a\). It equals the product of the \(p\) distinct factors \(x-a\) for \(a\in\mathbb{F}_p\): the product is monic of degree \(p\), and its roots are exactly those elements. The difference between that product and \(x^p-x\) has degree at most \(p-1\) because their leading terms cancel, and it vanishes at all \(p\) elements. The root bound forces that difference to be the zero polynomial.

Now suppose \(f\) and \(g\) define the same function. Then \(h=f-g\) vanishes at every \(a\in\mathbb{F}_p\). Factoring out \(x-a\) for each field element as described above shows that their product, \(x^p-x\), divides \(h\). Conversely, suppose \(f-g=(x^p-x)q\) for some \(q\in\mathbb{F}_p[x]\). For every \(a\in\mathbb{F}_p\), \(f(a)-g(a)=(a^p-a)q(a)=0\). Thus \(f(a)=g(a)\) for every \(a\), so the polynomials define the same function. \(\square\)

Worked Example: Distinct Polynomials, Identical Function

Compare \(f(x)=x^3+1\) and \(g(x)=x+1\) over \(\mathbb{F}_3\). They are not formally equal: \(f\) has coefficient \(1\) on \(x^3\), while \(g\) has coefficient \(0\) there. Their difference is \(x^3-x\). Evaluate both at each field element:

$$ \begin{array}{c|ccc} a&0&1&2\\ \hline f(a)=a^3+1&1&2&9\equiv0\pmod3\\ g(a)=a+1&1&2&3\equiv0\pmod3 \end{array} $$

The values agree at \(0\), \(1\), and \(2\), so the functions are identical. In fact, \(f-g=x^3-x\), which is exactly \(x^p-x\) for \(p=3\); the theorem explains why the agreement holds.

Every Function Has a Unique Low-Degree Polynomial

The theorem also explains why polynomials of degree less than \(p\) are a useful way to represent functions on \(\mathbb{F}_p\). Each function has exactly one such representing polynomial. “Degree less than \(p\)” here means that all powers appearing have exponent at most \(p-1\); the zero polynomial is included.

Theorem: For every function \(F:\mathbb{F}_p\to\mathbb{F}_p\), there is a unique polynomial \(P\in\mathbb{F}_p[x]\) of degree less than \(p\) such that \(P(a)=F(a)\) for every \(a\in\mathbb{F}_p\).

Proof. For each \(a\in\mathbb{F}_p\), define \(L_a(x)=\prod_{b\in\mathbb{F}_p,\ b\ne a}\frac{x-b}{a-b}\). Every denominator \(a-b\) is nonzero, so it has an inverse in the field. The polynomial \(L_a\) has degree \(p-1\). At \(x=a\), each factor equals \(1\), so \(L_a(a)=1\). At any other field element \(c\ne a\), the factor for \(b=c\) is zero, so \(L_a(c)=0\). Therefore \(P(x)=\sum_{a\in\mathbb{F}_p}F(a)L_a(x)\) has degree at most \(p-1\) and satisfies \(P(c)=F(c)\) for every \(c\).

For uniqueness, suppose \(P\) and \(Q\) both have degree less than \(p\) and agree with \(F\) at every field element. Then \(P-Q\) vanishes at all \(p\) elements. If \(P-Q\) were nonzero, its degree would be at most \(p-1\), contradicting the root bound. Hence \(P-Q\) is the zero polynomial, so \(P=Q\). \(\square\)

Worked Example: Interpolating a Function on \(\mathbb{F}_3\)

Let \(F:\mathbb{F}_3\to\mathbb{F}_3\) have values \(F(0)=0\), \(F(1)=0\), and \(F(2)=1\). Find its polynomial of degree less than \(3\). Write \(P(x)=a+bx+cx^2\), with \(a,b,c\in\mathbb{F}_3\). Substituting the three inputs gives

$$ \begin{aligned} P(0)=0&\implies a=0,\\ P(1)=0&\implies a+b+c=0\implies b+c=0,\\ P(2)=1&\implies a+2b+4c=1\implies 2b+c=1. \end{aligned} $$

Subtract \(b+c=0\) from \(2b+c=1\), obtaining \(b=1\) in \(\mathbb{F}_3\). Then \(c=-1=2\), and \(a=0\). Thus \(P(x)=x+2x^2\). Check the values: \(P(0)=0\), \(P(1)=1+2=0\) in \(\mathbb{F}_3\), and \(P(2)=2+2\cdot4=10\equiv1\pmod3\). The polynomial has the required values, and uniqueness follows from the theorem.

Common Mistake: Confusing Roots with Formal Zero

A tempting but incorrect claim is: “If a polynomial evaluates to zero at every field element, it must be the zero polynomial.” Over \(\mathbb{F}_3\), the concrete counterexample is \(x^3-x\). It is formally nonzero, but its evaluations are \(0^3-0=0\), \(1^3-1=0\), and \(2^3-2=6\equiv0\pmod3\). The correction is to distinguish the polynomial from its induced function. The root bound is still true: \(x^3-x\) has degree \(3\) and exactly \(3\) roots.

In practical terms, evaluation can identify different formal polynomials. The theorem on \(x^p-x\) gives the precise test: \(f\) and \(g\) yield the same values at every field element if and only if their difference is a multiple of \(x^p-x\). Restricting to degree less than \(p\) removes this ambiguity, since each function then has a unique polynomial representation.

Check Your Understanding

Use arithmetic in the stated finite field, and distinguish formal equality from equality of values.

  1. In \(\mathbb{F}_3[x]\), is \(x^3+2x\) formally equal to \(2x\)? Do the two polynomials define the same function on \(\mathbb{F}_3\)?
  2. Why does the root bound not rule out a degree-\(p\) polynomial vanishing at all \(p\) elements of \(\mathbb{F}_p\)?
  3. Show that \(x^4-x\) evaluates to zero at every element of \(\mathbb{F}_4\) only if \(\mathbb{F}_4\) is understood as a field with four elements; explain why the prime-field theorem above cannot be applied directly to it.
  4. Find a polynomial of degree less than \(3\) representing the function on \(\mathbb{F}_3\) with values \(F(0)=1\), \(F(1)=1\), \(F(2)=0\).
  5. State the divisibility condition that is equivalent to two polynomials defining the same function on \(\mathbb{F}_5\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon