• No results found

The continued fraction expansion of a rational number is the basis of a party trick (probably only for nerds and geeks) suggested to me by one of my colleagues.

Ask someone to think of two positive integersr ands, to dividerbys using their calculator, and to tell you the result. You will find the numbersrands.

How? You simply calculate the continued fraction for the number q=r/s, and use this to express it as a fraction:

q= [a0;a1, . . . ,an] =

[a0,a1, . . . ,an]

[a1, . . . ,an]

. You tell them the numerator and denominator of this fraction.

There are a couple of traps, one theoretical, one practical. First of all, as we have seen, the greatest common divisor of the numerator and denominator of a continued fraction is 1. So if the original numbersr andshave greatest common divisord>1, then you will findr/d ands/d instead ofrands. There is nothing that can be done about this; you have to bluff your way out of it as well as you can.

The practical problem is caused by rounding errors. Maybe, at some stage of the algorithm, the calculator will give you a number like 5.99999862, and you have to guess that this should really be 6, and terminate the algorithm at that point. There is no hard-and-fast rule for this.

3.4. A PARTY TRICK 27

Example Suppose the chosen numbers are 225 and 157, so thatq=225/157= 1.433121019. Now we calculate as follows:

a0=bqc=1, q1=1/(q−1) =2.308823529 a1=bq1c=2, q2=1/(q1−2) =3.238095238

a2=bq2c=3, q3=1/(q2−3) =4.2

a3=bq3c=4, q4=1/(q3−4) =5

Soq= [1; 2,3,4,5] = 225157.

Of courser=450 ands=314 would have given the same result!

The chance of the gcd problem arising can be estimated rather precisely, by a surprising theorem which is not part of this course.

Theorem 3.9 Given a large positive integer n, let pnbe the probability that two randomly chosen positive integers at most n are coprime. Then lim

n→∞

pn= 6

π2.

For example, of the 1000000 pairs of positive integers not exceeding 1000, there are 608383 coprime pairs.

Exercises

3.1 Express 245/43 as a continued fraction.

3.2 (a) Letα = [a0;a1,a2, . . . ,an], wherea0, . . . ,anare positive integers.

(i) Show thatα =a0+1/[a1;a2, . . . ,an]ifn>0.

(ii) Show thata0≤α ≤a0+1.

(b) Now letβ = [b0;b1,b2, . . . ,bm], whereb0, . . . ,bmare positive integers. Sup-

pose that ai=bifori=0, . . . ,k−1 andak<bk. Prove that • ifkis even, thenα≤β; • ifkis odd, thenβ ≤α. [Hint:Induction onk.]

Chapter 4

Infinite continued fractions

Infinite continued fractions are not really continued fractions at all, but are limits of finite continued fractions. We show in this section that every real irrational number has an expression as an infinite continued fraction, and show that these provide “good” rational approximations to irrational numbers. For example, the famous approximations 22/7 and 355/113 toπarise in this way.

4.1

An example

The Pythagoreans knew that the ratio of the diagonal to the side of a square is irrational. According to the historian of mathematics David Fowler, they may have reasoned something like this.

@ @ @ @ @ @ @@ @ @ @ @ @ @ @ d s s s s d

Let s and d be the side and diagonal lengths of a square. Rotate the square through 45 degrees. Prolong the diagonal bysand draw a new square on this side, with side and diagonal lengthsSandD. We see from the figure thatS=s+d, and D=2s+d; so S+D S = 3s+2d s+d =2+ s s+d. 29

30 CHAPTER 4. INFINITE CONTINUED FRACTIONS Letu= (s+d)/s. Since any two squares are similar, we also have u= (S+ D)/S, and so

u=2+1 u.

Substituting this expression foruinto the right-hand side of the expression repeat- edly, we see that

u = 2+ 1 2+1 u = 2+ 1 2+ 1 2+1 u = . . .

Now the Pythagoreans knew the essence of Euclid’s algorithm, which as we have seen can be used to find the finite continued fraction of a rational number. Put another way, ifuwere a rational number, then the procedure for finding the continued fraction foruterminates, and the continued fraction is finite. The above argument shows that, if this algorithm is applied to our numberu, it never termi- nates; the algorithm “spins its wheels” and the next number at each stage is always u.

You might guess that this means thatucan be expressed as an “infinite contin- ued fraction” u=2+ 1 2+ 1 2+ 1 2+· · · .

In this chapter we will give a precise meaning to the notion of an infinite continued fraction, and verify that this is always the case. Morever, every real irrationanl number has a unique expression as an infinite continued fraction. We will also see that the finite continued fractions obtained by stopping after a finite number of steps give the “best possible” rational approximations to the number in question.

Related documents