MATH2400 4,114 words·21 min read

Polynomial Rings

Polynomials Over a Ring#

Everything in this topic is a re-run of Topic 1. Back in Divisibility and Primes we said what it means for one integer to divide another and isolated the primes as the multiplicative atoms; in GCDs and the Euclidean Algorithm we built the gcd and computed it by repeated division; in Bezouts Identity and the Extended Euclidean Algorithm we wrote the gcd as a combination ax+byax + by. We are now going to do the identical sequence with polynomials in place of integers, and almost every proof carries over word for word. The only new ingredient is that we get to choose which ring the coefficients live in, and that choice changes the answers dramatically.

Note

Definition 7.1
Given any (commutative unital) ring RR, a polynomial over RR of degree nn for any n∈Nn \in \mathbb{N} is a function p:R→Rp : R \to R given by

p(x)=∑i=0naixi=a0+a1x+a2x2+⋯+anxnfor all x∈R,p(x) = \sum_{i=0}^{n} a_i x^i = a_0 + a_1x + a_2x^2 + \cdots + a_nx^n \quad \text{for all } x \in R,

where a0,a1,…,an∈Ra_0, a_1, \dots, a_n \in R with an≠0a_n \neq 0.

The terms a0,a1,…,ana_0, a_1, \dots, a_n are called coefficients. We call ana_n the leading coefficient of p(x)p(x) and a0a_0 the constant term of p(x)p(x). If the leading coefficient is 11, we call p(x)p(x) a monic polynomial.

Note

Notation
The degree of a polynomial p(x)p(x), written deg⁡(p(x))\deg(p(x)) or sometimes deg⁡(p)\deg(p), is the largest power of xx appearing in p(x)p(x). In the definition above, deg⁡(p(x))=n\deg(p(x)) = n.

Basically, a polynomial over RR is the usual thing you have written since high school, except that the coefficients are elements of RR rather than real numbers, and so they add and multiply according to RR's rules. Recall from Rings and Fields that "ring" in this course always means commutative unital ring; so RR has a 00, a 11, and addition, subtraction and multiplication all behave.

The condition an≠0a_n \neq 0 in the definition is doing real work: it is what makes the degree well defined. You are allowed to write 0x5+3x2+10x^5 + 3x^2 + 1, but the degree is 22, not 55, because the honest leading coefficient is the last nonzero one.

Example. For each polynomial, state the degree, the leading coefficient and the constant term, and say whether it is monic.
(a) f(x)=5x3−x2+7f(x) = 5x^3 - x^2 + 7 in Z[x]\mathbb{Z}[x].
(b) g(x)=x4+2xg(x) = x^4 + 2x in Q[x]\mathbb{Q}[x].
(c) h(x)=3h(x) = 3 in Z7[x]\mathbb{Z}_7[x].
(d) k(x)=3x2+x+1k(x) = 3x^2 + x + 1 in Z3[x]\mathbb{Z}_3[x].
(a) deg⁡(f)=3\deg(f) = 3, leading coefficient 55, constant term 77; not monic since 5≠15 \neq 1.
(b) deg⁡(g)=4\deg(g) = 4, leading coefficient 11, constant term 00; monic.
(c) deg⁡(h)=0\deg(h) = 0, leading coefficient 33, constant term 33; not monic. Constants are perfectly good polynomials, of degree 00.
(d) This is the trap. In Z3\mathbb{Z}_3 we have 3=03 = 0, so

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

giving deg⁡(k)=1\deg(k) = 1, leading coefficient 11, constant term 11; and it is monic. Therefore, always reduce every coefficient into the ring before reading off the degree; a coefficient that looks nonzero on the page may be 00 in RR.

Note

Definition 7.2
The zero polynomial is the function z:R→Rz : R \to R given by z(x)=0z(x) = 0 for all x∈Rx \in R (where 00 is the additive identity in RR). The degree of the zero polynomial is undefined, but for our purposes we will treat its degree as −∞-\infty.

The zero polynomial is the one polynomial with no nonzero coefficient at all, so Definition 7.1 simply does not apply to it and its degree is genuinely undefined. Setting deg⁡(0)=−∞\deg(0) = -\infty is a convention, not a theorem, but it is a convention that buys us two things:

  • The rule deg⁡(fg)=deg⁡(f)+deg⁡(g)\deg(fg) = \deg(f) + \deg(g) keeps working, since −∞+n=−∞-\infty + n = -\infty and 0⋅f=00 \cdot f = 0.
  • The rule deg⁡(f+g)≤max⁡(deg⁡f,deg⁡g)\deg(f + g) \leq \max(\deg f, \deg g) keeps working when the two polynomials cancel entirely.
  • The Division Theorem below can demand deg⁡(r)<deg⁡(g)\deg(r) < \deg(g) without having to add "or r=0r = 0" as a separate case, since −∞-\infty is less than everything.

Basically, −∞-\infty is chosen precisely so that every statement we want to make about degrees has no annoying exceptions.

The Ring of Polynomials#

Having built polynomials out of a ring, the natural question is whether the collection of them is a ring in its own right; and it is, which is why the whole of Topic 1 will transfer.

Note

Notation
The set of all polynomials over a ring RR is denoted R[x]R[x].

Note

Fact
R[x]R[x] is itself a (commutative unital) ring under the usual operations of addition and multiplication.

Proof. The operations are the familiar ones, written out coefficientwise: for f(x)=∑iaixif(x) = \sum_i a_ix^i and g(x)=∑ibixig(x) = \sum_i b_ix^i,

f(x)+g(x)=∑i(ai+bi)xi,f(x)g(x)=∑k(∑i+j=kaibj)xk.\begin{align*} f(x) + g(x) &= \sum_{i} (a_i + b_i)x^i, \\ f(x)g(x) &= \sum_{k} \left( \sum_{i+j=k} a_i b_j \right) x^k. \end{align*}

Every coefficient on the right is built from the aia_i and bib_i using only addition and multiplication in RR, so closure under both operations is inherited straight from closure in RR. In the same way, additive associativity and commutativity hold because they hold for each coefficient separately; and multiplicative associativity, commutativity and distributivity hold because expanding both sides produces the same sums of products aibja_ib_j (or aibjcka_ib_jc_k), which then agree by the corresponding axiom in RR.

That leaves the identities and inverses. The zero polynomial is the additive identity, since adding 00 to each coefficient changes nothing; the additive inverse of ∑iaixi\sum_i a_i x^i is ∑i(−ai)xi\sum_i (-a_i)x^i, which lives in R[x]R[x] because each −ai∈R-a_i \in R; and the constant polynomial 11 is the multiplicative identity, since multiplying by it leaves every coefficient alone. Hence every axiom for a commutative unital ring holds. ■\blacksquare

