The computation of the gcd is similar to the computation of the gcd for
integers (see Section 1.2).
Euclid's algorithm for polynomials
- Input: two polynomials a, b.
- Output: the gcd of a and b.
- Replace (simultaneously)
- a by b and
- b by the remainder
after division of a by b.
- Repeat Step 1 until b = 0.
- 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
- Input: two polynomials a and b.
- Output: x and y with gcd(a,b) =
xa + yb.
- Put x = v = 1 and y = u = 0.
- 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.
- Repeat Step 2 until b = 0.
- Return x and y.