Next: Minimal polynomials and conjugate
Up: lecture4
Previous: lecture4
The Euclidean algorithm is perhaps the oldest algorithm in the world,
being attributed to Euclid and appearing in his Elements. It
applies on any Euclidean domain:
Integers and polynomials form a Euclidean domain, where the metric for
integers is simply the absolute value, and for polynomials it is the
degree of the polynomial.
Before we get to Euclid's algorithm, we need one more fact about GCDs:
For any integer
,
.
Euclid's algorithm finds the greatest common divisor of a pair
elements in a Euclidean domain.
The Euclidean algorithm works by repeated division.
This can be coded in nothing at all in MATLAB:
We can do more, however. It is a fact of number theory that
for some integers
and
. We can use the Euclidean algorithm to
determine
and
. In many of our applications, these will be the
numbers that we need. (Another useful fact: if there is an
and
such that
, then
.)
More formally, the algorithm may be stated in the following theorem,
which also fixes some useful notation.
Theorem 1 (The Euclidean algorithm)
Let
and
be integers
. Then
by repeated application of the division algorithm write
Then
, the last nonzero remainder of the division process.
That the theorem stops after a finite number of steps follows since
every remainder must be less than the preceding remainder.
If the GCD
and the coefficients
and
are desired
such that
a little more work is required. Observe that the recursion in the
Euclidean algorithm may be expressed as
for
(until termination) with
and
. The values for
and
may be obtained by finding
intermediate integers
and
satisfying
In conjunction with (1) we obtain
 |
(2) |
for
(until termination) with
This algorithm applies as well to polynomials (over a field) as to
integers. The following implementation is for polynomials.
As an example, we can try
>> [g,x,y] = gcdpoly([4 10 8 2],[8 14 7 1])
g =
1.0000 1.5000 0.5000
x =
0.3333
y =
-0.1667
Next: Minimal polynomials and conjugate
Up: lecture4
Previous: lecture4
Todd Moon
2009-11-06