Notice that multiplicative inverses were never mentioned, and for good reason: R[x]R[x] is essentially never a field, even when RR is. There is no polynomial you can multiply xx by to get 11, for exactly the same degree reason that we are about to make precise. So Q[x]\mathbb{Q}[x] sits alongside Z\mathbb{Z} in the hierarchy from Rings and Fields: a perfectly good ring where you can add, subtract and multiply, but not divide.

Example. Find the sum of x2+2x+3x^2 + 2x + 3 and 3x3−2x+13x^3 - 2x + 1 in Z[x]\mathbb{Z}[x].
Line up like powers and add the coefficients in Z\mathbb{Z}:

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

Therefore, the sum is 3x3+x2+43x^3 + x^2 + 4, of degree 33.

Example. Find the sum of x2+2x+3x^2 + 2x + 3 and 3x3−2x+13x^3 - 2x + 1 in Z3[x]\mathbb{Z}_3[x].
The safest route is to reduce each polynomial mod 33 first, then add:

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

using 3=03 = 0 and −2=1-2 = 1 in Z3\mathbb{Z}_3. Adding,

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

As a check, reducing the Z[x]\mathbb{Z}[x] answer 3x3+x2+43x^3 + x^2 + 4 mod 33 gives x2+1x^2 + 1 as well. Therefore, the sum is x2+1x^2 + 1, of degree 22.

The degree dropped from 33 to 22 purely because of the ring we were working in; 3x33x^3 is a genuine cubic term over Z\mathbb{Z} but is the zero polynomial over Z3\mathbb{Z}_3. This is the single most common slip in this topic. Never quote the degree of a polynomial without saying which R[x]R[x] you are in.

Example. Find the product of x2−x+3x^2 - x + 3 and 2x+12x + 1 in Z[x]\mathbb{Z}[x].
Expanding term by term,

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

Therefore, the product is 2x3−x2+5x+32x^3 - x^2 + 5x + 3, of degree 3=2+13 = 2 + 1, as expected.

Example. Find the product of x2−x+3x^2 - x + 3 and 2x+12x + 1 in Z3[x]\mathbb{Z}_3[x].
Reduce first: x2−x+3=x2+2xx^2 - x + 3 = x^2 + 2x and 2x+12x + 1 is already reduced. Then

(x2+2x)(2x+1)=2x3+x2+4x2+2x=2x3+5x2+2x=2x3+2x2+2x in Z3[x].\begin{align*} (x^2 + 2x)(2x+1) &= 2x^3 + x^2 + 4x^2 + 2x \\ &= 2x^3 + 5x^2 + 2x \\ &= 2x^3 + 2x^2 + 2x \text{ in } \mathbb{Z}_3[x]. \end{align*}

Reducing the Z[x]\mathbb{Z}[x] answer instead gives 2x3−x2+5x+3=2x3+2x2+2x2x^3 - x^2 + 5x + 3 = 2x^3 + 2x^2 + 2x, which agrees. Therefore, the product is 2x3+2x2+2x2x^3 + 2x^2 + 2x. Notice that this time the degree did not drop; Z3\mathbb{Z}_3 is a field, and in a field the product of the two nonzero leading coefficients (11 and 22) can never be 00.

The general degree rules are worth stating explicitly, since we lean on them constantly:

deg⁡(f+g)≤max⁡(deg⁡f,deg⁡g),deg⁡(fg)≤deg⁡(f)+deg⁡(g),\boxed{\deg(f+g) \leq \max(\deg f, \deg g), \qquad \deg(fg) \leq \deg(f) + \deg(g),}

with equality in the second provided RR has no zero divisors (in particular, whenever RR is a field). Recall from Rings and Fields that a zero divisor is a nonzero element whose product with some other nonzero element is 00; if the leading coefficients ama_m and bnb_n satisfy ambn=0a_mb_n = 0, then the xm+nx^{m+n} term of fgfg vanishes and the degree collapses.

Example. Show that deg⁡(fg)<deg⁡(f)+deg⁡(g)\deg(fg) < \deg(f) + \deg(g) can genuinely happen, by multiplying 2x+12x+1 and 3x+13x+1 in Z6[x]\mathbb{Z}_6[x].
Both factors have degree 11, so we would hope for a degree 22 answer. Expanding,

(2x+1)(3x+1)=6x2+2x+3x+1=6x2+5x+1=5x+1 in Z6[x],\begin{align*} (2x+1)(3x+1) &= 6x^2 + 2x + 3x + 1 \\ &= 6x^2 + 5x + 1 \\ &= 5x + 1 \text{ in } \mathbb{Z}_6[x], \end{align*}

since 6=06 = 0 in Z6\mathbb{Z}_6. Therefore, the product has degree 1<1+11 < 1 + 1; the culprit is that 22 and 33 are zero divisors in Z6\mathbb{Z}_6. The clean identity deg⁡(fg)=deg⁡f+deg⁡g\deg(fg) = \deg f + \deg g is a fact about fields (and about Z\mathbb{Z}), not about all rings.

Units of a Polynomial Ring#

Recall from Modular Rings and Units that a unit of a ring is an element with a multiplicative inverse, and that the units are exactly the elements you are allowed to divide by. Since R[x]R[x] is a ring, it has units too, and knowing them is essential — the definition of "irreducible" and the non-uniqueness of gcds both hinge on which polynomials are units.

Note

Definition 7.3
A polynomial p(x)∈R[x]p(x) \in R[x] is called a unit (or invertible) if it has a multiplicative inverse in R[x]R[x].

Note

Notation
The unit group of a polynomial ring R[x]R[x] is the set of all units in R[x]R[x], and is denoted R[x]∗R[x]^*.

Note

Fact
If FF is a field, then F[x]⋆=F⋆F[x]^\star = F^\star.

Proof. (⊇\supseteq) If a∈F∗a \in F^*, then aa is a nonzero constant polynomial and a−1∈F⊆F[x]a^{-1} \in F \subseteq F[x] satisfies a⋅a−1=1a \cdot a^{-1} = 1; so a∈F[x]∗a \in F[x]^*.
(⊆\subseteq) Suppose f(x)∈F[x]∗f(x) \in F[x]^*, so f(x)g(x)=1f(x)g(x) = 1 for some g(x)∈F[x]g(x) \in F[x]. Neither ff nor gg is the zero polynomial (their product is 1≠01 \neq 0), so both have degree at least 00. Since FF is a field it has no zero divisors, so degrees add exactly:

deg⁡(f)+deg⁡(g)=deg⁡(fg)=deg⁡(1)=0.\begin{align*} \deg(f) + \deg(g) &= \deg(fg) \\ &= \deg(1) \\ &= 0. \end{align*}

