MATH2400 2,453 words·13 min read

Polynomial Congruences

The Mod Operator for Polynomials#

Recall from Modular Arithmetic that the whole of integer modular arithmetic grew out of a single result: the Division Theorem, which says that any integer aa can be written uniquely as a=qn+ra = qn + r with 0≤r<n0 \leq r < n. Everything after that (congruence classes, Zn\mathbb{Z}_n, linear congruences, the CRT) was really just bookkeeping around remainders.

Now that Polynomial Rings has handed us a Division Theorem for F[x]F[x] over any field FF, we can run the entire story again with polynomials playing the part of integers. This lecture is the polynomial mirror of Topics 3 and 4, and almost every statement in it will look familiar; the only real change is that the size condition "0≤r<n0 \leq r < n" gets replaced by the degree condition "deg⁡(r)<deg⁡(m)\deg(r) < \deg(m)".

Note

Notation
The mod operator returns the remainder when one polynomial is divided by another in F[x]F[x], for any field FF. That is, given polynomials f(x),g(x)∈F[x]f(x), g(x) \in F[x] with g(x)≠0g(x) \neq 0, we have

f(x) mod g(x)=r(x),f(x) \bmod g(x) = r(x),

where deg⁡(r(x))<deg⁡(g(x))\deg(r(x)) < \deg(g(x)) and f(x)=q(x)g(x)+r(x)f(x) = q(x)g(x) + r(x) for some polynomials q(x),r(x)∈F[x]q(x), r(x) \in F[x].

Basically, f(x) mod g(x)f(x) \bmod g(x) is just "do the long division and throw the quotient away". The Division Theorem is what makes this a legitimate operator: it guarantees that the pair q(x),r(x)q(x), r(x) exists and is unique, so there is exactly one possible answer. Notice that the remainder is allowed to be the zero polynomial, which is exactly the statement g(x)∣f(x)g(x) \mid f(x).

The coefficients must live in a field, and every coefficient has to be reduced inside that field before you read off your answer. This is the single most common slip when the field is Zp\mathbb{Z}_p; a coefficient of −4-4 in Z3[x]\mathbb{Z}_3[x] is not a coefficient of −4-4, it is a coefficient of 22, and writing it the wrong way will make a perfectly correct division look wrong.

Example. In Q[x]\mathbb{Q}[x], find (x2+x+1) mod (x2+1)(x^2 + x + 1) \bmod (x^2 + 1).
The two polynomials have the same degree, so the quotient is just the constant 11;

x2+x+1=1⋅(x2+1)+x,\begin{align*} x^2 + x + 1 &= 1 \cdot (x^2 + 1) + x, \end{align*}

and deg⁡(x)=1<2=deg⁡(x2+1)\deg(x) = 1 < 2 = \deg(x^2+1), so the division has finished. Therefore, (x2+x+1) mod (x2+1)=x(x^2 + x + 1) \bmod (x^2 + 1) = x.

Example. In Z3[x]\mathbb{Z}_3[x], find (x2−4) mod (x+1)(x^2 - 4) \bmod (x + 1).
First reduce the coefficients in Z3\mathbb{Z}_3: since −4=−4+6=2-4 = -4 + 6 = 2 in Z3\mathbb{Z}_3, the polynomial being divided is really x2+2x^2 + 2. Dividing,

x2+2=(x−1)(x+1)+3=(x+2)(x+1)+0 in Z3[x],\begin{align*} x^2 + 2 &= (x - 1)(x + 1) + 3 \\ &= (x + 2)(x + 1) + 0 \text{ in } \mathbb{Z}_3[x], \end{align*}

since 3=03 = 0 in Z3\mathbb{Z}_3. Therefore, (x2−4) mod (x+1)=0(x^2 - 4) \bmod (x + 1) = 0; equivalently, (x+1)∣(x2−4)(x+1) \mid (x^2 - 4) in Z3[x]\mathbb{Z}_3[x].

The Remainder Theorem from Polynomial Rings gets this instantly and with no long division at all: dividing by x−ax - a leaves remainder f(a)f(a), and here a=−1a = -1, so

f(−1)=(−1)2−4=−3=0 in Z3.\begin{align*} f(-1) &= (-1)^2 - 4 \\ &= -3 \\ &= 0 \text{ in } \mathbb{Z}_3. \end{align*}

Whenever the divisor is linear, use the Remainder Theorem; long division by x−ax - a is wasted effort. Notice also that this answer is genuinely field-dependent: over Q\mathbb{Q} the same computation gives f(−1)=−3≠0f(-1) = -3 \neq 0, so (x2−4) mod (x+1)=−3(x^2-4) \bmod (x+1) = -3 in Q[x]\mathbb{Q}[x]. The polynomial did not change, the field did.

Example. In Z3[x]\mathbb{Z}_3[x], find (x4+2x3+x+1) mod (x2+2)(x^4 + 2x^3 + x + 1) \bmod (x^2 + 2).
Long division, remembering that every coefficient is reduced mod 33 as we go:

x4+2x3+x+1−x2(x2+2)=2x3−2x2+x+1=2x3+x2+x+1,2x3+x2+x+1−2x(x2+2)=x2+x+1−4x=x2+1,x2+1−1(x2+2)=−1=2.\begin{align*} x^4 + 2x^3 + x + 1 - x^2(x^2 + 2) &= 2x^3 - 2x^2 + x + 1 \\ &= 2x^3 + x^2 + x + 1, \\ 2x^3 + x^2 + x + 1 - 2x(x^2 + 2) &= x^2 + x + 1 - 4x \\ &= x^2 + 1, \\ x^2 + 1 - 1(x^2 + 2) &= -1 \\ &= 2. \end{align*}

Collecting the quotient terms x2x^2, 2x2x and 11 gives

x4+2x3+x+1=(x2+2x+1)(x2+2)+2,x^4 + 2x^3 + x + 1 = (x^2 + 2x + 1)(x^2 + 2) + 2,

