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+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.
Definition 7.1
Given any (commutative unital) ring R, a polynomial over R of degree n for any n∈N is a function p:R→R given by
p(x)=i=0∑naixi=a0+a1x+a2x2+⋯+anxnfor all x∈R,
where a0,a1,…,an∈R with an=0.
The terms a0,a1,…,an are called coefficients. We call an the leading coefficient of p(x) and a0 the constant term of p(x). If the leading coefficient is 1, we call p(x) a monic polynomial.
Notation
The degree of a polynomial p(x), written deg(p(x)) or sometimes deg(p), is the largest power of x appearing in p(x). In the definition above, deg(p(x))=n.
Basically, a polynomial over R is the usual thing you have written since high school, except that the coefficients are elements of R rather than real numbers, and so they add and multiply according to R's rules. Recall from Rings and Fields that "ring" in this course always means commutative unital ring; so R has a 0, a 1, and addition, subtraction and multiplication all behave.
The condition an=0 in the definition is doing real work: it is what makes the degree well defined. You are allowed to write0x5+3x2+1, but the degree is 2, not 5, 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+7 in Z[x].
(b) g(x)=x4+2x in Q[x].
(c) h(x)=3 in Z7[x].
(d) k(x)=3x2+x+1 in Z3[x].
(a) deg(f)=3, leading coefficient 5, constant term 7; not monic since 5=1.
(b) deg(g)=4, leading coefficient 1, constant term 0; monic.
(c) deg(h)=0, leading coefficient 3, constant term 3; not monic. Constants are perfectly good polynomials, of degree 0.
(d) This is the trap. In Z3 we have 3=0, so
k(x)=3x2+x+1=0x2+x+1=x+1 in Z3[x],
giving deg(k)=1, leading coefficient 1, constant term 1; 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 0 in R.
Definition 7.2
The zero polynomial is the function z:R→R given by z(x)=0 for all x∈R (where 0 is the additive identity in R). The degree of the zero polynomial is undefined, but for our purposes we will treat its degree as −∞.
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)=−∞ is a convention, not a theorem, but it is a convention that buys us two things:
The rule deg(fg)=deg(f)+deg(g) keeps working, since −∞+n=−∞ and 0⋅f=0.
The rule deg(f+g)≤max(degf,degg) keeps working when the two polynomials cancel entirely.
The Division Theorem below can demand deg(r)<deg(g) without having to add "or r=0" as a separate case, since −∞ is less than everything.
Basically, −∞ is chosen precisely so that every statement we want to make about degrees has no annoying exceptions.
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.
Notation
The set of all polynomials over a ring R is denoted R[x].
Fact
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)=∑iaixi and g(x)=∑ibixi,
Every coefficient on the right is built from the ai and bi using only addition and multiplication in R, so closure under both operations is inherited straight from closure in R. 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 aibj (or aibjck), which then agree by the corresponding axiom in R.
That leaves the identities and inverses. The zero polynomial is the additive identity, since adding 0 to each coefficient changes nothing; the additive inverse of ∑iaixi is ∑i(−ai)xi, which lives in R[x] because each −ai∈R; and the constant polynomial 1 is the multiplicative identity, since multiplying by it leaves every coefficient alone. Hence every axiom for a commutative unital ring holds. ■
Notice that multiplicative inverses were never mentioned, and for good reason: R[x] is essentially never a field, even when R is. There is no polynomial you can multiply x by to get 1, for exactly the same degree reason that we are about to make precise. So Q[x] sits alongside 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+3 and 3x3−2x+1 in Z[x].
Line up like powers and add the coefficients in Z:
Example. Find the sum of x2+2x+3 and 3x3−2x+1 in Z3[x].
The safest route is to reduce each polynomial mod 3 first, then add:
x2+2x+33x3−2x+1=x2+2x,=0x3+x+1=x+1,
using 3=0 and −2=1 in Z3. Adding,
(x2+2x)+(x+1)=x2+3x+1=x2+1 in Z3[x].
As a check, reducing the Z[x] answer 3x3+x2+4 mod 3 gives x2+1 as well. Therefore, the sum is x2+1, of degree 2.
The degree dropped from 3 to 2 purely because of the ring we were working in; 3x3 is a genuine cubic term over Z but is the zero polynomial over Z3. This is the single most common slip in this topic. Never quote the degree of a polynomial without saying which R[x] you are in.
Example. Find the product of x2−x+3 and 2x+1 in Z[x].
Expanding term by term,
Therefore, the product is 2x3−x2+5x+3, of degree 3=2+1, as expected.
Example. Find the product of x2−x+3 and 2x+1 in Z3[x].
Reduce first: x2−x+3=x2+2x and 2x+1 is already reduced. Then
(x2+2x)(2x+1)=2x3+x2+4x2+2x=2x3+5x2+2x=2x3+2x2+2x in Z3[x].
Reducing the Z[x] answer instead gives 2x3−x2+5x+3=2x3+2x2+2x, which agrees. Therefore, the product is 2x3+2x2+2x. Notice that this time the degree did not drop; Z3 is a field, and in a field the product of the two nonzero leading coefficients (1 and 2) can never be 0.
The general degree rules are worth stating explicitly, since we lean on them constantly:
deg(f+g)≤max(degf,degg),deg(fg)≤deg(f)+deg(g),
with equality in the second provided R has no zero divisors (in particular, whenever R is a field). Recall from Rings and Fields that a zero divisor is a nonzero element whose product with some other nonzero element is 0; if the leading coefficients am and bn satisfy ambn=0, then the xm+n term of fg vanishes and the degree collapses.
Example. Show that deg(fg)<deg(f)+deg(g) can genuinely happen, by multiplying 2x+1 and 3x+1 in Z6[x].
Both factors have degree 1, so we would hope for a degree 2 answer. Expanding,
(2x+1)(3x+1)=6x2+2x+3x+1=6x2+5x+1=5x+1 in Z6[x],
since 6=0 in Z6. Therefore, the product has degree 1<1+1; the culprit is that 2 and 3 are zero divisors in Z6. The clean identity deg(fg)=degf+degg is a fact about fields (and about Z), not about all rings.
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] 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.
Definition 7.3
A polynomial p(x)∈R[x] is called a unit (or invertible) if it has a multiplicative inverse in R[x].
Notation
The unit group of a polynomial ring R[x] is the set of all units in R[x], and is denoted R[x]∗.
Fact
If F is a field, then F[x]⋆=F⋆.
Proof. (⊇) If a∈F∗, then a is a nonzero constant polynomial and a−1∈F⊆F[x] satisfies a⋅a−1=1; so a∈F[x]∗.
(⊆) Suppose f(x)∈F[x]∗, so f(x)g(x)=1 for some g(x)∈F[x]. Neither f nor g is the zero polynomial (their product is 1=0), so both have degree at least 0. Since F is a field it has no zero divisors, so degrees add exactly:
deg(f)+deg(g)=deg(fg)=deg(1)=0.
Two non-negative integers summing to 0 must both be 0, so deg(f)=deg(g)=0; that is, f=a and g=b are constants with ab=1 in F. Hence f=a∈F∗. ■
Basically, over a field the only invertible polynomials are the nonzero constants, because multiplying by anything of degree ≥1 pushes the degree up and there is no way to push it back down to 0.
Example. Find the following unit groups.
(a) Q[x]∗.
(b) Z[x]∗.
(c) Z3[x]∗.
(d) Z4[x]∗.
(a) Q is a field, so by the fact above, Q[x]∗=Q∗=Q∖{0}; every nonzero rational constant, and nothing else.
(b) Z is not a field, but it has no zero divisors, so the degree argument in the proof still runs verbatim and forces f=a, g=b with ab=1 in Z. We showed in Rings and Fields that this forces a=±1. Therefore Z[x]∗=Z∗={1,−1}.
(c) Z3 is a field (as 3 is prime), so Z3[x]∗=Z3∗={1,2}.
(d) Z4 is not a field and it does have a zero divisor, namely 2, since 2×2=4=0. The degree argument collapses, and the answer is genuinely bigger than Z4∗={1,3}. Watch what happens to 1+2x:
(1+2x)2=1+4x+4x2=1+0x+0x2=1 in Z4[x],
so 1+2x is its own inverse and is therefore a unit of degree 1. The same trick works with any number of terms: because 22=0 in Z4, every product of two of the "2" coefficients dies, and one checks in exactly the same way that
(3+2x)2=(1+2x+2x2)2=(3+2x2+2x5)2=1.
Therefore
Z4[x]∗={a0+a1x+⋯+anxn:a0∈{1,3} and a1,…,an∈{0,2}},
which is an infinite set, one unit for each finite choice of which higher coefficients are 2.
The condition that F be a field in F[x]∗=F∗ is not decoration; Z4[x]∗ is strictly bigger than Z4∗ and contains units of every degree. The precise reason is that 2 is nilpotent in Z4 (some power of it is 0), and nilpotent coefficients can be attached to any power of x 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.
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".
Definition 7.4
Given two polynomials f(x),g(x)∈R[x] for some ring R, we say f(x)dividesg(x) and write f(x)∣g(x) to mean g(x)=f(x)q(x) for some polynomial q(x)∈R[x].
Example. Show that (2x+1)∣(2x3−x2+5x+3) in Z[x], and decide whether 2∣x in Z[x] and in Q[x].
The first one we have already done: from the product example above,
2x3−x2+5x+3=(x2−x+3)(2x+1),
and x2−x+3∈Z[x], so (2x+1)∣(2x3−x2+5x+3) in Z[x].
For the second, we need q(x) with x=2q(x), i.e. q(x)=21x. This is not in Z[x], so 2∤x in Z[x]; but 21x∈Q[x], so 2∣x in 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] and not in another.
Definition 7.5
An irreducible polynomial in R[x] is any p(x)∈R[x] such that
p(x)=0 and p(x)∈/R[x]∗, and
whenever p(x)=f(x)g(x) for polynomials f(x),g(x)∈R[x], we must have f(x)∈R[x]∗ or g(x)∈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 1 is not counted as a prime integer, transplanted.
The source note adds the practical version over a field.
Fact
If F is a field, then p(x)∈F[x] is irreducible if and only if whenever p(x)=f(x)g(x) with deg(f(x))≤deg(g(x)), we must have deg(f(x))=0 and deg(g(x))>0.
This is just F[x]∗=F∗ rewritten in terms of degrees: over a field, "is a unit" and "has degree 0" 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 1 over a field is irreducible, since 1=degf+degg forces one of the degrees to be 0.
A polynomial of degree 2 or 3 over a field is irreducible if and only if it has no root in F; the only available split is off a linear factor ax+b, and over a field that factor contributes the root −a−1b. (This fails from degree 4 onwards, where a polynomial can factorise into two quadratics with no roots at all; see Irreducible Polynomials.)
Example. Determine whether x2+1 is irreducible in R[x], C[x], Z5[x], Z3[x] and Z2[x].
It has degree 2 in every one of these, so we hunt for roots.
In R[x]: a2+1≥1>0 for every real a, so there is no root and x2+1 is irreducible.
In C[x]: x2+1=(x+i)(x−i), two factors of degree 1; reducible.
In Z5[x]: testing a=0,1,2,3,4 gives 1,2,0,0,2, so 2 and 3 are roots. Indeed
(x+2)(x+3)=x2+5x+6=x2+1 in Z5[x],
so it is reducible.
In Z3[x]: testing a=0,1,2 gives 1,2,2, none of which is 0; irreducible.
In Z2[x]: 12+1=0, so 1 is a root, and (x+1)2=x2+2x+1=x2+1; reducible (in fact a perfect square).
Therefore, the very same polynomial is irreducible over R and Z3 but reducible over C, Z5 and Z2. 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+2 is irreducible in Q[x] but reducible in Z[x].
In Q[x] it has degree 1, so it is irreducible by the first consequence above; concretely, 2x+2=2(x+1) is a factorisation, but 2∈Q[x]∗, so it does not count. In Z[x] the same factorisation 2x+2=2(x+1) is fatal, because Z[x]∗={±1}, so neither 2 nor x+1 is a unit. Therefore 2x+2 is reducible in 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.
Theorem 7.6Unique Factorisation in F[x]
If F is a field, then every polynomial f(x)∈F[x] with degree greater than 0 has a unique factorisation into irreducible polynomials, up to unit factors. That is, we can write f(x) uniquely in the form
where c∈F∗, each p1(x),p2(x),…,pk(x) is a different irreducible monic polynomial in F[x], and α1,α2,…,αk∈Z+ for some k∈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 c playing the role of the sign. The reason we insist the pi are monic is the same reason we insist primes are positive: without it, 6=2×3=(−2)×(−3) would count as two different factorisations, and x2−1=(x−1)(x+1)=(2x−2)(21x+21) would too. Pulling all the unit "junk" out into a single leading c makes the factorisation genuinely unique.
Example. Write 2x4−2 in the form guaranteed by Theorem 7.6, over Q and then over Z5.
Over 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),
and we checked above that x2+1 is irreducible over Q (it has no real root, let alone a rational one). All three factors are monic irreducibles, so c=2 and k=3 with every αi=1.
Over Z5, the factor x2+1 splits further into (x+2)(x+3), and x−1=x+4, so
2x4−2=2(x+4)(x+1)(x+2)(x+3) in Z5[x],
now with c=2 and k=4. Therefore, the same polynomial has a three-factor factorisation over Q and a four-factor one over Z5; enlarging the field can only ever split things further, never fuse them.
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.
Theorem 7.7Division Theorem
For any field F and polynomials f(x),g(x)∈F[x] with g(x)=0, there exist unique polynomials q(x),r(x)∈F[x] such that both
f(x)=q(x)g(x)+r(x)anddeg(r(x))<deg(g(x)).
We call q(x) the quotient and r(x) the remainder when f(x) is divided by g(x).
Note that the zero polynomial can be a remainder, since its degree is −∞; this is the payoff of that convention, and it is exactly the case r=0 that says g∣f.
Fact
The Division Theorem is also true over R[x] for any ring R, so long as the leading coefficient of g(x) is a unit of R.
Proof (sketch). Use strong induction on deg(f). If deg(f)<deg(g) there is nothing to do; take q(x)=0 and r(x)=f(x). Otherwise write f(x)=amxm+⋯ and g(x)=bnxn+⋯ with m≥n, and kill the leading term of f by subtracting the right multiple of g:
f~(x)=f(x)−ambn−1xm−ng(x).
The xm terms cancel exactly, so deg(f~)<m, and by the inductive hypothesis f~=q~g+r with deg(r)<deg(g). Rearranging gives f=(ambn−1xm−n+q~)g+r, as required.
For uniqueness, suppose q1g+r1=q2g+r2 with both remainders of degree less than deg(g). Then (q1−q2)g=r2−r1; the right-hand side has degree less than deg(g), while the left-hand side has degree deg(q1−q2)+deg(g)≥deg(g) unless q1−q2=0. So q1=q2, and then r1=r2.
Notice that the only thing the argument ever needed from F was the inverse bn−1 of the leading coefficient of g; so the whole proof runs unchanged over any ring R provided that leading coefficient is a unit of R. ■
You cannot divide by an arbitrary polynomial over a ring that is not a field. For instance, in Z[x] try to divide x2 by 2x+1: the quotient would have to begin with 21x, which is not in Z[x], and no choice of integer quotient can leave a remainder of degree 0. Over Q[x] it is fine, and over Z[x] it is fine whenever the divisor is monic, since 1 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+5 is divided by x2+2x−3 (in Q[x]).
Write the dividend with every power present, including the missing 0x2, and long divide:
At each stage we divide the current leading term by x2 (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 2. Reading off the answer, q(x)=2x2−x+8 and r(x)=−18x+29. Checking that q(x)g(x)+r(x)=f(x):
Therefore, the quotient is 2x2−x+8 and the remainder is −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+2 is divided by x2+1 in Z3[x], by balancing coefficients.
Since deg(f)=4 and deg(g)=2, the quotient has degree 2 and the remainder has degree at most 1; so write
(x2+2x+2)(x2+1)+x=x4+2x3+2x2+x2+2x+2+x=x4+2x3+3x2+3x+2=x4+2x3+2 in Z3[x].✓
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.
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.
Definition 7.8
For any field F, a greatest common divisor (GCD) of two polynomials f(x),g(x)∈F[x] is any polynomial d(x)∈F[x] such that
both d(x)∣f(x) and d(x)∣g(x), and
for all c(x)∈F[x], if c(x)∣f(x) and c(x)∣g(x), then c(x)∣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) 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+x and g(x)=x2+4x+3 in Z5[x].
Factorise each polynomial, remembering that Z5[x]∗=Z5∗={1,2,3,4}, so each factorisation can be rewritten in four ways by moving a unit across:
(As a spot check, 2x(x+3)=2x2+6x=2x2+x and (3x+3)(2x+1)=6x2+3x+6x+3=x2+4x+3 in Z5[x].) Comparing the two lists, the common non-constant factors are 2x+1, x+3, 4x+2 and 3x+4; and these four are exactly the unit multiples of one another, since
1(x+3)2(x+3)3(x+3)4(x+3)=x+3,=2x+6=2x+1,=3x+9=3x+4,=4x+12=4x+2 in Z5[x].
Therefore, the GCDs of f(x) and g(x) in Z5[x] are 2x+1, x+3, 4x+2 and 3x+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.
Notation
The standard greatest common divisor of two polynomials f(x),g(x)∈F[x], denoted gcd(f(x),g(x)), is the monic GCD of f(x) and g(x) (that is, the GCD whose leading coefficient is 1).
For example, in Z5[x] we have gcd(2x2+x,x2+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 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∗ 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.
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.
Algorithm 7.9Euclidean algorithm
Given any field F and polynomials f(x),g(x)∈F[x], repeatedly apply the Division Theorem, first to f(x) and g(x), then to g(x) and the previous remainder r0(x), then to r0(x) and the previous remainder r1(x), and so on, terminating when rn+1(x)=0. Then the previous remainder rn(x) is a GCD of f(x) and 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] we find a remainder 2x+1 at one step, we could instead multiply it by 2 to get
2(2x+1)=4x+2=x+2 in Z3[x],
and use x+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] 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−4 and g(x)=x3+x2+2x+2. Find gcd(f(x),g(x)) in Q[x].
Divide f by g. Since x4÷x3=x,
The remainder −2x−2 has degree 1<3, as required. Before continuing, scale it by the unit −21 to get the monic x+1, and divide g by that:
x3+x2+2x+2=x2(x+1)+2(x+1)=(x2+2)(x+1)+0.(2)
The remainder is 0, so the algorithm stops and the last nonzero remainder x+1 is a GCD; it is already monic. Therefore, gcd(f(x),g(x))=x+1. As a sanity check, f(−1)=1+1+2−4=0 and g(−1)=−1+1−2+2=0, so x+1 really does divide both.
Example. Find gcd(x3−1,x2−1) in Q[x].
Running the algorithm,
x3−1x2−1=x(x2−1)+(x−1),=(x+1)(x−1)+0,
so the last nonzero remainder is x−1, which is monic. Therefore, gcd(x3−1,x2−1)=x−1. This matches the factorisations x3−1=(x−1)(x2+x+1) and x2−1=(x−1)(x+1), where x2+x+1 and x+1 share nothing.
Given any field F and polynomials f(x),g(x)∈F[x], there exist polynomials p(x),q(x)∈F[x] such that
gcd(f(x),g(x))=f(x)p(x)+g(x)q(x).
We can find these polynomials p(x) and q(x) the same way as we did before with integers: either by reversing the Euclidean algorithm applied to f(x) and 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 f and g remain.
Example. Let f(x)=x4+x2−2x−4 and g(x)=x3+x2+2x+2. Find p(x),q(x)∈Q[x] such that 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, and line (1) of that run is the only line with a nonzero remainder, so there is only one substitution to make. Rearranging (1) for its remainder,
−2x−2=f(x)−(x−1)g(x).(from (1))
Now multiply through by −21 to turn the left-hand side into the monic gcd:
x+1=−21(f(x)−(x−1)g(x))=−21f(x)+21(x−1)g(x).
Therefore, p(x)=−21 and q(x)=2x−1. Checking by expanding, and using (x−1)(x3+x2+2x+2)=x4+x2−2:
Notice that p(x) is allowed to be a constant, and that constants like −21 are unavoidable here; the whole point of working over a field is that these fractions are legal. Over Z[x] this identity would be impossible to write down.
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 x and y are taken (they were the row names before, and x is now the variable), so we will call the two coefficient rows ui and vi, and the invariant becomes
ri(x)=f(x)ui(x)+g(x)vi(x) in every column,
with the same recursions ri=ri−2−qiri−1, ui=ui−2−qiui−1 and vi=vi−2−qivi−1, seeded by u:1,0 and v: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) by −2x−2 rather than by x+1; the quotient there is −21x2−1, since
(−21x2−1)(−2x−2)=x3+x2+2x+2=g(x),
with remainder 0. So the quotients are x−1 and −21x2−1, and the table is:
qi
x−1
−21x2−1
ri
x4+x2−2x−4
x3+x2+2x+2
−2x−2
0
ui
1
0
1
21x2+1
vi
0
1
1−x
−21x3+21x2−x+2
For instance the third column comes from u3=1−(x−1)⋅0=1 and v3=0−(x−1)⋅1=1−x. Reading off the second-last column, where ri is a GCD,
−2x−2=f(x)⋅1+g(x)(1−x),
and multiplying by −21 to make it monic gives x+1=−21f(x)+2x−1g(x), exactly as before. Therefore, p(x)=−21 and q(x)=2x−1. The table hands you a GCD, not the standard GCD; scaling to monic is always the last step, and you must scale p(x) and q(x) by the same unit.
Example. Let f(x)=x4+x2+2 and g(x)=x2+2x+2. Find gcd(f(x),g(x)) in Z3[x], and find some p(x),q(x)∈Z3[x] such that gcd(f(x),g(x))=f(x)p(x)+g(x)q(x).
Run the Euclidean algorithm, doing all coefficient arithmetic in Z3. Dividing f by g: first x4÷x2=x2, and
where line (3) uses 2−1=2 in Z3, since 2(2x+1)=4x+2=x+2. The last nonzero remainder is the constant 2, which is a unit; scaling it to be monic gives 1. Therefore, gcd(f(x),g(x))=1; the two polynomials are coprime in Z3[x].
For the Bézout pair, back-substitute from (2) upwards using (1):
2=g(x)−x(x+2)=g(x)−x(f(x)−(x2+x)g(x))=−xf(x)+(1+x3+x2)g(x)=2xf(x)+(x3+x2+1)g(x) in Z3[x].(from (2))(substituting from (1))(collecting terms)
Finally multiply through by 2−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).
Therefore, p(x)=x and q(x)=2x3+2x2+2. Checking directly,
xf(x)+q(x)g(x)=(x5+x3+2x)+(2x5+2x3+x+1)=3x5+3x3+3x+1=1 in Z3[x].✓
Note
Expand one factor at a time and reduce mod p 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), (2) and (3) are x2+x, x and 2x+1:
qi
x2+x
x
2x+1
ri
x4+x2+2
x2+2x+2
x+2
2
0
ui
1
0
1
2x
2x2+x+1
vi
0
1
2x2+2x
x3+x2+1
x4+x2+2
The fourth column is u4=0−x(1)=−x=2x and v4=1−x(2x2+2x)=1−2x3−2x2=x3+x2+1, and it reproduces 2=2xf(x)+(x3+x2+1)g(x) exactly as the back-substitution did. Scaling by 2 gives the same final answer.
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
In F[x]
integer
polynomial over the field F
absolute value ∣n∣
degree deg(p)
units ±1
units $F^* $ (the nonzero constants)
prime
irreducible polynomial
n=±p1α1⋯pkαk
f=cp1α1⋯pkαk with each pi monic irreducible
a=qb+r with 0≤r<∣b∣
f=qg+r with 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(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.