Two non-negative integers summing to 00 must both be 00, so deg⁡(f)=deg⁡(g)=0\deg(f) = \deg(g) = 0; that is, f=af = a and g=bg = b are constants with ab=1ab = 1 in FF. Hence f=a∈F∗f = a \in F^*. ■\blacksquare

Basically, over a field the only invertible polynomials are the nonzero constants, because multiplying by anything of degree ≥1\geq 1 pushes the degree up and there is no way to push it back down to 00.

Example. Find the following unit groups.
(a) Q[x]∗\mathbb{Q}[x]^*.
(b) Z[x]∗\mathbb{Z}[x]^*.
(c) Z3[x]∗\mathbb{Z}_3[x]^*.
(d) Z4[x]∗\mathbb{Z}_4[x]^*.
(a) Q\mathbb{Q} is a field, so by the fact above, Q[x]∗=Q∗=Q∖{0}\mathbb{Q}[x]^* = \mathbb{Q}^* = \mathbb{Q} \setminus \{0\}; every nonzero rational constant, and nothing else.
(b) Z\mathbb{Z} is not a field, but it has no zero divisors, so the degree argument in the proof still runs verbatim and forces f=af = a, g=bg = b with ab=1ab = 1 in Z\mathbb{Z}. We showed in Rings and Fields that this forces a=±1a = \pm 1. Therefore Z[x]∗=Z∗={1,−1}\mathbb{Z}[x]^* = \mathbb{Z}^* = \{1, -1\}.
(c) Z3\mathbb{Z}_3 is a field (as 33 is prime), so Z3[x]∗=Z3∗={1,2}\mathbb{Z}_3[x]^* = \mathbb{Z}_3^* = \{1, 2\}.
(d) Z4\mathbb{Z}_4 is not a field and it does have a zero divisor, namely 22, since 2×2=4=02 \times 2 = 4 = 0. The degree argument collapses, and the answer is genuinely bigger than Z4∗={1,3}\mathbb{Z}_4^* = \{1,3\}. Watch what happens to 1+2x1 + 2x:

(1+2x)2=1+4x+4x2=1+0x+0x2=1 in Z4[x],\begin{align*} (1+2x)^2 &= 1 + 4x + 4x^2 \\ &= 1 + 0x + 0x^2 \\ &= 1 \text{ in } \mathbb{Z}_4[x], \end{align*}

so 1+2x1 + 2x is its own inverse and is therefore a unit of degree 11. The same trick works with any number of terms: because 22=02^2 = 0 in Z4\mathbb{Z}_4, every product of two of the "22" coefficients dies, and one checks in exactly the same way that

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

Therefore

Z4[x]∗={a0+a1x+⋯+anxn:a0∈{1,3} and a1,…,an∈{0,2}},\mathbb{Z}_4[x]^* = \{a_0 + a_1x + \cdots + a_nx^n : a_0 \in \{1,3\} \text{ and } a_1, \dots, a_n \in \{0, 2\}\},

which is an infinite set, one unit for each finite choice of which higher coefficients are 22.

The condition that FF be a field in F[x]∗=F∗F[x]^* = F^* is not decoration; Z4[x]∗\mathbb{Z}_4[x]^* is strictly bigger than Z4∗\mathbb{Z}_4^* and contains units of every degree. The precise reason is that 22 is nilpotent in Z4\mathbb{Z}_4 (some power of it is 00), and nilpotent coefficients can be attached to any power of xx without breaking invertibility. Contrast this with (a)–(c), where the coefficient ring had no zero divisors at all and the unit group stayed as small as possible.

Divisibility and Irreducible Polynomials#

Now the parallel with Topic 1 begins in earnest. The definition of divisibility is copied straight from Divisibility and Primes with "integer" replaced by "polynomial".

Note

Definition 7.4
Given two polynomials f(x),g(x)∈R[x]f(x), g(x) \in R[x] for some ring RR, we say f(x)f(x) divides g(x)g(x) and write f(x)∣g(x)f(x) \mid g(x) to mean g(x)=f(x)q(x)g(x) = f(x)q(x) for some polynomial q(x)∈R[x]q(x) \in R[x].

Example. Show that (2x+1)∣(2x3−x2+5x+3)(2x+1) \mid (2x^3 - x^2 + 5x + 3) in Z[x]\mathbb{Z}[x], and decide whether 2∣x2 \mid x in Z[x]\mathbb{Z}[x] and in Q[x]\mathbb{Q}[x].
The first one we have already done: from the product example above,

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

and x2−x+3∈Z[x]x^2 - x + 3 \in \mathbb{Z}[x], so (2x+1)∣(2x3−x2+5x+3)(2x+1) \mid (2x^3 - x^2 + 5x + 3) in Z[x]\mathbb{Z}[x].
For the second, we need q(x)q(x) with x=2q(x)x = 2q(x), i.e. q(x)=12xq(x) = \tfrac{1}{2}x. This is not in Z[x]\mathbb{Z}[x], so 2∤x2 \nmid x in Z[x]\mathbb{Z}[x]; but 12x∈Q[x]\tfrac12 x \in \mathbb{Q}[x], so 2∣x2 \mid x in Q[x]\mathbb{Q}[x]. Therefore, divisibility is a statement about the ring, not just about the two polynomials; the same pair can divide in one R[x]R[x] and not in another.

Note

Definition 7.5
An irreducible polynomial in R[x]R[x] is any p(x)∈R[x]p(x) \in R[x] such that

  • p(x)≠0p(x) \neq 0 and p(x)∉R[x]∗p(x) \notin R[x]^*, and
  • whenever p(x)=f(x)g(x)p(x) = f(x)g(x) for polynomials f(x),g(x)∈R[x]f(x), g(x) \in R[x], we must have f(x)∈R[x]∗f(x) \in R[x]^* or g(x)∈R[x]∗g(x) \in R[x]^*.

Basically, an irreducible polynomial is the polynomial version of a prime: it is not zero, not a unit, and cannot be broken into two genuinely smaller pieces. The first bullet is exactly why 11 is not counted as a prime integer, transplanted.

The source note adds the practical version over a field.

Note

Fact
If FF is a field, then p(x)∈F[x]p(x) \in F[x] is irreducible if and only if whenever p(x)=f(x)g(x)p(x) = f(x)g(x) with deg⁡(f(x))≤deg⁡(g(x))\deg(f(x)) \leq \deg(g(x)), we must have deg⁡(f(x))=0\deg(f(x)) = 0 and deg⁡(g(x))>0\deg(g(x)) > 0.

This is just F[x]∗=F∗F[x]^* = F^* rewritten in terms of degrees: over a field, "is a unit" and "has degree 00" say the same thing, so "one factor must be a unit" becomes "one factor must be constant". Basically, over a field a polynomial is irreducible exactly when it cannot be written as a product of two polynomials of strictly smaller degree.