and deg⁡(2)=0<2\deg(2) = 0 < 2. Therefore, (x4+2x3+x+1) mod (x2+2)=2(x^4 + 2x^3 + x + 1) \bmod (x^2 + 2) = 2.

Example. In Q[x]\mathbb{Q}[x], find (x3−2x+5) mod (x−2)(x^3 - 2x + 5) \bmod (x - 2).
The divisor is linear, so the Remainder Theorem applies with a=2a = 2;

f(2)=23−2(2)+5=8−4+5=9.\begin{align*} f(2) &= 2^3 - 2(2) + 5 \\ &= 8 - 4 + 5 \\ &= 9. \end{align*}

Therefore, (x3−2x+5) mod (x−2)=9(x^3 - 2x + 5) \bmod (x - 2) = 9. (As a check, the full division gives x3−2x+5=(x2+2x+2)(x−2)+9x^3 - 2x + 5 = (x^2 + 2x + 2)(x - 2) + 9.)

Congruence of Polynomials#

With a mod operator in hand, congruence is defined exactly as it was for integers.

Note

Notation
Given polynomials f(x),g(x),m(x)∈F[x]f(x), g(x), m(x) \in F[x], we say that f(x)f(x) and g(x)g(x) are congruent modulo m(x)m(x), and write

f(x)≡g(x)(modm(x)),f(x) \equiv g(x) \pmod{m(x)},

to mean that f(x) mod m(x)=g(x) mod m(x)f(x) \bmod m(x) = g(x) \bmod m(x), or equivalently that m(x)∣f(x)−g(x)m(x) \mid f(x) - g(x).

Basically, two polynomials are congruent when they leave the same remainder, which is the same as saying their difference is a multiple of the modulus. These are the same two descriptions we had for integers in Modular Arithmetic, and in practice you pick whichever is cheaper: computing two remainders, or subtracting and doing one divisibility check.

There is a third description that we will make official in the next section, and it is the one that gets used most: f(x)f(x) and g(x)g(x) are congruent mod m(x)m(x) exactly when they are equal as elements of the quotient system F[x]/⟨m(x)⟩F[x]/\langle m(x)\rangle. So there are three equivalent formulations to keep straight:

  • f(x) mod m(x)=g(x) mod m(x)f(x) \bmod m(x) = g(x) \bmod m(x) (equal remainders),
  • m(x)∣f(x)−g(x)m(x) \mid f(x) - g(x) (the difference is a multiple of the modulus),
  • f(x)=g(x)f(x) = g(x) in F[x]/⟨m(x)⟩F[x]/\langle m(x)\rangle (equal in the quotient).

Example. In Z3[x]\mathbb{Z}_3[x], verify that x3+2x+1≡x+1(modx2+1)x^3 + 2x + 1 \equiv x + 1 \pmod{x^2 + 1} using both of the first two formulations.
For the remainder version, divide each side by x2+1x^2 + 1. Since x2≡−1x^2 \equiv -1, we get x3=x⋅x2≡−x=2xx^3 = x \cdot x^2 \equiv -x = 2x, so

x3+2x+1≡2x+2x+1=4x+1=x+1 in Z3[x],\begin{align*} x^3 + 2x + 1 &\equiv 2x + 2x + 1 \\ &= 4x + 1 \\ &= x + 1 \text{ in } \mathbb{Z}_3[x], \end{align*}

while x+1x + 1 already has degree 1<21 < 2 and so is its own remainder. Both sides leave remainder x+1x+1.
For the divisibility version, subtract:

(x3+2x+1)−(x+1)=x3+x=x(x2+1),\begin{align*} (x^3 + 2x + 1) - (x + 1) &= x^3 + x \\ &= x(x^2 + 1), \end{align*}

which is visibly a multiple of x2+1x^2+1. Therefore, the congruence holds, and the two tests agree as the mod operator promises they must.

The Set of Polynomials Modulo m(x)#

For integers, the set of remainders modulo nn was packaged into the ring Zn\mathbb{Z}_n (see Modular Rings and Units). The polynomial version does exactly the same thing with the set of possible remainders modulo m(x)m(x).

Note

Definition 7.11
Given any polynomial m(x)∈F[x]m(x) \in F[x] with degree nn, the set of polynomials modulo m(x)m(x) is denoted F[x]/⟨m(x)⟩F[x]/\langle m(x)\rangle, and is the algebraic system with elements

{a0+a1x+a2x2+⋯+an−1xn−1:ai∈F}\{a_0 + a_1x + a_2x^2 + \cdots + a_{n-1}x^{n-1} : a_i \in F\}

and addition and multiplication operations the same as in F[x]F[x], except always reduced to the remainder with smallest degree modulo m(x)m(x).

Basically, the elements are exactly the possible remainders on division by m(x)m(x); every polynomial of degree less than nn, and nothing else. You add and multiply as normal polynomials and then reduce mod m(x)m(x) at the end, in the same way that arithmetic in Zn\mathbb{Z}_n is ordinary integer arithmetic followed by taking a remainder.

Note

Notation
We may write "f(x)=g(x)f(x) = g(x) in F[x]/⟨m(x)⟩F[x]/\langle m(x)\rangle" (or similarly) to mean the same thing as f(x)≡g(x)(modm(x))f(x) \equiv g(x) \pmod{m(x)}.

This matches the habit from earlier topics of writing "=4= 4 in Z15\mathbb{Z}_{15}" rather than "≡4(mod15)\equiv 4 \pmod{15}"; the ≡\equiv notation emphasises the relation, the == notation emphasises that we are working inside a fixed finite system where the reduced form is the element.

Counting is easy: an element is determined by its nn coefficients a0,…,an−1a_0, \dots, a_{n-1}, each chosen freely from FF. So if FF is finite,

∣F[x]/⟨m(x)⟩∣=∣F∣n,where n=deg⁡(m(x)).\boxed{\left| F[x]/\langle m(x)\rangle \right| = |F|^n, \quad \text{where } n = \deg(m(x)).}

