This lecture discusses one of the earliest and most important mathematical algorithms. The Euclidean algorithm computes the greatest common divisor of two integers (it can be extended to other domains such as polynomials). This algorithm, not commonly taught when gcds are introduced in High School mathematics, is a much more efficient way to compute the gcd than using integer factorization.

The algorithm can be stated in a few lines, using recursion, yet it has many fascinating properties, and its complete analysis was a major undertaking.

An immediate generalization of the Euclidean algorithm, called the extended Euclidean algorithm computes integers x and y such that x*a + y*b = gcd(a,b).

- Euclidean division (division with remainder). a = q*b + r, where 0 <= r < b. The quotient q and remainder r are unique.
- Definition. g = gcd(a,b) iff g|a and g|b (m|n iff n = q*m for some q) and if e|a and e|b then e|g.
- Factorization into primes (every integer can be written uniquely (upto order) as a product of prime numbers. This is called the fundamental theorem of arithmetic.

- Maple User Manual (also available through Maple Help)
- Chapter 1: Getting Started
- Chapter 3: Worksheet Mode
- Chapter 9: Basic Programming
- Maple's help for igcd, igcdex, gcd, and gcdex commands.

- Definition of greatest common divisors
- Existence proof of Bezout's identity and a proof of Theorem 1.1.
- Euclidean algorithm

gcd(a,b)- if b = 0 then return a;
- else return gcd(b,a mod b)

- Proof of correctness
- The extended Euclidean algorithm (recursive version)
- Iterative version of the algorithm and remainder sequences
- Fibonacci numbers and an upper bound on the number of divisions
- The Fibonacci numbers are defined by F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2} for n > 1.
- F_n = 1/sqrt(5)*(phi^n - phihat^n), where phi = (1 + sqrt(5))/2 and phihat = (1 - sqrt(5))/2 are the roots of x^2-x-1=0. F_n is the nearest integer to 1/sqrt(5)*phi^n.
- Let 0 <= b < a <= N and n = the maximum number of division steps required to compute gcd(a,b) using the Euclidean algorithm. Then n <= 2lg(N). This constant in this bound is not tight.
- Let 0 <= b < a <= N. The maximum number of division steps occurs when when a = F_{n+2} and b = F_{n+1}. From this it follows that the n <= log[phi](N) + log[phi](sqrt(5)/phi). log[phi](N) is approximately 1.44*lg(N).

- The probability that two random integers are relatively prime.

- euclid.mw - Maple worksheet on the Euclidean algorithm.
- (euclid.pdf,euclid.pptx) - Lecture notes on the Euclidean algorithm.

- Use Maple's
**igcd**command to find gcd(1239,168). - Use Maple's
**igcdex**command to find integers x and y such that 1239*x + 168*y = gcd(1239,168). - Create a Maple worksheet containing the proof of correctness of the Extended Euclidean algorithm. Include example computations and a trace of the computation of the extended Euclidean algorithm.
- Experiment with Maple's
**cfrac**command from the**numtheory**package.