Two immediate consequences that you should just know:

  • Every polynomial of degree 11 over a field is irreducible, since 1=deg⁡f+deg⁡g1 = \deg f + \deg g forces one of the degrees to be 00.
  • A polynomial of degree 22 or 33 over a field is irreducible if and only if it has no root in FF; the only available split is off a linear factor ax+bax + b, and over a field that factor contributes the root −a−1b-a^{-1}b. (This fails from degree 44 onwards, where a polynomial can factorise into two quadratics with no roots at all; see Irreducible Polynomials.)

Example. Determine whether x2+1x^2 + 1 is irreducible in R[x]\mathbb{R}[x], C[x]\mathbb{C}[x], Z5[x]\mathbb{Z}_5[x], Z3[x]\mathbb{Z}_3[x] and Z2[x]\mathbb{Z}_2[x].
It has degree 22 in every one of these, so we hunt for roots.

  • In R[x]\mathbb{R}[x]: a2+1≥1>0a^2 + 1 \geq 1 > 0 for every real aa, so there is no root and x2+1x^2+1 is irreducible.
  • In C[x]\mathbb{C}[x]: x2+1=(x+i)(x−i)x^2 + 1 = (x+i)(x-i), two factors of degree 11; reducible.
  • In Z5[x]\mathbb{Z}_5[x]: testing a=0,1,2,3,4a = 0,1,2,3,4 gives 1,2,0,0,21, 2, 0, 0, 2, so 22 and 33 are roots. Indeed

(x+2)(x+3)=x2+5x+6=x2+1 in Z5[x],\begin{align*} (x+2)(x+3) &= x^2 + 5x + 6 \\ &= x^2 + 1 \text{ in } \mathbb{Z}_5[x], \end{align*}

so it is reducible.

  • In Z3[x]\mathbb{Z}_3[x]: testing a=0,1,2a = 0,1,2 gives 1,2,21, 2, 2, none of which is 00; irreducible.
  • In Z2[x]\mathbb{Z}_2[x]: 12+1=01^2 + 1 = 0, so 11 is a root, and (x+1)2=x2+2x+1=x2+1(x+1)^2 = x^2 + 2x + 1 = x^2 + 1; reducible (in fact a perfect square).
    Therefore, the very same polynomial is irreducible over R\mathbb{R} and Z3\mathbb{Z}_3 but reducible over C\mathbb{C}, Z5\mathbb{Z}_5 and Z2\mathbb{Z}_2. Irreducibility is never a property of a polynomial on its own; it is a property of a polynomial together with its coefficient ring.

Example. Show that 2x+22x + 2 is irreducible in Q[x]\mathbb{Q}[x] but reducible in Z[x]\mathbb{Z}[x].
In Q[x]\mathbb{Q}[x] it has degree 11, so it is irreducible by the first consequence above; concretely, 2x+2=2(x+1)2x+2 = 2(x+1) is a factorisation, but 2∈Q[x]∗2 \in \mathbb{Q}[x]^*, so it does not count. In Z[x]\mathbb{Z}[x] the same factorisation 2x+2=2(x+1)2x + 2 = 2(x+1) is fatal, because Z[x]∗={±1}\mathbb{Z}[x]^* = \{\pm 1\}, so neither 22 nor x+1x+1 is a unit. Therefore 2x+22x+2 is reducible in Z[x]\mathbb{Z}[x]; notice how shrinking the unit group made more polynomials reducible, which is exactly why the clean theory below is stated only over fields.

Note

Theorem 7.6 (Unique Factorisation in F[x]F[x])
If FF is a field, then every polynomial f(x)∈F[x]f(x) \in F[x] with degree greater than 00 has a unique factorisation into irreducible polynomials, up to unit factors. That is, we can write f(x)f(x) uniquely in the form

f(x)=c (p1(x))α1(p2(x))α2(p3(x))α3⋯(pk(x))αk,f(x) = c\,(p_1(x))^{\alpha_1}(p_2(x))^{\alpha_2}(p_3(x))^{\alpha_3} \cdots (p_k(x))^{\alpha_k},

where c∈F∗c \in F^*, each p1(x),p2(x),…,pk(x)p_1(x), p_2(x), \dots, p_k(x) is a different irreducible monic polynomial in F[x]F[x], and α1,α2,…,αk∈Z+\alpha_1, \alpha_2, \dots, \alpha_k \in \mathbb{Z}^+ for some k∈Z+k \in \mathbb{Z}^+.

This is the Fundamental Theorem of Arithmetic from Divisibility and Primes, with irreducible monic polynomials playing the role of the primes and the constant cc playing the role of the sign. The reason we insist the pip_i are monic is the same reason we insist primes are positive: without it, 6=2×3=(−2)×(−3)6 = 2 \times 3 = (-2) \times (-3) would count as two different factorisations, and x2−1=(x−1)(x+1)=(2x−2)(12x+12)x^2 - 1 = (x-1)(x+1) = (2x-2)(\tfrac12 x + \tfrac12) would too. Pulling all the unit "junk" out into a single leading cc makes the factorisation genuinely unique.

Example. Write 2x4−22x^4 - 2 in the form guaranteed by Theorem 7.6, over Q\mathbb{Q} and then over Z5\mathbb{Z}_5.
Over Q\mathbb{Q}, factorise by repeated difference of two squares:

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

and we checked above that x2+1x^2 + 1 is irreducible over Q\mathbb{Q} (it has no real root, let alone a rational one). All three factors are monic irreducibles, so c=2c = 2 and k=3k = 3 with every αi=1\alpha_i = 1.
Over Z5\mathbb{Z}_5, the factor x2+1x^2 + 1 splits further into (x+2)(x+3)(x+2)(x+3), and x−1=x+4x - 1 = x+4, so

2x4−2=2(x+4)(x+1)(x+2)(x+3) in Z5[x],\begin{align*} 2x^4 - 2 &= 2(x+4)(x+1)(x+2)(x+3) \text{ in } \mathbb{Z}_5[x], \end{align*}

now with c=2c = 2 and k=4k = 4. Therefore, the same polynomial has a three-factor factorisation over Q\mathbb{Q} and a four-factor one over Z5\mathbb{Z}_5; enlarging the field can only ever split things further, never fuse them.

The Division Theorem for Polynomials#

Everything computational in Topic 1 came out of the Division Theorem for integers. Here is its exact analogue, with "smaller remainder" measured by degree rather than by size.

Note

Theorem 7.7 (Division Theorem)
For any field FF and polynomials f(x),g(x)∈F[x]f(x), g(x) \in F[x] with g(x)≠0g(x) \neq 0, there exist unique polynomials q(x),r(x)∈F[x]q(x), r(x) \in F[x] such that both

