Antonio Mach UNITEXT Algebra for Symbolic Computation 10.1007/978-88-470-2397-0_1 Springer-Verlag Italia 2012
1. The Euclidean algorithm, the Chinese remainder theorem and interpolation
The Euclidean algorithm
Let m be an arbitrary integer number (positive, negative or zero), n a positive integer, and let
the set of multiples of n . There exist two consecutive terms of this sequence, qn and ( q + 1) n , such that:
The operation consisting in finding the two numbers q and r is called division of m (dividend) by n (divisor). The integer q is the quotient (the greatest integer whose product by n is not greater than m , and as such it is uniquely determined), and r is the remainder of the division (which is uniquely determined as well). From (), by subtracting qn from each term, we get
and hence: the remainder is never negative and is less than the divisor . If r = 0, the number m is said to be a multiple of n, and n is said to be a divisor of m, and we write n|m. If m 1 has no divisors but itself and 1, then m is a prime number.
Consider now two integers m and n , m n > 0, and look for the integers that divide both m and n. We shall see that the problem reduces to finding the divisors of a single integer d . Divide m by n:
It follows that r = m qn . It is then apparent that an integer dividing both m and n divides r too. On the other hand, if an integer divides n and r , the same equality tells us that that integer divides m too, so it divides both m and n . In other words, the common divisors of m and n coincide with those of n and r . Now, dividing n by r , we deduce as above that the common divisors of n ad r (hence those of m and n ) are those of r and of the remainder of the division. Going on this way, we get a sequence of divisions that eventually reach a remainder equal to zero, since the remainders are strictly decreasing non-negative integers (we have set q = q 1 and r = r 1):
with the k th remainder r k equal to zero. By the above argument we have now that the common divisors of m and n are the common divisors of r k 1 (the last non-zero remainder) and 0 and, since all integers divide 0, we have that the common divisors of m and n are exactly the divisors of r k 1. Having set d = r k 1, we write d = (m, n) or d = gcd( m , n ). Now, d divides both m and n , and since among the divisors of d there is d itself, d is the greatest among the mutual divisors of m and n , hence the name of greatest common divisor of m and n . This name, however, conceals the main property of this number, lying not only in being the greatest among the divisors of both m and n , but in having as its divisors all the divisors of m and n .
So we have the following Euclidean algorithm :
input: m, n;
output: gcd (m, n);
u := m;
v := n ;
while v 0 do:
q := quotient( u , v );
t := u ;
u := v;
v := t qv .
If d = ( m , n ) = 1, then m and n have no common divisors different from 1: they are coprirne or relatively prime .
The remainder r 1 = m qn is a linear combination of m and n :
and this holds for r 2 too: we have r 2 = n q 2 r 1 = n q 2 m + q 1 q 2 n; hence:
This happens for all the remainders r i , i = 1, , ..., k , so it also holds for r k- 1 = d . Hence, we have:
Theorem 1.1 (The Bzout identity)
Given two integers m and n, there exist two integers h and k such that d = (m, n) is a linear combination of m and n: d = hm + kn .
Remark
The integers h and k in Theorem 1.1 are not uniquely determined. Indeed, for every integer s we have d = ( h sn)m + (k sm)n .
Let m, n > 1; note that in the Bzout identity it is not possible that h and k are both positive, nor both negative. Assume now k > 0; then it is always possible to find h and k with |h| < n and k < m such that hm + kn = d . Indeed, if k < m, hm = d kn , and hence |h|m = kn d , and if we had |h| > n , then nm < |h|m = kn d < mn d , a contradiction. If k > m , divide k by m: k = mq + r , 0 < r < m . Then ( h + qn)m +( k mq)n = d , and setting h = h + qn, k = k qm from k < m it follows, by the above, that h < n .
By modifying the program for the Euclidean algorithm we get the Bzout algorithm . It provides the triple [h, k, d] :
(u and v denote the third component of u and v ).
The input of the algorithm consists of the two integers m and n . In the form given by Bzouts theorem they are written m = 1 m +0 n and n = 0 m +1 n , which yield the starting triples for the algorithm ( m = ( m, m ) and n = ( n, n )).
An integer m divided by n gives a non-negative remainder that is less than n . So the possible remainders are the integers 0, , ..., n 1 (and all of them can be obtained, since a number m less than n , divided by n , gives m as remainder, the quotient being 0). If the remainder is r , we say that m is congruent to r modulo n , and we write m = r mod n . As a last thing, let us recall the fundamental theorem of arithmetic: every integer number different from 1 iss either prime or can be written as a product of prime factors and this, up to reordering the factors, can be done in a unique way . (The uniqueness of this decomposition is another consequence of the existence of the greatest common divisor; see Exercise 3, below.)