Math 413 Lecture 2

Divisibility, Division & Euclidean Algorithms

1 Feb, 2001


1. Divisibility

2. Division Algorithm

3. Euclidean Algorithm

4. Extended Euclidean Algorithm

5. Final Words: Generalizing & Work Factors

5.A. Generalizing the Euclidean Algorithm

We have seen how the Euclidean algorithm applies to the integers. It is worth asking if such an algorithm applies to rings other than the integers. This is useful both because the Euclidean algorithm is the primary computational tool in number theory and because the existence of a Euclidean algorithm has strong consequences for the structure of the ring. In particular, we will see in the next few lectures, the existence of a Euclidean algorithm forces unique factorization.

Some examples are:

The existence of a Euclidean algorithm is sufficiently important that we call a ring with such an algorithm a Euclidean ring. Thus Z (the integers), Q[x] and Z[i] are Euclidean, while Z[x] is not, and we will later see that Z[sqrt(-5)] is not.

5.A. Work Factors

When studying number theory from a computational angle, we need to know not only that a problem can be solved, but how many basic operations are needed to solve it. The amount of work needed for an operation is generally expressed in terms of the number of multiplications needed. Divisions are often counted as multiplications, as they can often be accomplished in a similar time and additions and other operations are ignored, as they are generally negligible when compared to a multiplication.

A naive analysis tells us that the number of steps needed is about the number of bits of the operands, log2(a). When we divide some a by some b as a step of the Euclidean algorithm we will be left with a remainder which is in the range [0,b-1]. On average, we expect this to be about half the size of b. Thus the size of the operands will shrink by a factor of about 2 each step and we get the estimate of log2(a) steps.

Although this analysis has a lot of holes in it, the much more careful analysis in [ Knuth2, sect 4.5.3] yields a result of 0.842766 ln(a) = 1.21585 log2(a), almost the same result.

In addition to an average work it is worth while finding the worst case of the Euclidean algorithm. With some work it can be seen that the worst case comes when computing gcd(Fn, Fn+1), where Fn is the nth Fibonacci number. Computing this gcd takes n steps. As the nth Fibonacci number is asymptotically Fn~((1+sqrt(5))/2)n. Thus we get a worst case work factor of logg(a), where g=(1+sqrt(5))/2. Converting to bits, our work factor is 1.4404 log2(a).

Our conclusion is that not only is the Euclidean algorithm efficient, but its worst case efficiency is not much worse than its expected efficiency. (The best case efficiency is, of course, a single step.)

Careful analyses of the Euclidean algorithm and faster variants of the algorithm can be found in [Knuth2] and [BS96].


Robert Campbell, campbell@math.umbc.edu
17 Feb, 2001