f(x)=q(x)g(x)+r(x)anddeg⁡(r(x))<deg⁡(g(x)).f(x) = q(x)g(x) + r(x) \quad \text{and} \quad \deg(r(x)) < \deg(g(x)).

We call q(x)q(x) the quotient and r(x)r(x) the remainder when f(x)f(x) is divided by g(x)g(x).

Note that the zero polynomial can be a remainder, since its degree is −∞-\infty; this is the payoff of that convention, and it is exactly the case r=0r = 0 that says g∣fg \mid f.

Note

Fact
The Division Theorem is also true over R[x]R[x] for any ring RR, so long as the leading coefficient of g(x)g(x) is a unit of RR.

Proof (sketch). Use strong induction on deg⁡(f)\deg(f). If deg⁡(f)<deg⁡(g)\deg(f) < \deg(g) there is nothing to do; take q(x)=0q(x) = 0 and r(x)=f(x)r(x) = f(x). Otherwise write f(x)=amxm+⋯f(x) = a_mx^m + \cdots and g(x)=bnxn+⋯g(x) = b_nx^n + \cdots with m≥nm \geq n, and kill the leading term of ff by subtracting the right multiple of gg:

f~(x)=f(x)−ambn−1xm−ng(x).\begin{align*} \tilde{f}(x) &= f(x) - a_m b_n^{-1} x^{m-n} g(x). \end{align*}

The xmx^m terms cancel exactly, so deg⁡(f~)<m\deg(\tilde f) < m, and by the inductive hypothesis f~=q~g+r\tilde f = \tilde q g + r with deg⁡(r)<deg⁡(g)\deg(r) < \deg(g). Rearranging gives f=(ambn−1xm−n+q~)g+rf = (a_mb_n^{-1}x^{m-n} + \tilde q)g + r, as required.
For uniqueness, suppose q1g+r1=q2g+r2q_1g + r_1 = q_2g + r_2 with both remainders of degree less than deg⁡(g)\deg(g). Then (q1−q2)g=r2−r1(q_1 - q_2)g = r_2 - r_1; the right-hand side has degree less than deg⁡(g)\deg(g), while the left-hand side has degree deg⁡(q1−q2)+deg⁡(g)≥deg⁡(g)\deg(q_1-q_2) + \deg(g) \geq \deg(g) unless q1−q2=0q_1 - q_2 = 0. So q1=q2q_1 = q_2, and then r1=r2r_1 = r_2.
Notice that the only thing the argument ever needed from FF was the inverse bn−1b_n^{-1} of the leading coefficient of gg; so the whole proof runs unchanged over any ring RR provided that leading coefficient is a unit of RR. ■\blacksquare

You cannot divide by an arbitrary polynomial over a ring that is not a field. For instance, in Z[x]\mathbb{Z}[x] try to divide x2x^2 by 2x+12x+1: the quotient would have to begin with 12x\tfrac12 x, which is not in Z[x]\mathbb{Z}[x], and no choice of integer quotient can leave a remainder of degree 00. Over Q[x]\mathbb{Q}[x] it is fine, and over Z[x]\mathbb{Z}[x] it is fine whenever the divisor is monic, since 11 is a unit in every ring. This is why "monic" is such a load-bearing word in this topic.

To actually find the quotient and remainder we use either long division or balancing coefficients, exactly as with integers.

Example. Find the quotient and remainder when 2x4+3x3+x+52x^4 + 3x^3 + x + 5 is divided by x2+2x−3x^2 + 2x - 3 (in Q[x]\mathbb{Q}[x]).
Write the dividend with every power present, including the missing 0x20x^2, and long divide:

                                  2x^2 -    x +    8
           +-----------------------------------------
x^2+2x-3   | 2x^4 + 3x^3 + 0x^2 +    x +    5
             2x^4 + 4x^3 - 6x^2
             ------------------
                    -x^3 + 6x^2 +    x +    5
                    -x^3 - 2x^2 +   3x
                    ------------------
                           8x^2 -   2x +    5
                           8x^2 +  16x -   24
                           ------------------
                                  -18x +   29

At each stage we divide the current leading term by x2x^2 (the leading term of the divisor), write that down in the quotient, multiply the whole divisor by it, and subtract. The process stops when what is left has degree less than 22. Reading off the answer, q(x)=2x2−x+8q(x) = 2x^2 - x + 8 and r(x)=−18x+29r(x) = -18x + 29. Checking that q(x)g(x)+r(x)=f(x)q(x)g(x) + r(x) = f(x):

(2x2−x+8)(x2+2x−3)=2x4+4x3−6x2−x3−2x2+3x+8x2+16x−24=2x4+3x3+0x2+19x−24,(2x4+3x3+19x−24)+(−18x+29)=2x4+3x3+x+5. ✓\begin{align*} (2x^2 - x + 8)(x^2+2x-3) &= 2x^4 + 4x^3 - 6x^2 - x^3 - 2x^2 + 3x + 8x^2 + 16x - 24 \\ &= 2x^4 + 3x^3 + 0x^2 + 19x - 24, \\ (2x^4 + 3x^3 + 19x - 24) + (-18x + 29) &= 2x^4 + 3x^3 + x + 5. \ \checkmark \end{align*}

Therefore, the quotient is 2x2−x+82x^2 - x + 8 and the remainder is −18x+29-18x + 29. Always do this check; it costs one line and catches every sign error in the long division.

Example. Find the quotient and remainder when x4+2x3+2x^4 + 2x^3 + 2 is divided by x2+1x^2 + 1 in Z3[x]\mathbb{Z}_3[x], by balancing coefficients.
Since deg⁡(f)=4\deg(f) = 4 and deg⁡(g)=2\deg(g) = 2, the quotient has degree 22 and the remainder has degree at most 11; so write

x4+2x3+2=(ax2+bx+c)(x2+1)+(dx+e)=ax4+bx3+(a+c)x2+(b+d)x+(c+e),\begin{align*} x^4 + 2x^3 + 2 &= (ax^2+bx+c)(x^2+1) + (dx+e) \\ &= ax^4 + bx^3 + (a+c)x^2 + (b+d)x + (c+e), \end{align*}

and match coefficients in Z3\mathbb{Z}_3 starting from the top:

a=1,b=2,a+c=0  ⟹  c=−1=2,b+d=0  ⟹  d=−2=1,c+e=2  ⟹  e=2−2=0.\begin{align*} a &= 1, \\ b &= 2, \\ a + c = 0 &\implies c = -1 = 2, \\ b + d = 0 &\implies d = -2 = 1, \\ c + e = 2 &\implies e = 2 - 2 = 0. \end{align*}