The count depends only on the degree of m(x)m(x), not on which polynomial of that degree you chose. Whether m(x)m(x) factors or not changes the structure enormously (that is the subject of Irreducible Polynomials), but never the number of elements.

Example. List the elements of Z3[x]/⟨x2+1⟩\mathbb{Z}_3[x]/\langle x^2 + 1\rangle.
Here F=Z3F = \mathbb{Z}_3 and deg⁡(x2+1)=2\deg(x^2+1) = 2, so the elements are all a0+a1xa_0 + a_1 x with a0,a1∈{0,1,2}a_0, a_1 \in \{0,1,2\}, and there are ∣F∣n=32=9|F|^n = 3^2 = 9 of them:

Z3[x]/⟨x2+1⟩={0, 1, 2, x, x+1, x+2, 2x, 2x+1, 2x+2}.\begin{align*} \mathbb{Z}_3[x]/\langle x^2+1\rangle &= \{0,\ 1,\ 2,\ x,\ x+1,\ x+2,\ 2x,\ 2x+1,\ 2x+2\}. \end{align*}

Therefore, there are exactly 99 elements. Notice that this is not Z9\mathbb{Z}_9; it has nine elements, but the arithmetic is completely different, as the next example shows.

Example. In Z3[x]/⟨x2+1⟩\mathbb{Z}_3[x]/\langle x^2 + 1\rangle, compute (x+2)+(2x+2)(x+2) + (2x+2) and (2x+1)(x+2)(2x+1)(x+2).
Addition never needs reducing, since the sum of two polynomials of degree <2< 2 still has degree <2< 2:

(x+2)+(2x+2)=3x+4=0x+1=1.\begin{align*} (x + 2) + (2x + 2) &= 3x + 4 \\ &= 0x + 1 \\ &= 1. \end{align*}

Multiplication does need reducing. The key relation is x2+1=0x^2 + 1 = 0, i.e.

x2=−1=2 in Z3[x]/⟨x2+1⟩,x^2 = -1 = 2 \text{ in } \mathbb{Z}_3[x]/\langle x^2+1\rangle,

so every x2x^2 that appears can be swapped for −1-1 on sight:

(2x+1)(x+2)=2x2+4x+x+2=2x2+5x+2=2x2+2x+2=2(−1)+2x+2=2x.\begin{align*} (2x+1)(x+2) &= 2x^2 + 4x + x + 2 \\ &= 2x^2 + 5x + 2 \\ &= 2x^2 + 2x + 2 \\ &= 2(-1) + 2x + 2 \\ &= 2x. \end{align*}

Therefore, (x+2)+(2x+2)=1(x+2) + (2x+2) = 1 and (2x+1)(x+2)=2x(2x+1)(x+2) = 2x in Z3[x]/⟨x2+1⟩\mathbb{Z}_3[x]/\langle x^2+1\rangle. Substituting x2=−1x^2 = -1 is the same operation as dividing by x2+1x^2+1 and keeping the remainder; it is just far faster, and you should always reach for it once the modulus is fixed.

Example. List the elements of Z2[x]/⟨x2+x+1⟩\mathbb{Z}_2[x]/\langle x^2 + x + 1\rangle and write down its multiplication table.
Here ∣F∣n=22=4|F|^n = 2^2 = 4, so the elements are 0,1,x,x+10, 1, x, x+1. The relation x2+x+1=0x^2 + x + 1 = 0 gives

x2=−x−1=x+1 in Z2[x]/⟨x2+x+1⟩,\begin{align*} x^2 &= -x - 1 \\ &= x + 1 \text{ in } \mathbb{Z}_2[x]/\langle x^2+x+1\rangle, \end{align*}

using −1=1-1 = 1. Reducing every product with this,

x⋅x=x2=x+1,x(x+1)=x2+x=(x+1)+x=1,(x+1)(x+1)=x2+2x+1=x2+1=(x+1)+1=x,\begin{align*} x \cdot x &= x^2 = x+1, \\ x(x+1) &= x^2 + x = (x+1) + x = 1, \\ (x+1)(x+1) &= x^2 + 2x + 1 = x^2 + 1 = (x+1) + 1 = x, \end{align*}

which fills in the table:

×\times 00 11 xx x+1x+1
00 00 00 00 00
11 00 11 xx x+1x+1
xx 00 xx x+1x+1 11
x+1x+1 00 x+1x+1 11 xx

Therefore, Z2[x]/⟨x2+x+1⟩\mathbb{Z}_2[x]/\langle x^2+x+1\rangle has four elements and the multiplication table above. Notice that every nonzero row contains a 11, so every nonzero element has a multiplicative inverse; by the definition in Rings and Fields this system is a field with four elements, which is something Zn\mathbb{Z}_n can never give us (there is no Z4\mathbb{Z}_4 that is a field). This is exactly why polynomial quotients matter, and it happens here because x2+x+1x^2+x+1 has no roots in Z2\mathbb{Z}_2; more on that in Irreducible Polynomials.

Reducing Powers in the Quotient#

Computing a high power of xx inside F[x]/⟨m(x)⟩F[x]/\langle m(x)\rangle is the polynomial version of computing aka^k in Zn\mathbb{Z}_n, and there are the same two ways to do it: grind out the division, or find a small power of xx that collapses to something trivial and exploit it. The second way is almost always faster, and it is the direct analogue of reducing an exponent modulo the order in Order and Primitive Elements.

Example. Find x5+1x^5 + 1 in Z3[x]/⟨x2+1⟩\mathbb{Z}_3[x]/\langle x^2 + 1\rangle.
By long division, taking one quotient term at a time:

x5+1−x3(x2+1)=−x3+1,−x3+1+x(x2+1)=x+1,\begin{align*} x^5 + 1 - x^3(x^2+1) &= -x^3 + 1, \\ -x^3 + 1 + x(x^2 + 1) &= x + 1, \end{align*}

and deg⁡(x+1)=1<2\deg(x+1) = 1 < 2, so we stop. Collecting the quotient terms,

