HomeHelp
12

HowTo: Euclidean algorithm for polynomials

In this HowTo we will describe the analogue of the euclidean algorithm to compute the greatest common divisor of any two polynomials in ℝ[X]  .

As the name indicates, a greatest common divisor (gcd) of two polynomials f,g ∈ ℝ[X]  is a polynomial d ∈ ℝ[X]  of greatest possible degree which divides both f  and g  . Clearly d  is only defined up to multiplication by a non-zero scalar, which is why we talk about ‘a’ gcd instead of ‘the’ gcd. Indeed, let 0 ⁄= c ∈ ℝ  be a non-zero scalar, then if d  is a gcd of f,g ∈ ℝ[X]  , so is cd  .

Given polynomials f,g  with g ⁄= 0  , the division algorithm gives polynomials q,r  with degr < deg g  such that

f = qg+ r .

A crucial observation, as with the gcd of integers, is that a polynomial d  is a gcd of f  and g  if and only if it is a gcd of r  and g  . This is proved in the same way as with integers.

The euclidean algorithm then works in the same way.

Problem. Find a greatest common divisor of two polynomials f,g ∈ ℝ[X]  , with g ⁄= 0  .

Solution (Euclidean algorithm). This is solved by iteration:

  1. Let F = f  and G = g  .
  2. Use the division algorithm to find polynomials q,r  , with degr < deg G  , such that F = qG + r  .
  3. If r = 0  then we stop: G = g  is a greatest common divisor.
  4. If r ⁄= 0  then replace F  by G  and G  by r  and go to (2).

Notice that this algorithm ends because at every step the degree of G  is decreasing.

Similarly we can modify the extended euclidean algorithm to write d = f r+ gs  from which it follows that any common divisor of f  and g  also divides d  . As a corollary we can prove that any two gcds of f,g  are multiples of each other. Indeed, if d1  and d2  are gcds, then d1∣d2  and d2∣d1  , whence by Problem 5.3, they have the same degree, hence if, say, d1 = cd2  , then c  must be a constant.

We could talk of the greatest common divisor if we imposed an extra condition on d  to eliminate the freedom of multiplying by a constant. One such condition is that the gcd be monic; that is, that the coefficient of highest degree be 1  .