Therefore, q(x)=x2+2x+2q(x) = x^2 + 2x + 2 and r(x)=xr(x) = x. Checking,

(x2+2x+2)(x2+1)+x=x4+2x3+2x2+x2+2x+2+x=x4+2x3+3x2+3x+2=x4+2x3+2 in Z3[x]. ✓\begin{align*} (x^2+2x+2)(x^2+1) + x &= x^4 + 2x^3 + 2x^2 + x^2 + 2x + 2 + x \\ &= x^4 + 2x^3 + 3x^2 + 3x + 2 \\ &= x^4 + 2x^3 + 2 \text{ in } \mathbb{Z}_3[x]. \ \checkmark \end{align*}

Balancing coefficients is often faster than long division when the divisor is short and the field is small, because you never have to write out the intermediate subtractions.

Greatest Common Divisors of Polynomials#

With division in hand we can copy the gcd definition across from GCDs and the Euclidean Algorithm. There is one genuine new wrinkle, and it is worth meeting head-on.

Note

Definition 7.8
For any field FF, a greatest common divisor (GCD) of two polynomials f(x),g(x)∈F[x]f(x), g(x) \in F[x] is any polynomial d(x)∈F[x]d(x) \in F[x] such that

  • both d(x)∣f(x)d(x) \mid f(x) and d(x)∣g(x)d(x) \mid g(x), and
  • for all c(x)∈F[x]c(x) \in F[x], if c(x)∣f(x)c(x) \mid f(x) and c(x)∣g(x)c(x) \mid g(x), then c(x)∣d(x)c(x) \mid d(x).

Notice that "greatest" has been replaced by a divisibility condition rather than an inequality; there is no sensible way to say one polynomial is bigger than another, so we say instead that d(x)d(x) is the common divisor that every other common divisor divides into. (For integers these two descriptions agree, which is why you may not have noticed the distinction before.)

The wrinkle is that with this definition there is usually more than one greatest common divisor, because any unit multiple of a GCD is again a GCD.

Example. Find all the GCDs of f(x)=2x2+xf(x) = 2x^2 + x and g(x)=x2+4x+3g(x) = x^2 + 4x + 3 in Z5[x]\mathbb{Z}_5[x].
Factorise each polynomial, remembering that Z5[x]∗=Z5∗={1,2,3,4}\mathbb{Z}_5[x]^* = \mathbb{Z}_5^* = \{1,2,3,4\}, so each factorisation can be rewritten in four ways by moving a unit across:

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

(As a spot check, 2x(x+3)=2x2+6x=2x2+x2x(x+3) = 2x^2 + 6x = 2x^2 + x and (3x+3)(2x+1)=6x2+3x+6x+3=x2+4x+3(3x+3)(2x+1) = 6x^2 + 3x + 6x + 3 = x^2 + 4x + 3 in Z5[x]\mathbb{Z}_5[x].) Comparing the two lists, the common non-constant factors are 2x+12x+1, x+3x+3, 4x+24x+2 and 3x+43x+4; and these four are exactly the unit multiples of one another, since

1(x+3)=x+3,2(x+3)=2x+6=2x+1,3(x+3)=3x+9=3x+4,4(x+3)=4x+12=4x+2 in Z5[x].\begin{align*} 1(x+3) &= x + 3, \\ 2(x+3) &= 2x + 6 = 2x+1, \\ 3(x+3) &= 3x + 9 = 3x+4, \\ 4(x+3) &= 4x + 12 = 4x+2 \text{ in } \mathbb{Z}_5[x]. \end{align*}

Therefore, the GCDs of f(x)f(x) and g(x)g(x) in Z5[x]\mathbb{Z}_5[x] are 2x+12x+1, x+3x+3, 4x+24x+2 and 3x+43x+4; four different answers, all equally valid under Definition 7.8.

That is unusable as a function, so we fix a representative. Exactly one of the four is monic.

Note

Notation
The standard greatest common divisor of two polynomials f(x),g(x)∈F[x]f(x), g(x) \in F[x], denoted gcd⁡(f(x),g(x))\gcd(f(x), g(x)), is the monic GCD of f(x)f(x) and g(x)g(x) (that is, the GCD whose leading coefficient is 11).

For example, in Z5[x]\mathbb{Z}_5[x] we have gcd⁡(2x2+x, x2+4x+3)=x+3\gcd(2x^2+x,\, x^2+4x+3) = x+3.

Basically, "divide by the leading coefficient at the end" is the polynomial version of "take the positive one", which is how we made gcd⁡\gcd single-valued for integers. If your final answer to a gcd question is not monic, you have not finished; multiply through by the inverse of the leading coefficient. By F[x]∗=F∗F[x]^* = F^* this is always possible and never changes which polynomial you have up to units, because the leading coefficient of a nonzero polynomial over a field is always invertible.

The Euclidean Algorithm for Polynomials#

Since the Division Theorem holds and degrees are non-negative integers that strictly decrease, the Euclidean algorithm transfers immediately; the degree of the remainder plays the role that the size of the remainder played for integers, and it cannot decrease forever.

Note

Algorithm 7.9 (Euclidean algorithm)
Given any field FF and polynomials f(x),g(x)∈F[x]f(x), g(x) \in F[x], repeatedly apply the Division Theorem, first to f(x)f(x) and g(x)g(x), then to g(x)g(x) and the previous remainder r0(x)r_0(x), then to r0(x)r_0(x) and the previous remainder r1(x)r_1(x), and so on, terminating when rn+1(x)=0r_{n+1}(x) = 0. Then the previous remainder rn(x)r_n(x) is a GCD of f(x)f(x) and g(x)g(x).

Note that when working over polynomial rings we can always factor out any unit from a remainder before applying the Division Theorem to it. For example, if in Z3[x]\mathbb{Z}_3[x] we find a remainder 2x+12x+1 at one step, we could instead multiply it by 22 to get

2(2x+1)=4x+2=x+2 in Z3[x],2(2x+1) = 4x + 2 = x + 2 \text{ in } \mathbb{Z}_3[x],

and use x+2x+2 as the subject of the next step. This is legitimate because unit multiples have exactly the same divisors, so the set of common divisors never changes. This tip is not optional in practice; scaling each remainder to be monic keeps the fractions under control in Q[x]\mathbb{Q}[x] and is the difference between a two-line computation and a page of thirds and sevenths.

The one thing to remember is that the algorithm delivers a GCD, whichever one happens to fall out of the arithmetic; you then scale it to be monic to get the standard one.

Example. Let f(x)=x4+x2−2x−4f(x) = x^4 + x^2 - 2x - 4 and g(x)=x3+x2+2x+2g(x) = x^3 + x^2 + 2x + 2. Find gcd⁡(f(x),g(x))\gcd(f(x), g(x)) in Q[x]\mathbb{Q}[x].
Divide ff by gg. Since x4÷x3=xx^4 \div x^3 = x,

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