x5+1=(x3−x)(x2+1)+(x+1),x^5 + 1 = (x^3 - x)(x^2 + 1) + (x + 1),

so the remainder is x+1x+1.
Alternatively, and much faster, use the relation x2=−1x^2 = -1 directly:

x4=(x2)2=(−1)2=1,x5=x4⋅x=x,x5+1=x+1.\begin{align*} x^4 &= (x^2)^2 \\ &= (-1)^2 \\ &= 1, \\ x^5 &= x^4 \cdot x \\ &= x, \\ x^5 + 1 &= x + 1. \end{align*}

Therefore, x5+1=x+1x^5 + 1 = x + 1 in Z3[x]/⟨x2+1⟩\mathbb{Z}_3[x]/\langle x^2+1\rangle. Notice how x4=1x^4 = 1 means the powers of xx cycle with period 44; this is precisely an order calculation, with xx playing the role of a unit.

Example. Find x5+1x^5 + 1 in Z2[x]/⟨x2+x+1⟩\mathbb{Z}_2[x]/\langle x^2 + x + 1\rangle.
By long division, remembering that in Z2\mathbb{Z}_2 subtracting is the same as adding:

x5+1+x3(x2+x+1)=x4+x3+1,x4+x3+1+x2(x2+x+1)=x2+1,x2+1+1(x2+x+1)=x,\begin{align*} x^5 + 1 + x^3(x^2+x+1) &= x^4 + x^3 + 1, \\ x^4 + x^3 + 1 + x^2(x^2+x+1) &= x^2 + 1, \\ x^2 + 1 + 1(x^2+x+1) &= x, \end{align*}

so the quotient is x3+x2+1x^3 + x^2 + 1 and

x5+1=(x3+x2+1)(x2+x+1)+x.x^5 + 1 = (x^3 + x^2 + 1)(x^2 + x + 1) + x.

Alternatively, use x2=x+1x^2 = x + 1 from the previous section, which gives

x3=x⋅x2=x(x+1)=x2+x=(x+1)+x=1,\begin{align*} x^3 &= x \cdot x^2 \\ &= x(x+1) \\ &= x^2 + x \\ &= (x+1) + x \\ &= 1, \end{align*}

so the powers of xx cycle with period 33 and

x5=x3⋅x2=1⋅(x+1)=x+1,x5+1=x+1+1=x.\begin{align*} x^5 &= x^3 \cdot x^2 \\ &= 1 \cdot (x+1) \\ &= x + 1, \\ x^5 + 1 &= x + 1 + 1 \\ &= x. \end{align*}

Therefore, x5+1=xx^5 + 1 = x in Z2[x]/⟨x2+x+1⟩\mathbb{Z}_2[x]/\langle x^2+x+1\rangle; both routes agree, and the second one took three lines.

Example. Find x100x^{100} in Z2[x]/⟨x2+x+1⟩\mathbb{Z}_2[x]/\langle x^2+x+1\rangle, and find x10+x7x^{10} + x^7 in Z3[x]/⟨x2+1⟩\mathbb{Z}_3[x]/\langle x^2+1\rangle.
Nobody is doing these by long division. From the previous examples, x3=1x^3 = 1 in the first system and x4=1x^4 = 1 in the second, so in each case we reduce the exponent modulo that period:

100=3×33+1,x100=(x3)33⋅x=x in Z2[x]/⟨x2+x+1⟩.\begin{align*} 100 &= 3 \times 33 + 1, \\ x^{100} &= (x^3)^{33} \cdot x \\ &= x \text{ in } \mathbb{Z}_2[x]/\langle x^2+x+1\rangle. \end{align*}

For the second, 10=4×2+210 = 4 \times 2 + 2 and 7=4×1+37 = 4 \times 1 + 3, so

x10=(x4)2⋅x2=x2=−1=2,x7=(x4)⋅x3=x⋅x2=−x=2x,x10+x7=2x+2 in Z3[x]/⟨x2+1⟩.\begin{align*} x^{10} &= (x^4)^2 \cdot x^2 \\ &= x^2 = -1 = 2, \\ x^7 &= (x^4) \cdot x^3 \\ &= x \cdot x^2 = -x = 2x, \\ x^{10} + x^7 &= 2x + 2 \text{ in } \mathbb{Z}_3[x]/\langle x^2+1\rangle. \end{align*}

Therefore, x100=xx^{100} = x and x10+x7=2x+2x^{10} + x^7 = 2x + 2. Reduce the exponent modulo the period of xx, never modulo the degree of m(x)m(x); the degree tells you how big the remainders are allowed to be, not how the powers repeat.

Solving Linear Congruences with Polynomial Moduli#

Now for the polynomial version of Linear Congruences and Diophantine Equations. Given f(x),g(x),m(x)∈F[x]f(x), g(x), m(x) \in F[x], we want to solve the general linear congruence

f(x)a(x)≡g(x)(modm(x))f(x)a(x) \equiv g(x) \pmod{m(x)}

for the unknown polynomial a(x)a(x). Compare this with ax≡c(modn)ax \equiv c \pmod n: the method is word-for-word the same, with gcd⁡\gcd of polynomials (from the polynomial Euclidean algorithm in Polynomial Rings) replacing gcd⁡\gcd of integers.

  • Find d(x)=gcd⁡(f(x),m(x))d(x) = \gcd(f(x), m(x)). If d(x)∤g(x)d(x) \nmid g(x), there is no solution; stop.
  • Find polynomials p(x),q(x)∈F[x]p(x), q(x) \in F[x] such that d(x)=f(x)p(x)+m(x)q(x)d(x) = f(x)p(x) + m(x)q(x), e.g. via the Euclidean algorithm and working backwards.
  • The general solution is then

a(x)≡g(x)d(x) p(x) ⁣ ⁣(modm(x)d(x)).\boxed{a(x) \equiv \frac{g(x)}{d(x)} \, p(x) \!\!\pmod{\frac{m(x)}{d(x)}}.}

