The computation of the gcd is similar to the computation of the gcd for integers (see Section 1.2).

Euclid's algorithm for polynomials



  1. Replace (simultaneously)
    • a by b and
    • b by the remainder after division of a by b.
  2. Repeat Step 1 until b = 0.
  3. Return a.

As for the integers we can find polynomials x and y with

xa + yb = gcd(a,b).

The extended Euclidean algorithm for polynomials


  1. Put x = v = 1 and y = u = 0.
  2. Replace (simultaneously)
    • a by b,
    • b by the remainder after division of a by b,
    • x by u and y by v,
    • u by x - qu and v by y - qv, where q is the quotient of a and b.
  3. Repeat Step 2 until b = 0.
  4. Return x and y.