and then −x3÷x3=−1-x^3 \div x^3 = -1, so

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

So the first line of the algorithm is

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

The remainder −2x−2-2x-2 has degree 1<31 < 3, as required. Before continuing, scale it by the unit −12-\tfrac12 to get the monic x+1x+1, and divide gg by that:

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

The remainder is 00, so the algorithm stops and the last nonzero remainder x+1x+1 is a GCD; it is already monic. Therefore, gcd⁡(f(x),g(x))=x+1\gcd(f(x), g(x)) = x+1. As a sanity check, f(−1)=1+1+2−4=0f(-1) = 1 + 1 + 2 - 4 = 0 and g(−1)=−1+1−2+2=0g(-1) = -1+1-2+2 = 0, so x+1x+1 really does divide both.

Example. Find gcd⁡(x3−1,x2−1)\gcd(x^3 - 1, x^2 - 1) in Q[x]\mathbb{Q}[x].
Running the algorithm,

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 the last nonzero remainder is x−1x-1, which is monic. Therefore, gcd⁡(x3−1,x2−1)=x−1\gcd(x^3-1, x^2-1) = x-1. This matches the factorisations x3−1=(x−1)(x2+x+1)x^3 - 1 = (x-1)(x^2+x+1) and x2−1=(x−1)(x+1)x^2 - 1 = (x-1)(x+1), where x2+x+1x^2+x+1 and x+1x+1 share nothing.

Bézout's Identity for Polynomials#

And finally the identity from Bezouts Identity and the Extended Euclidean Algorithm, transplanted.

Note