Basically, p(x)p(x) is playing the role of an inverse: the Bézout identity says f(x)p(x)≡d(x)(modm(x))f(x)p(x) \equiv d(x) \pmod{m(x)}, so multiplying the congruence through by p(x)p(x) converts the left-hand side from f(x)a(x)f(x)a(x) into d(x)a(x)d(x)a(x), and then everything divides by d(x)d(x). The divisibility condition d(x)∣g(x)d(x) \mid g(x) appears for exactly the same reason as d∣cd \mid c did for integers; the reachable values of f(x)a(x)+m(x)b(x)f(x)a(x) + m(x)b(x) are precisely the multiples of the gcd.

The modulus shrinks from m(x)m(x) to m(x)d(x)\frac{m(x)}{d(x)}, and forgetting this is the classic mistake. In the integer case a single class mod nd\frac{n}{d} split into dd separate classes mod nn; here a single class mod m(x)d(x)\frac{m(x)}{d(x)} splits into ∣F∣deg⁡d|F|^{\deg d} separate classes mod m(x)m(x), by the count of elements in the quotient when FF is finite. If a question asks for the answer modulo the original m(x)m(x), you have to list all of them by repeatedly adding m(x)d(x)\frac{m(x)}{d(x)}.

In Z2[x]\mathbb{Z}_2[x], subtraction is identical to addition, because −1=1-1 = 1; so signs never matter and you may freely replace every minus with a plus. This is a genuine convenience when back-substituting through the Euclidean algorithm (no sign bookkeeping at all), but it is also the single most common source of confusion in this topic, because the same manipulation in Z3[x]\mathbb{Z}_3[x] or Q[x]\mathbb{Q}[x] absolutely does need its signs. Always know which field you are in before you start cancelling.

Example. Solve (x3+x2+1)a(x)≡x2(modx4+1)(x^3 + x^2 + 1)a(x) \equiv x^2 \pmod{x^4 + 1} in Z2[x]\mathbb{Z}_2[x].
First run the Euclidean algorithm on m(x)=x4+1m(x) = x^4 + 1 and f(x)=x3+x2+1f(x) = x^3 + x^2 + 1. Dividing,

x4+1=(x+1)(x3+x2+1)+(x2+x),x3+x2+1=x(x2+x)+1,x2+x=(x2+x)(1)+0,\begin{align*} x^4 + 1 &= (x + 1)(x^3 + x^2 + 1) + (x^2 + x), \\ x^3 + x^2 + 1 &= x(x^2 + x) + 1, \\ x^2 + x &= (x^2 + x)(1) + 0, \end{align*}

so the last nonzero remainder is d(x)=1d(x) = 1. (It is worth checking the first line: (x+1)(x3+x2+1)=x4+x3+x+x3+x2+1=x4+x2+x+1(x+1)(x^3+x^2+1) = x^4 + x^3 + x + x^3 + x^2 + 1 = x^4 + x^2 + x + 1, and adding x2+xx^2 + x gives x4+1x^4+1 as required.) Since 11 divides everything, a solution exists.

Now work backwards from the second line to build the Bézout identity:

1=(x3+x2+1)+x(x2+x)=(x3+x2+1)+x[(x4+1)+(x+1)(x3+x2+1)]=(x3+x2+1)[1+x(x+1)]+x(x4+1)=(x3+x2+1)(x2+x+1)+x(x4+1),\begin{align*} 1 &= (x^3 + x^2 + 1) + x(x^2 + x) \\ &= (x^3 + x^2 + 1) + x\big[(x^4+1) + (x+1)(x^3+x^2+1)\big] \\ &= (x^3+x^2+1)\big[1 + x(x+1)\big] + x(x^4+1) \\ &= (x^3+x^2+1)(x^2+x+1) + x(x^4+1), \end{align*}

so p(x)=x2+x+1p(x) = x^2 + x + 1 and q(x)=xq(x) = x. As a check,

(x3+x2+1)(x2+x+1)=x5+x4+x3+x4+x3+x2+x2+x+1=x5+x+1,\begin{align*} (x^3+x^2+1)(x^2+x+1) &= x^5 + x^4 + x^3 + x^4 + x^3 + x^2 + x^2 + x + 1 \\ &= x^5 + x + 1, \end{align*}

and adding x(x4+1)=x5+xx(x^4+1) = x^5 + x leaves exactly 11. ✓\checkmark

Since d(x)=1d(x) = 1, neither the right-hand side nor the modulus shrinks, and the general solution is

a(x)≡x2(x2+x+1)(modx4+1)≡x4+x3+x2(modx4+1)≡1+x3+x2(modx4+1),\begin{align*} a(x) &\equiv x^2(x^2 + x + 1) \pmod{x^4+1} \\ &\equiv x^4 + x^3 + x^2 \pmod{x^4+1} \\ &\equiv 1 + x^3 + x^2 \pmod{x^4+1}, \end{align*}

using x4=−1=1x^4 = -1 = 1 in Z2[x]/⟨x4+1⟩\mathbb{Z}_2[x]/\langle x^4+1\rangle. Checking the answer by multiplying out, and using the fact that squaring in Z2[x]\mathbb{Z}_2[x] kills all the cross terms,

(x3+x2+1)(x3+x2+1)=x6+x4+1=x2(x4)+x4+1=x2+1+1=x2 in Z2[x]/⟨x4+1⟩.✓\begin{align*} (x^3+x^2+1)(x^3+x^2+1) &= x^6 + x^4 + 1 \\ &= x^2(x^4) + x^4 + 1 \\ &= x^2 + 1 + 1 \\ &= x^2 \text{ in } \mathbb{Z}_2[x]/\langle x^4+1\rangle. \checkmark \end{align*}

Therefore, the solution is a(x)≡x3+x2+1(modx4+1)a(x) \equiv x^3 + x^2 + 1 \pmod{x^4 + 1}. Amusingly the answer is f(x)f(x) itself, i.e. f(x)f(x) happens to be its own "square root of x2x^2" here; that is a coincidence of this example, not a general phenomenon.

