Continued Fractions and the Euclidean AlgorithmWilliam F. HammondLecture notes prepared for MATH 326, Spring 1997 Department of Mathematics and Statistics University at AlbanyZGL1IntroductionSU-12The continued fraction expansion of a real numberSU-23First examplesSU-34The case of a rational numberSU-45The symbol t1,t2,,trSU-56Application to Continued FractionsSU-67Bezouts Identity and the double recursionSU-78The action of GL2Z on the projective lineSU-89Periodic continued fractionsSU-9ReferencesSU-TheBibLiog
1IntroductionContinued fractions offer a means of concrete representation for arbitrary real numbers The continued fraction expansion of a real number is an alternative to the representation of such a number as a (possibly infinite) decimalThe reasons for including this topic in the course on Classical Algebra are: (i)The subject provides many applications of the method of recursion(ii)It is closely related to the Euclidean algorithm and, in particular, to Bezouts Identity(iii)It provides an opportunity to introduce the subject of group theory via the 2dimensional unimodular group GL2Z
2The continued fraction expansion of a real numberEvery real number x is represented by a point on the real line and, as such, falls between two integers For example, if n is an integer and nxn1, x falls between n and n1 and there is one and only one such integer n for any given real x In the case where x itself is an integer, one has nx The integer n is sometimes called the floor of x and one often introduces a notation for the floor of x such as nxExamples: 1.21.52.3For any real x with nx the number uxn falls in the unit interval I consisting of all real numbers u for which 0u1Thus, for given real x there is a unique decomposition xnu where n is an integer and u is in the unit interval Moreover, u0 if and only if x is an integer This decomposition is sometimes called the mod one decomposition of a real number It is the first step in the process of expanding x as a continued fractionThe process of finding the continued fraction expansion of a real number is a recursive process that procedes one step at a time Given x one begins with the mod one decomposition xn1u1, where n1 is an integer and 0u11If u10 which happens if and only if x is an integer, the recursive process terminates with this first step The idea is to obtain a sequence of integers that give a precise determination of xIf u10 then the reciprocal 1u1 of u1 satisfies 1u11 since u1 is in I and, therefore, u11 In this case the second step in the recursive determination of the continued fraction expansion of x is to apply the mod one decomposition to 1u1 One writes 1u1n2u2, where n2 is an integer and 0u21 Combining the equations that represent the first two steps, one may write xn11n2u2Either u20 in which case the process ends with the expansion xn11n2, or u20 In the latter case one does to u2 what had just been done to u1 above under the assumption u10 One writes 1u2n3u3, where n3 is an integer and 0u31 Then combining the equations that represent the first three steps, one may write xn11n21n3u3After k steps, if the process has gone that far, one has integers n1,n2,,nk and real numbers u1,u2,,uk that are members of the unit interval I with u1,u2,,uk1 all positive One may write xn11n21n311nkuk Alternatively, one may write xn1,n2,n3,,nkuk If uk0 the process ends after k steps Otherwise, the process continues at least one more step with 1uknk1uk1In this way one associates with any real number x a sequence, which could be either finite or infinite, n1,n2, of integers This sequence is called the continued fraction expansion of x AssertLabel-1conventionConventionWhen n1,n2,... is called a continued fraction, it is understood that all of the numbers nj are integers and that nj1 for j2
3First examples15111411111141123411214311211131,2,1,310311103311033161110331611033161613,6,6,6,2,3,5,2213,5,221315,221315122131112213211213511211358135Let x11213121312 In this case one finds that x11y, where y213121312 Further reflection shows that the continued fraction structure for y is selfsimilar: y2131y This simplifies to y7y23y1 and leads to the quadratic equation 3y26y20 with discriminant 60 Since y2 one of the two roots of the quadratic equation cannot be y and, therefore, y3153 Finally, x1512The idea of the calculation above leads to the conclusion that any continued fraction n1,n2, that eventually repeats is the solution of a quadratic equation with positive discriminant and integer coefficients The converse of this statement is also true, but a proof requires further consideration
4The case of a rational numberThe process of finding the continued fraction expansion of a rational number is essentially identical to the process of applying the Euclidean algorithm to the pair of integers given by its numerator and denominatorLet xab,b0 be a representation of a rational number x as a quotient of integers a and b The mod one decomposition abn1u1,u1an1bb shows that u1r1b where r1 is the remainder for division of a by b The case where u10 is the case where x is an integer Otherwise u10 and the mod one decomposition of 1u1 gives br1n2u2,u2bn2r1r1 This shows that u2r2r1 where r2 is the remainder for division of b by r1 Thus, the successive quotients in Euclids algorithm are the integers n1,n2, occurring in the continued fraction Euclids algorithm terminates after a finite number of steps with the appearance of a zero remainder Hence, the continued fraction expansion of every rational number is finite AssertLabel-2theoremsTheorem1The continued fraction expansion of a real number is finite if and only if the real number is rationalProof. It has just been shown that if x is rational, then the continued fraction expansion of x is finite because its calculation is given by application of the Euclidean algorithm to the numerator and denominator of x The converse statement is the statement that every finite continued fraction represents a rational number That statement will be demonstrated in the following section
5The symbol t1,t2,,trFor arbitrary real numbers t1,t2,,tr with each tj1 for j2 the symbol t1,t2,,tr is defined recursively by: t1t1 t-receqnt1,t2,,trt11t2,,tr In order for this definition to make sense one needs to know that the denominator in the righthand side of (iref="t-rec"t-rec) is nonzero The condition tj1 for j2 guarantees, in fact, that t2,,tr0 as one may prove using inductionIt is an easy consequence of mathematical induction that the symbol t1,t2,,tr is a rational number if each tj is rational In particular, each finite continued fraction is a rational number (Note that the symbol t1,t2,,tr is to be called a continued fraction, according to the convention of the first section, only when each tj is an integer.)Observe that the recursive nature of the symbol t1,,tr suggests that the symbol should be computed in a particular case working from right to left Consider again, for example, the computation above showing that 2,3,5,28135 Working from right to left one has: 225,25125121123,5,2315,2321135112,3,5,2213,5,2211358135There is, however, another approach to computing t1,t2,,tr Let, in fact, t1,t2, be any (finite or infinite) sequence of real numbers One uses the double recursion pdefeqnpjtjpj1pj2,j1,p01,p10 to define the sequence pj,j1 The double recursion, differently initialized, qdefeqnqjtjqj1qj2,j1,q00,q11 defines the sequence qj,j1 Note that p1t1 p2t1t21 and q11 q2t2 q3t2t31 One now forms the matrix Mr-defeqnMjrrpjqjpj1qj1forj0 Thus, for example, M0rr1001,andM1rrt1110 It is easy to see that the matrices Mj satisfy the double recursion Mr-receqnMjrrtj110Mj1,j1 as a consequence of the double recursion formulas for the pj and qj Hence, a simple argument by mathematical induction shows that MrcompeqnMrrrtr110rrt2110rrt1110,r1 This is summarized by: AssertLabel-3propositionsProposition1For any sequence tj,j1 of real numbers, if pj and qj are the sequences defined by the double recursions (iref="pdef"pdef) and (iref="qdef"qdef), then one has the matrix identity prqr-roweqnrrprqrpr1qr1rrtr110rrt2110rrt1110 for each integer r1 pqidencorollariesCorollary1One has the identity prqr1qrpr11r for each integer r1Proof. The number prqr1qrpr1 is the determinant of the matrix Mr From the formula (iref="Mrcomp"Mrcomp) the matrix Mr is the product of r matrix factors, each of which has determinant 1 Since the determinant of the product of matrices is the product of the determinants of the factors, it is clear that detMr1r videncorollariesCorollary2One has the vector identity prqr-veceqnrprqrrrt1110rrt2110rrtr110r10 for each integer r1Proof. First recall (i) that the product of a matrix and a (column) vector is defined by the relation rrabcdrxyraxbycxdy, (ii) that the transpose of a matrix is the matrix whose rows are the columns of the given matrix, and (iii) that the transpose operation reverses matrix multiplication One tranposes both sides of the relation (iref="prqr-row"prqr-row) to obtain: prqr-coleqnrrprpr1qrqr1rrt1110rrt2110rrtr110 To this relation one applies the principle that the first column of any 22 matrix is the product of that matrix with the column r10 in order to obtain the column identity (iref="prqr-vec"prqr-vec) AssertLabel-6theoremsTheorem2For any sequence tj,j1 of real numbers, if pj and qj are the sequences defined by the double recursions (iref="pdef"pdef) and (iref="qdef"qdef), and if tj1 for j2 then the value of the symbol t1,,tr is given by the formula t-compeqnt1,t2,,trprqrforr1Proof. What is slightly strange about this important result is that while the pr and the qr are defined by the front end recursions, albeit double recursions, (iref="pdef"pdef) and (iref="qdef"qdef), the symbol t1,,tr is defined by the back end recursion (iref="t-rec"t-rec) The proof begins with the comment that the righthand side of (iref="t-comp"t-comp) does not make sense unless one can be sure that the denominator qr0 One can show easily by induction on r that qr1 for r1 under the hypothesis tj1 for j2The proof proceeds by induction on r If r1 the assertion of the theorem is simply the statement t1p1q1 and, as noted above, p1t1 and q11 Assume now that r2 By induction we may assume the correctness of the statement (iref="t-comp"t-comp) for symbols of length r1 and, therefore, for the symbol t2,,tr That case of the statement says that t2,,tr must be equal to ac where by corollary iref="viden"viden racrrabcdr10 with rrabcdrrt2110rrtr110 Now by (iref="t-rec"t-rec) t1,t2,,trt11act1caat1ca But by corollary iref="viden"viden again rprqrrrt1110rrabcdr10rrat1cbt1dabr10rat1ca Hence, prqrat1cat1,t2,,tr
6Application to Continued FractionsRecall that n1,n2, is called a continued fraction only when each nj is an integer and nj1 for j2 The sequence n1,n2, may be finite or infinite The symbol crn1,n2,,nr formed with the first r terms of the sequence, is called the rth convergent of the continued fraction Associated with a given sequence n1,n2, are two sequences p1,p2, and q1,q2, that are given, according to the double recursions (iref="pdef"pdef), (iref="qdef"qdef) of the previous section with tjnj AssertLabel-7propositionsProposition2If n1,n2, is a continued fraction, then the integers pr and qr are coprime for each r1Proof. By Corollary iref="pqiden"pqiden of the previous section prqr1qrpr11r Hence, any positive divisor of both pr and qr must divide the lefthand side of this relation, and, therefore, must also divide 1r AssertLabel-8propositionsProposition3The difference between successive convergents of the continued fraction n1,n2, is given by the formula convgtdiffeqncrcr11rqrqr1forr2Proof. According to the theorem (formula iref="t-comp"t-comp) at the end of the last section the convergent cr is given by crprqr Hence, crcr1prqrpr1qr1prqr1pr1qrqrqr11rqrqr1 (The last step is by Corollary iref="pqiden"pqiden above.) AssertLabel-9remarksRemark1The formula (iref="convgtdiff"convgtdiff) remains true if crt1,,tr where the tj are real numbers subject to the assumption tj1 for j1 AssertLabel-10AssertDefaultLemmaThe sequence qj is a strictly increasing sequence for j2Proof. This is easily proved by induction from the recursive definition (iref="qdef"qdef) of the sequence AssertLabel-11theoremsTheorem3If n1,n2, is an infinite continued fraction, then the limit limrprqr always existsProof. As one plots the convergents cr on the line of real numbers, one moves alternately right and left The formula (iref="convgtdiff"convgtdiff) for the difference between successive convergents elucidates not only the fact of alternate right and left movement but also the fact that each successive movement is smaller than the one preceding Therefore, one has c1c3c5c6c4c2 Since any strictly increasing sequence of positive integers must have infinite limit, the seqence qjqj1 has infinite limit, and so the sequence of reciprocals 1qjqj1 must converge to zero Hence, the sequences of odd and evenindexed convergents must have the same limit, which is the limit of the sequence of all convergents AssertLabel-12definitionsDefinition1The limit of the sequence of convergents of an infinite continued fraction is called the value of that continued fraction AssertLabel-13theoremsTheorem4If n1,n2, is the continued fraction expansion of an irrational number x then xlimrprqr; that is, the value of the continued fraction expansion of a real number is that real numberProof. For each r1 the continued fraction expansion n1,n2, of x is characterized by the identity xconfraceqnxn1,n2,,nrur, where ur is a real number with 0ur1 The sequences of ps and qs for the symbol n1,n2,,nrur agree with those for the symbol n1,n2,,nr except for the rth terms One has by (iref="t-comp"t-comp) n1,n2,,nrurPrQr, where by (iref="qdef"qdef) qrnrqr1qr2Qrnrurqr1qr2 Hence, Qrqrurqr1 Therefore, the displacement from cr1 to x is by (iref="convgtdiff"convgtdiff) 1rQrqr11rqrqr1urqr12, which is in the same direction but of smaller magnitude than the displacement from cr1 to cr Therefore, x must be larger than every oddindexed convergent and smaller than every evenindexed convergent But since all convergents have the same limit, that limit must be x
7Bezouts Identity and the double recursionIt has already been observed that the process of finding the continued fraction expansion of a rational number ab (b0), involves the same series of long divisions that are used in the application of the Euclidean algorithm to the pair of integers a and b Recall that at each stage in the Euclidean algorithm the divisor for the current stage is the remainder from the previous stage and the dividend for the current stage is the divisor from the previous stage, or, equivalently, the dividend for the current stage is the remainder from the second previous stage The Euclidean algorithm may thus be viewed as a double recursion that is used to construct the sequence of remainders One starts the double recursion with r1aandr0b At the jth stage one performs long division of rj2 by rj1 to obtain the integer quotient nj and the integer remainder rj that satisfies 0rjrj1 Thus, remreceqnrjrj2njrj1 The Euclidean algorithm admits an additional stage if rj0 Since 0rjrj1r2r1r0b, there can be at most b stagesOne may use the sequence of successive quotients nj (j1) to form sequences pj and qj as in the previous section, according to the double recursions: npdefeqnpjnjpj1pj2,j1;p01,p10 nqdefeqnqjnjqj1qj2,j1;q00,q11 It has already been observed that qj1 for j1 and n1,n2,,njpjqj,j1Bezouts Identity says not only that the greatest common divisor of a and b is an integer linear combination of them but that the coefficents in that integer linear combination may be taken, up to a sign, as q and p AssertLabel-14theoremsTheorem5If the application of the Euclidean algorithm to a and b (b0) ends with the mth long division, i.e., rm0 then bezouteqnrj1j1qjapjb,1jmProof. One uses induction on j For j1 the statement is r1q1ap1b Since by (iref="npdef"npdef, iref="nqdef"nqdef) q11 and p1n1 this statement is simply the case j1 in (iref="remrec"remrec) Assume j2 and that the formula (iref="bezout"bezout) has been established for indices smaller than j By (iref="remrec"remrec) one has rjrj2njrj1 In this equation one may use (iref="bezout"bezout) to expand the terms rj2 and rj1 to obtain: rj1j3qj2apj2bnj1j2qj1apj1b1j1qj2apj2bnj1j1qj1apj1b1j1qj2apj2bnjqj1apj1b1j1qj2njqj1apj2njpj1b1j1qjapjb AssertLabel-15corollariesCorollary3The greatest common divisor d of a and b is given by the formula gcdbezouteqnd1mqm1apm1b, where m is the number of divisions required to obtain zero remainder in the Euclidean algorithmProof. One knows that d is the last nonzero remainder rm1 in the Euclidean algorithm This formula for d is the case jm1 in (iref="bezout"bezout) AssertLabel-16corollariesCorollary4checkbezouteqnpmad,qmbdProof. The last remainder rm0 The case jm in (iref="bezout"bezout) shows that abpmqm Since, by the first proposition of the preceding section, pm and qm have no common factor, this corollary is evident
8The action of GL2Z on the projective lineIf a b c d are real numbers with adbc0and Mrrabcd is the matrix with entries a b c and d then Mz for z real, will denote the expression glacteqnMzazbczd One calls Mz the action of M on zMz is a perfectly good function of z except for the case zdc where the denominator czd vanishes If it were also true that azb0 for the same z then one would have badc in contradiction of the assumption adbc0 Thus, when zdc the value of Mw increases beyond all bounds as w approaches z and it is convenient to say that Mdc where is regarded as large and signless If further it is agreed to define Mac, which is the limiting value of Mw as w increases without bound, then one may regard the expression Mz as being defined always for all real z and for The set consisting of all real numbers and also the object (not a number) is called the projective line The projective line is therefore the union of the (ordinary) affine line with a single point AssertLabel-17propositionsProposition4If n1,n2, is any continued fraction, then cfgleqnn1,n2,,nr,nr1,Mnr1, where Mrrn1110rrnr110Proof. Let znr1, Then n1,n2,,nr,nr1,n1,n2,,nr,z The statement of the proposition now becomes n1,n2,,nr,zMz This may be seen to follow by multiplying both sides in formula (iref="prqr-col"prqr-col), after replacing tj with nj, by the column rz1The matrix M in the preceding proposition is an integer matrix with determinant 1 The notation GL2Z denotes the set of all such matrices (The 2 indicates the size of the matrices, and the Z indicates that the entries in such matrices are numbers in the set Z of integers.) It is easy to check that the product of two members of GL2Z is a member of GL2Z and that the matrix inverse of a member of GL2Z is a member of GL2Z Thus, GL2Z forms what is called a group The formula (iref="glact"glact) defines what is called the action of GL2Z on the projective lineOne says that two points z and w of the projective line are rationally equivalent if there is a matrix M in GL2Z for which wMz Since (i) GL2Z is a group, (ii) M1M2zM1M2z and (iii) wMz if and only zM1w it is easy to see that every point of the projective line belongs to one and only one rational equivalence class and that two points rationally equivalent to a third must be rationally equivalent to each other AssertLabel-18AssertDefaultTerminologyThe rational equivalence of points on the projective line is said to be the equivalence relation on the projective line defined by the action of GL2Z AssertLabel-19examplesExample1The set of real numbers rationally equivalent to the point is precisely the set of rational numbers AssertLabel-20examplesExample2The proposition above shows that any continued fraction is rationally equivalent to each of its tails It follows that all tails of a continued fraction are rationally equivalent to each other
9Periodic continued fractionsIn one of the first examples of a continued fraction expansion, it was shown that 103,6,6,6, This is an example of a periodic continued fraction After a finite number of terms the sequence of integers repeats cyclically If a cyclic pattern is present from the very first term, then the continued fraction is called purely periodic Evidently, 6,6,6,103 is an example of a purely periodic continued fractionNote that a periodic continued fraction cannot represent a rational number since the continued fraction expansion of a rational number is finite AssertLabel-21theoremsTheorem6Every periodic continued fraction is the continued fraction expansion of a real quadratic irrational numberProof. For clarity: it is being asserted that every periodic continued fraction represent a number of the form abmc where a b c and m are all integers with m0 c0 and m not a perfect squareNumbers of this form with fixed m but varying integers a b and c0 may be added, subtracted, multiplied, and divided without leaving the class of such numbers (The statement here about division becomes clear if one remembers always to rationalize denominators.) Consequently, for M in GL2Z the number Mz will be a number of this form or if and only if z is in the same classSince a periodic continued fraction is rationally equivalent to a purely periodic continued fraction, the question of whether any periodic continued fraction is a quadratic irrationality reduces to the question of whether a purely periodic continued fraction is such Let xn1,,nr,n1,,nr,n1,,nr, be a purely periodic continued fraction By the proposition of the preceding section, xMx where M is notationally identical to the M in (iref="cfgl"cfgl) Ignoring the computation (iref="prqr-col"prqr-col) of M in terms of convergents, let Mrrabcd Then xaxbcxd, or, otherwise said, x is a solution of the quadratic equation cx2adxb0 AssertLabel-22remarksRemark2It is conversely true that the continued fraction expansion of every real quadratic irrationality is periodicThis converse will not be proved here
1KEY-1 G. Chrystal, Algebra: An Elementary Textbook (2 vols.), Chelsea 2KEY-2 G. Hardy E. Wright, An Introduction to the Theory of Numbers, Oxford Univ. Press 3KEY-3 S. Lang, Introduction to Diophantine Approximations, AddisonWesley 4KEY-4 O. Perron, Die Lehre von den Kettenbruchen, 2nd ed., Chelsea