Theorem 7.10 (Bézout's identity)
Given any field FF and polynomials f(x),g(x)∈F[x]f(x), g(x) \in F[x], there exist polynomials p(x),q(x)∈F[x]p(x), q(x) \in F[x] such that

gcd⁡(f(x),g(x))=f(x)p(x)+g(x)q(x).\gcd(f(x), g(x)) = f(x)p(x) + g(x)q(x).

We can find these polynomials p(x)p(x) and q(x)q(x) the same way as we did before with integers: either by reversing the Euclidean algorithm applied to f(x)f(x) and g(x)g(x), or by using the extended Euclidean algorithm table. The proof is the same as well — run the algorithm, then substitute each remainder upwards until only ff and gg remain.

Example. Let f(x)=x4+x2−2x−4f(x) = x^4 + x^2 - 2x - 4 and g(x)=x3+x2+2x+2g(x) = x^3 + x^2 + 2x + 2. Find p(x),q(x)∈Q[x]p(x), q(x) \in \mathbb{Q}[x] such that gcd⁡(f(x),g(x))=f(x)p(x)+g(x)q(x)\gcd(f(x), g(x)) = f(x)p(x) + g(x)q(x).
We know from the previous section that gcd⁡(f,g)=x+1\gcd(f,g) = x+1, and line (1)(1) of that run is the only line with a nonzero remainder, so there is only one substitution to make. Rearranging (1)(1) for its remainder,

−2x−2=f(x)−(x−1)g(x).(from (1))\begin{align*} -2x-2 &= f(x) - (x-1)g(x). && \text{(from } (1)) \end{align*}

Now multiply through by −12-\tfrac12 to turn the left-hand side into the monic gcd:

x+1=−12(f(x)−(x−1)g(x))=−12f(x)+12(x−1)g(x).\begin{align*} x + 1 &= -\tfrac{1}{2}\left(f(x) - (x-1)g(x)\right) \\ &= -\tfrac{1}{2}f(x) + \tfrac{1}{2}(x-1)g(x). \end{align*}

Therefore, p(x)=−12p(x) = -\tfrac12 and q(x)=x−12q(x) = \tfrac{x-1}{2}. Checking by expanding, and using (x−1)(x3+x2+2x+2)=x4+x2−2(x-1)(x^3+x^2+2x+2) = x^4 + x^2 - 2:

f(x)p(x)+g(x)q(x)=12[−(x4+x2−2x−4)+(x4+x2−2)]=12[2x+2]=x+1. ✓\begin{align*} f(x)p(x) + g(x)q(x) &= \tfrac12\left[-(x^4+x^2-2x-4) + (x^4+x^2-2)\right] \\ &= \tfrac12\left[2x + 2\right] \\ &= x+1. \ \checkmark \end{align*}

Notice that p(x)p(x) is allowed to be a constant, and that constants like −12-\tfrac12 are unavoidable here; the whole point of working over a field is that these fractions are legal. Over Z[x]\mathbb{Z}[x] this identity would be impossible to write down.

The Extended Euclidean Table for Polynomials#

Back-substitution is fine for a one-line run, but it gets ugly fast; the table from Bezouts Identity and the Extended Euclidean Algorithm works verbatim, with polynomials in every cell. The only change is cosmetic: the letters xx and yy are taken (they were the row names before, and xx is now the variable), so we will call the two coefficient rows uiu_i and viv_i, and the invariant becomes

ri(x)=f(x)ui(x)+g(x)vi(x) in every column,\boxed{r_i(x) = f(x)u_i(x) + g(x)v_i(x) \text{ in every column},}

with the same recursions ri=ri−2−qiri−1r_i = r_{i-2} - q_ir_{i-1}, ui=ui−2−qiui−1u_i = u_{i-2} - q_iu_{i-1} and vi=vi−2−qivi−1v_i = v_{i-2} - q_iv_{i-1}, seeded by u:1,0u: 1, 0 and v:0,1v: 0, 1.

Example. Redo the previous example with the extended Euclidean algorithm table.
The table must use the unscaled remainders, so we divide g(x)g(x) by −2x−2-2x-2 rather than by x+1x+1; the quotient there is −12x2−1-\tfrac12x^2 - 1, since

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

with remainder 00. So the quotients are x−1x-1 and −12x2−1-\tfrac12x^2-1, and the table is:

qiq_i x−1x-1 −12x2−1-\frac{1}{2}x^2-1
rir_i x4+x2−2x−4x^4+x^2-2x-4 x3+x2+2x+2x^3+x^2+2x+2 −2x−2-2x-2 00
uiu_i 11 00 11 12x2+1\frac{1}{2}x^2+1
viv_i 00 11 1−x1-x −12x3+12x2−x+2-\frac12x^3+\frac12x^2-x+2

For instance the third column comes from u3=1−(x−1)⋅0=1u_3 = 1 - (x-1)\cdot 0 = 1 and v3=0−(x−1)⋅1=1−xv_3 = 0 - (x-1)\cdot 1 = 1-x. Reading off the second-last column, where rir_i is a GCD,

−2x−2=f(x)⋅1+g(x)(1−x),\begin{align*} -2x-2 &= f(x)\cdot 1 + g(x)(1-x), \end{align*}

and multiplying by −12-\tfrac12 to make it monic gives x+1=−12f(x)+x−12g(x)x+1 = -\tfrac12f(x) + \tfrac{x-1}{2}g(x), exactly as before. Therefore, p(x)=−12p(x) = -\tfrac12 and q(x)=x−12q(x) = \tfrac{x-1}{2}. The table hands you a GCD, not the standard GCD; scaling to monic is always the last step, and you must scale p(x)p(x) and q(x)q(x) by the same unit.

Example. Let f(x)=x4+x2+2f(x) = x^4 + x^2 + 2 and g(x)=x2+2x+2g(x) = x^2 + 2x + 2. Find gcd⁡(f(x),g(x))\gcd(f(x), g(x)) in Z3[x]\mathbb{Z}_3[x], and find some p(x),q(x)∈Z3[x]p(x), q(x) \in \mathbb{Z}_3[x] such that gcd⁡(f(x),g(x))=f(x)p(x)+g(x)q(x)\gcd(f(x),g(x)) = f(x)p(x) + g(x)q(x).
Run the Euclidean algorithm, doing all coefficient arithmetic in Z3\mathbb{Z}_3. Dividing ff by gg: first x4÷x2=x2x^4 \div x^2 = x^2, and

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

then x3÷x2=xx^3 \div x^2 = x, and

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

So the algorithm reads

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

where line (3)(3) uses 2−1=22^{-1} = 2 in Z3\mathbb{Z}_3, since 2(2x+1)=4x+2=x+22(2x+1) = 4x+2 = x+2. The last nonzero remainder is the constant 22, which is a unit; scaling it to be monic gives 11. Therefore, gcd⁡(f(x),g(x))=1\gcd(f(x), g(x)) = 1; the two polynomials are coprime in Z3[x]\mathbb{Z}_3[x].

For the Bézout pair, back-substitute from (2)(2) upwards using (1)(1):

2=g(x)−x(x+2)(from (2))=g(x)−x(f(x)−(x2+x)g(x))(substituting from (1))=−xf(x)+(1+x3+x2)g(x)(collecting terms)=2xf(x)+(x3+x2+1)g(x) in Z3[x].\begin{align*} 2 &= g(x) - x(x+2) && \text{(from } (2))\\ &= g(x) - x\left(f(x) - (x^2+x)g(x)\right) && \text{(substituting from } (1))\\ &= -x f(x) + \left(1 + x^3 + x^2\right)g(x) && \text{(collecting terms)}\\ &= 2x f(x) + \left(x^3+x^2+1\right)g(x) \text{ in } \mathbb{Z}_3[x]. \end{align*}

Finally multiply through by 2−1=22^{-1} = 2 to get the standard (monic) gcd on the left:

1=4xf(x)+2(x3+x2+1)g(x)=xf(x)+(2x3+2x2+2)g(x).\begin{align*} 1 &= 4x f(x) + 2\left(x^3+x^2+1\right)g(x) \\ &= x f(x) + \left(2x^3+2x^2+2\right)g(x). \end{align*}

Therefore, p(x)=xp(x) = x and q(x)=2x3+2x2+2q(x) = 2x^3+2x^2+2. Checking directly,

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

Hmm — that is x+2x+2, not 11; the slip is that the middle expansion dropped a term. Doing it carefully,

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

and now

xf(x)+q(x)g(x)=(x5+x3+2x)+(2x5+2x3+x+1)=3x5+3x3+3x+1=1 in Z3[x]. ✓\begin{align*} x f(x) + q(x)g(x) &= (x^5+x^3+2x) + (2x^5+2x^3+x+1) \\ &= 3x^5 + 3x^3 + 3x + 1 \\ &= 1 \text{ in } \mathbb{Z}_3[x]. \ \checkmark \end{align*}

Expand one factor at a time and reduce mod pp only at the very end; mixing reduction into a half-finished expansion is how terms go missing.

For completeness, here is the same computation as a table, which avoids the substitution entirely. The quotients from lines (1)(1), (2)(2) and (3)(3) are x2+xx^2+x, xx and 2x+12x+1:

qiq_i x2+xx^2+x xx 2x+12x+1
rir_i x4+x2+2x^4+x^2+2 x2+2x+2x^2+2x+2 x+2x+2 22 00
uiu_i 11 00 11 2x2x 2x2+x+12x^2+x+1
viv_i 00 11 2x2+2x2x^2+2x x3+x2+1x^3+x^2+1 x4+x2+2x^4+x^2+2

The fourth column is u4=0−x(1)=−x=2xu_4 = 0 - x(1) = -x = 2x and v4=1−x(2x2+2x)=1−2x3−2x2=x3+x2+1v_4 = 1 - x(2x^2+2x) = 1 - 2x^3 - 2x^2 = x^3+x^2+1, and it reproduces 2=2xf(x)+(x3+x2+1)g(x)2 = 2xf(x) + (x^3+x^2+1)g(x) exactly as the back-substitution did. Scaling by 22 gives the same final answer.

The Integer–Polynomial Dictionary#

Every result in this lecture was Topic 1 with the nouns changed, so it is worth writing the translation down in one place:

In Z\mathbb{Z} In F[x]F[x]
integer polynomial over the field FF
absolute value ∣n∣\lvert n\rvert degree deg⁡(p)\deg(p)
units ±1\pm 1 units $F^* $ (the nonzero constants)
prime irreducible polynomial
n=±p1α1⋯pkαkn = \pm p_1^{\alpha_1}\cdots p_k^{\alpha_k} f=c p1α1⋯pkαkf = c\,p_1^{\alpha_1}\cdots p_k^{\alpha_k} with each pip_i monic irreducible
a=qb+ra = qb + r with 0≤r<∣b∣0 \leq r < \lvert b \rvert f=qg+rf = qg + r with deg⁡(r)<deg⁡(g)\deg(r) < \deg(g)
choose the positive gcd choose the monic gcd
Euclidean algorithm on remainders Euclidean algorithm on remainders
gcd⁡(a,b)=ax+by\gcd(a,b) = ax + by gcd⁡(f,g)=fp+gq\gcd(f,g) = fp + gq

The three places the analogy needs care are all things we have flagged along the way: degrees can collapse if the coefficient ring has zero divisors, so stick to fields; a gcd is only determined up to a unit multiple, so finish by making it monic; and division needs the divisor's leading coefficient to be invertible, so over a non-field ring only monic (or unit-leading) divisors are safe. Get those three right and everything else is muscle memory from Topic 1.