Example. In Z2[x]\mathbb{Z}_2[x], solve (a) (x2+1)a(x)≡x(modx3+1)(x^2+1)a(x) \equiv x \pmod{x^3+1}, and (b) (x2+1)a(x)≡x2+x(modx3+1)(x^2+1)a(x) \equiv x^2 + x \pmod{x^3+1}.
Both parts need the same gcd, so compute it once. In Z2[x]\mathbb{Z}_2[x],

x3+1=x(x2+1)+(x+1),x2+1=(x+1)(x+1)+0,\begin{align*} x^3 + 1 &= x(x^2+1) + (x+1), \\ x^2 + 1 &= (x+1)(x+1) + 0, \end{align*}

so d(x)=x+1d(x) = x + 1. (Both lines are just the factorisations x3+1=(x+1)(x2+x+1)x^3+1 = (x+1)(x^2+x+1) and x2+1=(x+1)2x^2+1 = (x+1)^2 in disguise.)
(a) Does x+1x + 1 divide g(x)=xg(x) = x? By the Remainder Theorem the remainder is the value at x=1x = 1, namely 1≠01 \neq 0; so no. Therefore, part (a) has no solutions.
(b) Here g(x)=x2+x=x(x+1)g(x) = x^2 + x = x(x+1), which is divisible by x+1x+1, so solutions exist. From the first division line,

x+1=(x3+1)+x(x2+1),x + 1 = (x^3+1) + x(x^2+1),

giving p(x)=xp(x) = x. Dividing the pieces by d(x)=x+1d(x) = x+1,

g(x)d(x)=x2+xx+1=x,m(x)d(x)=x3+1x+1=x2+x+1,\begin{align*} \frac{g(x)}{d(x)} &= \frac{x^2+x}{x+1} = x, \\ \frac{m(x)}{d(x)} &= \frac{x^3+1}{x+1} = x^2+x+1, \end{align*}

so the general solution is

a(x)≡x⋅x(modx2+x+1)≡x2(modx2+x+1)≡x+1(modx2+x+1),\begin{align*} a(x) &\equiv x \cdot x \pmod{x^2+x+1} \\ &\equiv x^2 \pmod{x^2+x+1} \\ &\equiv x + 1 \pmod{x^2+x+1}, \end{align*}

using x2=x+1x^2 = x+1 in Z2[x]/⟨x2+x+1⟩\mathbb{Z}_2[x]/\langle x^2+x+1\rangle as before. Checking with a(x)=x+1a(x) = x+1,

(x2+1)(x+1)=x3+x2+x+1=1+x2+x+1=x2+x in Z2[x]/⟨x3+1⟩,✓\begin{align*} (x^2+1)(x+1) &= x^3 + x^2 + x + 1 \\ &= 1 + x^2 + x + 1 \\ &= x^2 + x \text{ in } \mathbb{Z}_2[x]/\langle x^3+1\rangle, \checkmark \end{align*}

since x3=−1=1x^3 = -1 = 1. Therefore, the solution to (b) is a(x)≡x+1(modx2+x+1)a(x) \equiv x+1 \pmod{x^2+x+1}. Notice the modulus really did shrink, from degree 33 down to degree 22; modulo the original x3+1x^3+1 there are ∣F∣deg⁡d=21=2|F|^{\deg d} = 2^1 = 2 solutions, namely a(x)=x+1a(x) = x+1 and a(x)=(x+1)+(x2+x+1)=x2a(x) = (x+1) + (x^2+x+1) = x^2, and indeed (x2+1)x2=x4+x2=x+x2(x^2+1)x^2 = x^4 + x^2 = x + x^2 in Z2[x]/⟨x3+1⟩\mathbb{Z}_2[x]/\langle x^3+1\rangle as well.

Example. Solve (x2+1)a(x)≡x+2(modx3+2x+1)(x^2+1)a(x) \equiv x + 2 \pmod{x^3 + 2x + 1} in Z3[x]\mathbb{Z}_3[x].
This one is over Z3\mathbb{Z}_3, so signs matter again; recall −1=2-1 = 2 and −2=1-2 = 1 in Z3\mathbb{Z}_3. Running the Euclidean algorithm,

x3+2x+1=x(x2+1)+(x+1),x2+1=(x+2)(x+1)+2,x+1=(2x+2)(2)+0,\begin{align*} x^3 + 2x + 1 &= x(x^2+1) + (x + 1), \\ x^2 + 1 &= (x + 2)(x+1) + 2, \\ x + 1 &= (2x+2)(2) + 0, \end{align*}

where the middle line uses (x+2)(x+1)=x2+3x+2=x2+2(x+2)(x+1) = x^2 + 3x + 2 = x^2 + 2, so the remainder is (x2+1)−(x2+2)=−1=2(x^2+1) - (x^2+2) = -1 = 2. The last nonzero remainder is the constant 22, whose monic form is 11; so d(x)=1d(x) = 1 and a solution exists.

Working backwards,

2=(x2+1)−(x+2)(x+1)=(x2+1)−(x+2)[(x3+2x+1)−x(x2+1)]=(x2+1)[1+x(x+2)]−(x+2)(x3+2x+1)=(x2+1)(x2+2x+1)−(x+2)(x3+2x+1).\begin{align*} 2 &= (x^2+1) - (x+2)(x+1) \\ &= (x^2+1) - (x+2)\big[(x^3+2x+1) - x(x^2+1)\big] \\ &= (x^2+1)\big[1 + x(x+2)\big] - (x+2)(x^3+2x+1) \\ &= (x^2+1)(x^2+2x+1) - (x+2)(x^3+2x+1). \end{align*}

Multiplying through by 2−1=22^{-1} = 2 in Z3\mathbb{Z}_3 to make the gcd monic,

1=(x2+1)(2x2+4x+2)−(2x+4)(x3+2x+1)=(x2+1)(2x2+x+2)+(x+2)(x3+2x+1),\begin{align*} 1 &= (x^2+1)(2x^2+4x+2) - (2x+4)(x^3+2x+1) \\ &= (x^2+1)(2x^2+x+2) + (x+2)(x^3+2x+1), \end{align*}

