Sei sulla pagina 1di 6

Euclidean Algorithm

Ken Coiteux October 7, 2013

Introduction

Lets talk about fractions. I can hear all the moans and groans now, but dont worry. I will not be asking for you to add or divide fractions, Ill be just reviewing them briey. Shortly after learning about fractions, we learned about reducing fractions into smallest terms. Why? Because it is much easier to work with 54 (and to visualize) 2 3 than 81 . Then we quickly learned about greatest common divisors. Denition 1. Given two integers a,b, the greatest common divisor (gcd) is the largest integer that divides both a and b evenly. The general process we learned for nding the gcd of two integers was to rst nd the prime factorization of both numbers. Then we ere to nd the terms that were common to both factorizations. Those common terms then were then used to identify the gcd. That process can get quite tedious when determining the gcd of large numbers. It wasnt until college before learning about the Euclidean algorithm. Lets refresh ourselves on what an algorithm is. An algorithm is a xed set of directions that gives a procedure for accomplishing some task. The Euclidean algorithm gives us a procedure for nding the gcd of two integers. No prime factorization is involved. Lets begin by looking at an example of using the Euclidean algorithm to nd gcd(6923,5117). First divide 5117 into 6923. We get a quotient of 1 and a remainder of 1806. In other terms: 6923 = 5117(1) + 1806 The numbers now shift to the left. What I mean here is that we discard 6923 and look at gcd(5117,1806). Divide 1806 into 5117 and we get 5117 = 1806(2) + 1505 Continuing the process, discard 5117 and look at gcd(1806,1505). Divide 1505 into 1806. 1806 = 1505(1) + 301 1

One more repetition has us nding gcd(1505,301) 1505 = 301(5) + 0 Now that the remainder has arrived at 0 gcd(6923, 5117) = gcd(5117, 1806) = gcd(1806, 1505) = gcd(1505, 301) = 301 Now that an example has been shown, a denition of the Euclidean algorithm in general terms may be easier to understand. To nd gcd(a, b), where a b, divide b into a to get a quotient q1 and a remainder r1 . Then divide r1 into b to get q2 and r2 . Continue this process until rn = 0. Then gcd(a, b) = rn1 . The corresponding calculations are: a = bq1 + r1 b = r1 q2 + r2 r1 = r2 q3 + r3 . . . rn2 = rn1 qn + 0 Now that we have an idea of how to use the Euclidean algorithm, what can we learn from its use? In the following, we will be answering some questions when large quantities of gcds are calculated. How are the steps of the algorithm related to the size of number pairs? How do gcd(a, b) = 1 compare to gcd(c, d) = n? What is the probability that gcd(a, b) = 1?

Findings using the Euclidean algorithm

In the following, a computer program was written to determine the gcds of 100,000 random integer pairs. Each set of random pairs was selected from a range. In other words, 10n < a, b < 10n+1 . For ease of use, N= 10n will signify the upper limit of a range.

2.1

Euclidean steps

As you have seen earlier, the Euclidean algorithm is completed in a number of steps. Does the size of the integer pairs aect the number of steps in calculating 2

the gcd? Intuitively, it would seem that the number of steps increase as the size of the integer pairs increase.

Figure 1:

Figue 1 does back up that intuition. It appears that both the peak number of steps and the maximum number of steps increase as N increases. Lets take some information from Figure 1 and put it into a table. Table 1: Peak number of steps Max number of steps 3 9 5 13 7 17 9 19 11 20

N 102 103 104 105 106

As you can see, N increases exponentially at a factor of 10 and the peak number of step increases linearly at a factor of 2. The maximumm number of steps at rst seems linear but then changes. I suspect that is due to the number of random pairs chosen in the ranges of N= 105 and N= 106 . Unlike the smaller ranges, the 100,000 random pairs do not include all the possible pairs in the larger ranges. From this data, I can make some conjectures: Conjecture 1. As the size of the pairs of integers increase exponentially, the number of steps in the Euclidean algorithm increase linearly. Conjecture 2. As the size of the pairs of integers increase exponentially, the maximum number of steps in the Euclidean algorithm3 increase linearly. 3

2.2

Relation of gcd(a, b) = 1 to gcd(c, d) = k

Integer pairs that have gcd=1 are said to be relatively prime. This means that the largest integer that divides into relatively prime integers is 1. What is the relationship between the number of relatively prime integer pairs and the number of integer pairs with gcd=k? Figure 2: Frequency of gcds with N= 105

Looking at Figure 2, we see some obvious characteristics. The number of relatively prime integers are greater then the number of intgers with gcd=2. Those in turn are greater than the number of integer pairs with gcd=3. Now lets look at the ratio of the frequencies of gcd=2 to the frequencies of gcd=1. 15334 1 60825 4 This tells us that there is about one-quarter of gcd=2 as compared to gcd=1. Table 2: Approximate decimal 0.2521 0.1098 0.0601 0.4000 0.0278 0.2041 0.0156 0.0123 0.0100

Ratio gcd 2:gcd 1 gcd 3:gcd 1 gcd 4:gcd 1 gcd 5:gcd 1 gcd 6:gcd 1 gcd 7:gcd 1 gcd 8:gcd 1 gcd 9:gcd 1 gcd 10:gcd 1

Approximate fraction
1 4 1 9 1 16 1 25 1 36 1 49 1 64 1 81 1 100

Again, remember that only 100,000 random integer pairs were chosen for N= 105 . The number of trials is large enough for approxiamtion, but not enough for exactness. It does appear that there is a relationship between the dierent counts of gcd=k and gcd=1. Conjecture 3. The ratio of the frequency of gcd(a,b)=k to the frequency of 1 gcd(a,b)=1 is k 2.

2.3

Probability of integer pairs being realtively prime

Referring back to Figure 2, notice that the percentage of relatively prime numbers is about 60. 60825 100000 .608. Adding the percentages of all the frequencies of gcd(a,b)=k will equal 100 percent. From the previous section, it 1 follows that the percentage of gcd(a,b)=k is k 2 A, where A is the percentage of relatively prime numbers. So, 1 1 A + A + A + = 1 4 9 1 1 A(1 + + + ) = 1 4 9 From Euler, we know this result:

j =1

1 1 1 2 = 1 + + + = 2 j 4 9 6

Doing some substitution..... 2 )=1 6 6 A= 2

A(

The above information is the proof for the following: Theorem 1. The probability of two integers being relatively prime is
6 2 .

Conclusion

Lots of trials and data have lead to some conjectures to be proven true at a later time. Another conjecture discovererd after analyzing data is the following:
a b Conjecture 4. gcd(a, b) = k if and only if k |a, k |b, and gcd( k , k )=1

This conjecture is related to Conjecture 3, and proving one should quickly lead to proving the other. Then when these are proven, then the proof for Theorem will become stronger since it is partially based on Conjecture 3. There are other topics to consider looking at through the lens of the Euclidean algorithm. Fibonacci numbers, modular math, and polynomials are just a few areas to look for trends.