so p(x)=2x2+x+2p(x) = 2x^2 + x + 2. Since d(x)=1d(x) = 1, the general solution is a(x)≡g(x)p(x)a(x) \equiv g(x)p(x) modulo m(x)m(x):

a(x)≡(x+2)(2x2+x+2)(modx3+2x+1)≡2x3+x2+2x+4x2+2x+4(modx3+2x+1)≡2x3+2x2+x+1(modx3+2x+1).\begin{align*} a(x) &\equiv (x+2)(2x^2+x+2) \pmod{x^3+2x+1} \\ &\equiv 2x^3 + x^2 + 2x + 4x^2 + 2x + 4 \pmod{x^3+2x+1} \\ &\equiv 2x^3 + 2x^2 + x + 1 \pmod{x^3+2x+1}. \end{align*}

Now x3≡−2x−1=x+2x^3 \equiv -2x - 1 = x + 2, so 2x3≡2x+4=2x+12x^3 \equiv 2x + 4 = 2x + 1, giving

a(x)≡(2x+1)+2x2+x+1≡2x2+3x+2≡2x2+2(modx3+2x+1).\begin{align*} a(x) &\equiv (2x + 1) + 2x^2 + x + 1 \\ &\equiv 2x^2 + 3x + 2 \\ &\equiv 2x^2 + 2 \pmod{x^3+2x+1}. \end{align*}

Checking: with x3≡x+2x^3 \equiv x+2 we get x4≡x2+2xx^4 \equiv x^2 + 2x, so

(x2+1)(2x2+2)=2x4+4x2+2=2x4+x2+2≡2(x2+2x)+x2+2=3x2+4x+2=x+2.✓\begin{align*} (x^2+1)(2x^2+2) &= 2x^4 + 4x^2 + 2 \\ &= 2x^4 + x^2 + 2 \\ &\equiv 2(x^2+2x) + x^2 + 2 \\ &= 3x^2 + 4x + 2 \\ &= x + 2. \checkmark \end{align*}

Therefore, the solution is a(x)≡2x2+2(modx3+2x+1)a(x) \equiv 2x^2 + 2 \pmod{x^3 + 2x + 1}.

The Chinese Remainder Theorem for Polynomials#

Everything from Simultaneous Congruences and the CRT carries over as well, with the same pairwise-coprime hypothesis and the same uniqueness statement.

Note

Theorem 7.12 (Chinese Remainder Theorem)
Suppose that f(x),gi(x),mi(x)∈F[x]f(x), g_i(x), m_i(x) \in F[x], and that for the system of congruences

f(x)≡g1(x)(modm1(x)),f(x)≡g2(x)(modm2(x)),  ⋮f(x)≡gt(x)(modmt(x)),\begin{align*} f(x) &\equiv g_1(x) \pmod{m_1(x)}, \\ f(x) &\equiv g_2(x) \pmod{m_2(x)}, \\ &\ \ \vdots \\ f(x) &\equiv g_t(x) \pmod{m_t(x)}, \end{align*}

all the moduli are pairwise coprime (that is, gcd⁡(mi(x),mj(x))=1\gcd(m_i(x), m_j(x)) = 1 for all i≠ji \neq j). Then the system of congruences has a solution, and the solution is unique modulo m1(x)m2(x)⋯mt(x)m_1(x)m_2(x)\cdots m_t(x).

The proof is analogous to the integer case from Simultaneous Congruences and the CRT, so the lecture only sketches it; the substitution argument below is constructive anyway, which is really all we need in practice.

Pairwise coprime means coprime in pairs, not "no factor common to all of them". Exactly as with integers, gcd⁡(m1,m2,m3)=1\gcd(m_1, m_2, m_3) = 1 is not enough; you must check every pair separately. Notice also that "coprime" here means the gcd is the constant polynomial 11, i.e. the two moduli share no common factor of degree ≥1\geq 1.

To solve a system, we use the same substitution method as in the integer case:

  • Solve the first congruence and write f(x)f(x) in terms of some polynomial k1(x)∈F[x]k_1(x) \in F[x].
  • Substitute this into the second congruence and solve for k1(x)k_1(x) in terms of some new polynomial k2(x)∈F[x]k_2(x) \in F[x].
  • Rewrite f(x)f(x) in terms of k2(x)k_2(x), substitute into the third congruence, and so on.
  • The final expression for f(x)f(x), with kt(x)k_t(x) ranging over all of F[x]F[x], describes every solution.

Basically, each congruence narrows the family of possible f(x)f(x) down further, and the parameter ki(x)k_i(x) keeps track of whatever freedom is left. Since the final answer is unique modulo the product of the moduli, the degree of the product is a free sanity check: the reduced answer must have degree less than deg⁡(m1)+⋯+deg⁡(mt)\deg(m_1) + \cdots + \deg(m_t).

Example. Solve the following system of polynomial congruences in Z2[x]\mathbb{Z}_2[x]:

f(x)≡x+1(modx2+x+1),f(x)≡x(modx3).\begin{align*} f(x) &\equiv x + 1 \pmod{x^2+x+1}, \\ f(x) &\equiv x \pmod{x^3}. \end{align*}

First check the hypothesis: x2+x+1x^2+x+1 has constant term 11, so it is not divisible by xx, and the only factor of x3x^3 of positive degree is xx; hence gcd⁡(x2+x+1,x3)=1\gcd(x^2+x+1, x^3) = 1 and the CRT applies. The answer will be unique modulo

x3(x2+x+1)=x5+x4+x3.x^3(x^2+x+1) = x^5 + x^4 + x^3.

From the first congruence,

f(x)=x+1+(x2+x+1)k(x),k(x)∈Z2[x].f(x) = x + 1 + (x^2+x+1)k(x), \quad k(x) \in \mathbb{Z}_2[x].

Substituting this into the second congruence,

x+1+(x2+x+1)k(x)≡x(modx3)(x2+x+1)k(x)≡x−x−1(modx3)(x2+x+1)k(x)≡1(modx3),\begin{align*} x + 1 + (x^2+x+1)k(x) &\equiv x \pmod{x^3} \\ (x^2+x+1)k(x) &\equiv x - x - 1 \pmod{x^3} \\ (x^2+x+1)k(x) &\equiv 1 \pmod{x^3}, \end{align*}

using −1=1-1 = 1 in Z2\mathbb{Z}_2. So k(x)k(x) must be the inverse of x2+x+1x^2+x+1 modulo x3x^3; and the gcd is 11, so an inverse exists. Rather than run the full Euclidean algorithm, notice that

(x2+x+1)(x+1)=x3+x2+x+x2+x+1=x3+1≡1(modx3),\begin{align*} (x^2+x+1)(x+1) &= x^3 + x^2 + x + x^2 + x + 1 \\ &= x^3 + 1 \\ &\equiv 1 \pmod{x^3}, \end{align*}

so the inverse is x+1x+1 and

k(x)=x+1+x3t(x),t(x)∈Z2[x].k(x) = x + 1 + x^3 t(x), \quad t(x) \in \mathbb{Z}_2[x].

Substituting back,

f(x)=x+1+(x2+x+1)[x+1+x3t(x)]=x+1+(x3+1)+x3(x2+x+1)t(x)=x3+x+(x5+x4+x3)t(x).\begin{align*} f(x) &= x + 1 + (x^2+x+1)\big[x + 1 + x^3t(x)\big] \\ &= x + 1 + (x^3 + 1) + x^3(x^2+x+1)t(x) \\ &= x^3 + x + (x^5+x^4+x^3)t(x). \end{align*}

Checking both congruences with f(x)=x3+xf(x) = x^3 + x: modulo x3x^3 we have x3≡0x^3 \equiv 0, so f(x)≡xf(x) \equiv x; and modulo x2+x+1x^2+x+1 we showed earlier that x3=1x^3 = 1, so f(x)≡1+x=x+1f(x) \equiv 1 + x = x+1. Both hold. ✓\checkmark Therefore, the general solution is

f(x)≡x3+x(modx5+x4+x3),f(x) \equiv x^3 + x \pmod{x^5 + x^4 + x^3},

and its degree 33 is comfortably below 55, as the uniqueness statement requires.

Example. Solve f(x)≡1(modx+1)f(x) \equiv 1 \pmod{x+1} and f(x)≡x(modx2+1)f(x) \equiv x \pmod{x^2+1} in Z3[x]\mathbb{Z}_3[x].
Coprimality first: by the Remainder Theorem, x+1x+1 divides x2+1x^2+1 only if (−1)2+1=2(-1)^2 + 1 = 2 were 00 in Z3\mathbb{Z}_3, which it is not; so the moduli are coprime and the answer is unique modulo

(x+1)(x2+1)=x3+x2+x+1.(x+1)(x^2+1) = x^3 + x^2 + x + 1.

From the first congruence, f(x)=1+(x+1)k(x)f(x) = 1 + (x+1)k(x). Substituting into the second,

1+(x+1)k(x)≡x(modx2+1)(x+1)k(x)≡x−1(modx2+1).\begin{align*} 1 + (x+1)k(x) &\equiv x \pmod{x^2+1} \\ (x+1)k(x) &\equiv x - 1 \pmod{x^2+1}. \end{align*}

We need the inverse of x+1x+1 modulo x2+1x^2+1. Using x2≡−1x^2 \equiv -1,

(x+1)(x−1)=x2−1≡−1−1=−2=1 in Z3,\begin{align*} (x+1)(x-1) &= x^2 - 1 \\ &\equiv -1 - 1 \\ &= -2 \\ &= 1 \text{ in } \mathbb{Z}_3, \end{align*}

so (x+1)−1=x−1=x+2(x+1)^{-1} = x - 1 = x+2. Multiplying through,

k(x)≡(x−1)(x−1)(modx2+1)≡x2−2x+1(modx2+1)≡−1−2x+1(modx2+1)≡x(modx2+1),\begin{align*} k(x) &\equiv (x-1)(x-1) \pmod{x^2+1} \\ &\equiv x^2 - 2x + 1 \pmod{x^2+1} \\ &\equiv -1 - 2x + 1 \pmod{x^2+1} \\ &\equiv x \pmod{x^2+1}, \end{align*}

since −2=1-2 = 1 in Z3\mathbb{Z}_3. Hence k(x)=x+(x2+1)t(x)k(x) = x + (x^2+1)t(x), and

f(x)=1+(x+1)[x+(x2+1)t(x)]=x2+x+1+(x+1)(x2+1)t(x).\begin{align*} f(x) &= 1 + (x+1)\big[x + (x^2+1)t(x)\big] \\ &= x^2 + x + 1 + (x+1)(x^2+1)t(x). \end{align*}

Checking: at x=−1x = -1 we get f(−1)=1−1+1=1f(-1) = 1 - 1 + 1 = 1, so f(x)≡1(modx+1)f(x) \equiv 1 \pmod{x+1}; and modulo x2+1x^2+1 we have x2≡−1x^2 \equiv -1, so f(x)≡−1+x+1=xf(x) \equiv -1 + x + 1 = x. Both hold. ✓\checkmark Therefore,

f(x)≡x2+x+1(modx3+x2+x+1).f(x) \equiv x^2 + x + 1 \pmod{x^3+x^2+x+1}.

So the whole of Topics 3 and 4 transfers across intact: remainders, congruence classes, a finite quotient system, linear congruences solved by Bézout, and simultaneous congruences solved by substitution. The only things you have to keep watch over are which field the coefficients live in (because −1=1-1 = 1 in Z2\mathbb{Z}_2 but not in Z3\mathbb{Z}_3), and the fact that "size" now means degree; once those two habits are in place, every method here is one you have already used on integers.