An-Najah National University Faculty of Graduated Studies

On Continued and its Applications

By Rana Bassam Badawi

Supervisor Dr. “Mohammad Othman” Omran

This Thesis is Submitted in Partial Fulfillment of the Requirements for the Degree of Master of , Faculty of Graduate Studies, An-Najah National University, Nablus, Palestine. 2016

III Dedication

To my parents, the most wonderful people in my life who taught me that there is no such thing called

impossible. To my beloved brothers “Mohammad and Khalid”, To my lovely sisters “Walaa and Ruba”,

To all my family With my Respect and Love

****************

IV Acknowledgment

After a long period of hard working, writing this note of thanks is the finishing touch on my thesis. First of all, I’d like to thank God for making this thesis possible and helping me to complete it.

I would like to express my sincere gratitude to my supervisor Dr. “Mohammad Othman” Omran for the valuable guidance, continuous support and encouragement throughout my work on this thesis.

I would also like to thank my defense thesis committee: Dr. Subhi Ruziyah and Dr. Mohammad Saleh.

Last but not least, I wish to thank my family and all my friends who helped and supported me.

V اإلقرار

أنا الووقع أدناه هقذم الرسالة التي تحول العنواى

On Continued Fractions and its Applications

أقش بأى ها شولج عليَ الشسالت ُْ ًخاج جِذي الخاص, باسخثٌاء ها حوج اإلشاسة إليَ حيثوا ّسد,

ّأى ُزٍ الشسالت ككل أّ أي جزء هٌِا لن يقذم هي قبل لٌيل أي دسجت أّ لقب علوي أّ بحثي لذٓ أي هؤسست علويت أّ بحثيت. Declaration The work provided in this thesis, unless otherwise referenced, is the researcher's own work, and has not been submitted elsewhere for any other degree or qualification.

اسن الطالة: رنا تسام تذوي :Student's Name

التوقيع: Signature

التاريخ: Date 7112/11/72

VI

List of Contents Ch/Sec Subject Page Dedication III Acknowledgment IV Declaration V List of Contents VI List of Figures VII List of Tables VIII Abstract IX Introduction 1 History of Continued Fractions 2 1 Chapter One Definitions and Basic 6 Concepts 2 Chapter Two: Finite Simple Continued 9 Fractions 2.1 What is a Continued ? 9 2.2 Properties and Theorems 12 2.3 Convergents 25 2.4 Solving Linear Diophantine Equations 37 3 Chapter Three: Infinite Simple Continued 49 Fractions 3.1 Properties and Theorems 49 3.2 Periodic Continued Fractions 66 3.3 Solving Pell’s Equation 81 4 Chapter Four: Best Approximation and 90 Applications 4.1 Continued Fractions and Best Approximation 90 4.2 Applications 98 4.2.1 Calendar Construction 98 4.2.2 Piano Tuning 104 References 106 Appendix 110 ب الولخص VII List of Figures No. Subject Page 2.1 The behavior of the sequence of convergents in 35 Example 2.12 4.1 The first page of the papal bull by which Pope 99 Gregory XIII introduced his calendar. 4.2 A part of piano keyboard. 104

VIII

List of Tables No. Subject Page 2.1 A convergent table 31 2.2 Convergent table for Example 2.10 32 2.3 Convergent table for Example 2.17 45 2.4 Convergent table for Example 2.18 47 3.1 Convergent table for Example 3.3 54 3.2 The expansion for T , T is a positive non-perfect square integer between 2 80 and 30. 3.3 kth solutions of Pell’s Equation x2 19y 2 1, 87 1 ≤ k ≤ 5.

IX On Continued Fractions and its Applications By Rana Bassam Badawi Supervisor Dr. “Mohammad Othman” Omran

Abstract In this thesis, we study finite simple continued fractions, convergents, their properties and some examples on them. We use convergents and some related theorems to solve linear Diophantine equations. We also study infinite simple continued fractions, their convergents and their properties. Then, solving Pell’s equation using continued fractions is discussed. Moreover, we study the expansion of quadratic irrational numbers as periodic continued fractions and discuss some theorems. Finally, the relation between convergents and best approximations is studied and we apply continued fractions in calendar construction and piano tuning.

1

Introduction Continued fraction is a different way of looking at numbers. It is one of the most powerful and revealing representations of numbers that is ignored in mathematics that we’ve learnt during our study stages.

A continued fraction is a way of representing any real number by a finite (or infinite) sum of successive divisions of numbers. Continued fractions have been used in different areas. They’ve provided us with a way of constructing rational approximations to irrational numbers. Some computer algorithms used continued fractions to do such approximations. Continued fractions are also used in solving the

Diophantine and Pell's equations. Moreover, there is a connection between continued fractions and chaos theory as Robert M. Corless wrote in his paper in 1992.

The use of continued fractions is also important in mathematical treatment to problems arising in certain applications, such as calendar construction, astronomy, music and others.

2

History of Continued Fractions Mathematics is constantly built upon past discoveries. In doing so, one is able to build upon past accomplishments rather than repeating them. So, in order to understand and to make contributions to continued fractions, it is necessary to study its history. The history of continued fractions can be traced back to an algorithm of Euclid for computing the greatest common . This algorithm generates a continued fraction as a by-product. 34

For more than a thousand years, using continued fractions was limited to specific examples. The Indian mathematician Aryabhata used continued fractions to solve a linear indeterminate equation. Moreover, we can find specific examples and traces of continued fractions throughout Greek and Arab writings. 34

From the city of Bologna, Italy, two men, named Rafael Bombelli and Pietro Cataldi also contributed to this branch of mathematics. Bombelli was the first mathematician to make use of the concept of continued fractions in his book L’Algebra that was published in 1572. His approximation method of the square root of 13 produced what we now interpret as a continued fraction. Cataldi did the same for the square root of

18. He represented 18 as 4. & & & with the dots indicate that the following fraction is added to the denominator. It seems that he was the first to develop a symbolism for continued fractions in his essay Trattato del modo brevissimo Di trouare la Radici quadra delli numeri in 3 1613 . Besides these examples, however, both of them failed to examine closely the properties of continued fractions. 34,35,36,37

In 1625, Daniel Schwenter was the first mathematician who made a material contribution towards determining the convergents of the continued fractions. His main interest was to reduce fractions involving large numbers. He determined the rules we use now for calculating successive convergents. 35

Continued fractions first became an object of study in their own in the work which was completed in 1655 by Viscount William Brouncker and published by his friend John Wallis in his Arithmetica infinitorum written in 1656. 4 13355 7... Wallis represented the identity  and Brouncker  2 2 4 4 6 6... 4 1 converted it to the form  1 .  9 2  25 2  49 2  2  

In his book Opera Mathematica (1695), Wallis explained how to compute the nth convergent and discovered some of the properties of convergents. On the other hand, Brouncker found a method to solve the Diophantine Equation x2 – Ny2 = 1. 34,36

The Dutch mathematician Huygens was the first to use continued fractions in a practical application in 1687. His desire to build an accurate mechanical planetarium motivated him to use convergents of a continued fraction to find the best rational approximations for gear . 38 4 Later, the theory of continued fractions grew with the work of Leonard

Euler, Johan Heinrich Lambert and Joseph Louis Lagrange. Euler laid down much of the modern theory in his work De Fractionlous Continious (1737). He represented irrational and transcendental quantities by infinite series in which the terms were related by continuing . He called such series fractions continuae, perhaps echoing the use of the similar term fractions continuae fractae (continually broken fractions) by

John Wallis in the Arithmetica Infinitorum. He also found an expression for e in continued fraction form and used it to show that e and e2 are irrationals. He showed that every rational can be expressed as a finite simple continued fraction and used continued fractions to distinguish between rationals and irrationals. Euler then gave the nowadays standard algorithm used for converting a simple fraction into a continued fraction.

Moreover, he calculated a continued fraction expansion of √2 and gave a simple method to calculate the exact value of any periodic continued fraction and proved a theorem that every such continued fraction is the root of a quadratic equation. 34,36

In 1761, Lambert proved the irrationality of π using a continued fraction of tan x. He also generalized Euler work on e to show that both and tan x are irrationals if x is nonzero rational. 34,38,40

Lagrange used continued fractions to construct the general solution of Pell's Equation. He proved the converse of Euler's Theorem, i.e., if x is a quadratic irrational (a solution of a quadratic equation), then the regular continued fraction expansion of x is periodic. In 1776, Lagrange used 5 continued fractions in integral calculus where he developed a general method for obtaining the continued fraction expansion of the solution of a differential equation in one variable. 41,42,43

In the nineteenth century, the subject of continued fractions was known to every mathematician and the theory concerning convergents was developed. In 1813, Carl Friedrich Gauss derived a very general complex - valued continued fraction by a clever identity involving the hypergeometric function. Henri Pade defined Pade approximant in 1892. In fact, this century can probably be described as the golden age of continued fractions. Jacobi, Perron, Hermite, Cauchy, Stieljes and many other mathematicians made contributions to this field. 34,39

During the 20th century, continued fractions appeared in other fields. In 1992, for instance, the connection between continued fractions and chaos theory was studied in a paper written by Rob Corless.

6 Chapter One Definitions and Basic Concepts

Definition 1.1: 15

Let p and q be two integers where at least one of them is not zero. The greatest common divisor of p and q, denoted by gcd(p, q), is the positive integer d satisfying: 1) d divides both p and q.

2) If c divides both p and q, then c ≤ d.

Definition 1.2: 15

Two given integers p and q are called relatively prime if gcd(p, q) = 1.

Theorem 1.1: 15, p.4

Let p, q & s be integers. If p divides both q and s, then p divides qx + sy for every x & yZ.

Theorem 1.2: 15, p.7 (The Division Algorithm)

Given integers p and q, with q > 0, there exists unique integers m and r such that p = q.m + r, with 0 ≤ r < q. p is called the dividend, q the divisor, m the and r is the remainder.

Lemma 1.1: 15, p.30

Let p and q be two integers. If p = q.m+r , then gcd(p, q) = gcd(q, r).

The Euclidean Algorithm: 7 Euclidean algorithm is a method of finding the greatest common divisor of two given integers. It consists of repeated divisions. In this algorithm we apply the Division Algorithm repeatedly until we obtain a zero remainder. Since the gcd(p, q) = gcd(±p, ±q), we may assume that both p and q are positive integers with p > q.

Theorem 1.3: 15, p.29 (Euclidean algorithm)

Let p and q be two positive integers, where p > q and consider the following sequence of repeated divisions:

p q. a1  r 1 , 0  r 1  q

b r1. a 2  r 2 , 0  r 2  r 1

r1 r 2. a 3  r 3 , 0  r 3  r 2

r2 r 3. a 4  r 4 ,0  r 4  r 3 .

. .

rn2 r n  1. a n  r n ,0  r n  r n  1

rn11 r n.0 a n

Then gcd(p, q) = rn, the last non-zero remainder of the division process.

Proof:

We need to prove that the greatest common divisor of p and q is rn. Using Lemma 1.1 repeatedly, we get the following: gcd(p, q)=gcd(q, r1)=gcd(r1, r2)=gcd(r2, r3) =…=gcd(rn-1, rn)=gcd(rn, 0)

=rn.

Hence, the greatest common divisor of p and q is rn .

Theorem 1.4: 15, p.13 8 Given two integers p and q not both zero. Then the greatest common divisor of p and q is a linear combination of them. i.e. there exist two integers m and n such that gcd(p, q)=mp+nq.

Theorem 1.5: 15, p.16 p q Given two integers p and q, then & are relatively gcd( p, q) gcd( p, q) prime.

Theorem 1.6: 15, p.18 (Euclid’s Lemma)

If p and q are relatively prime and p divides qs then p divides s.

Definition 1.3: 17(Algebraic and Transcendental Numbers)

A complex number y is said to be algebraic if y is a root of a non-zero

n n1 polynomial P(x)  an x  an1x ...  a0 with integer coefficients a0, a1,

…, an . The number which is not algebraic is transcendental.

Binomial Theorem: n For any positive integer n, the expansion of (x  y) is given by: n n n n 0 n n1 1  n  1 n1 n 0 n n ni i (x  y)   x y   x y ...  x y   x y   x y 0 1 n 1 n i0  i  n n! where    is called the binomial coefficient.  i  i!(n i)!

9 Chapter Two

Finite Simple Continued Fractions

Section 2.1: What is a Continued Fraction? 1,3,4,6

Definition 2.1: A continued fraction (c.f.) is an expression of the form

b0 a0  b1 a1  b2 a2  b3 a3  a  4  where 0, 1, 2, …, b0, b1, b2, … can be either real or complex numbers.

Definition 2.2: A simple (regular) continued fraction is a continued fraction of the form 1 a  0 1 a  1 1 a  2 1 a3  a  4  where i is an integer for all i with 1, 2, 3…. . > 0.

The numbers i , i = 0, 1, 2, …. are called partial of the c.f. A simple continued fraction can have either a finite or infinite representation.

Definition 2.3: A finite simple continued fraction is a simple continued fraction with a finite number of terms. In symbols: 10 1 a  0 1 a  1 1 a  2 1  1 an1  an

It is called an nth-order continued fraction and has (n+1) elements (partial quotients).

It is also common to express the finite simple continued fraction as 1 1 1 1 a0  .... or simply as [a0 , a1,a2 ,...., an ]. a1  a2  a3  an

Definition 2.4: An infinite simple continued fraction is a simple continued fraction with an infinite number of terms. In symbols: 1 a  0 1 a  1 1 a  2 1 a3  a  4  1 1 1 It can be also expressed as a0  .... or simply as a1  a2  a3 

[a0 ,a1,a2 ,....].

Example 2.1: 1 6  1 1 1 1 a) 1 and 3 .... are infinite simple 1 7  15  1 292  1 5  1 1 5 ... continued fractions. 11 1 1 b) 1 and [1,2,6] are finite simple continued fractions. 3 1 1 1 1 6 Definition 2.5: A segment of an nth-order simple continued fraction is a continued fraction of the form [a0 ,a1,a2 ,....,ak ]where 0 ≤ k ≤ n and arbitrary k ≥ 0 if the continued fraction is infinite.

A remainder of an nth-order finite simple continued fraction is a continued fraction of the form [ar ,ar1,...,an ] where 0 ≤ r ≤ n. Similarly, [ar ,ar1,...] is a remainder of an infinite simple continued fraction for arbitrary r ≥ 0 .

Example 2.2: a) [0,1,2] is a segment of the finite simple continued fraction [0,1,2,1,4] and [2,1,4] is a remainder of it . b) [6,1,5,1] is a segment of the infinite simple continued fraction [6,1,5,1,5,1,5,...]and [5,1,5,1,5,...] is a remainder of it .

12 Section 2.2: Properties and Theorems

Every rational number can be expressed as a finite simple continued fraction. Before we prove it and explain the way of expansion, we will introduce the continued fractions by studying the relationship between Euclidean algorithm, the jigsaw puzzle (splitting rectangles into squares) and continued fractions. Jigsaw puzzle uses picture analogy to clarify how to convert a rational number into a continued fraction. The explanation of the puzzle’s steps is through the following example. 7,8

Example 2.3: Suppose we are interested in finding the greatest common divisor of 64 and 17. Using Euclidean algorithm, we have:

64  317 13 (2.1) 17 113 4 (2.2)

13  3 4 1 (2.3) 4  41 0 (2.4) Then gcd(64, 17) = 1. 64 Now, consider a 64 by 17 rectangle. 17

In terms of pictures, we split the rectangle 17 17 17 13 into 3 squares each of side length 17 and 17 only one 17 by 13 rectangle.

Next, it is clear that we can split the 17 by 17 17 17 13

13 rectangle into one square of side length 17 4 13 and only one 13 by 4 rectangle.

13 13 Similarly, split the 13 by 4 rectangle into 3 17 4 4 4 squares each of side length 4 and a 4 by 1 rectangle.

13 Finally, we can place 4 squares, each of side 17 1 4 4 4 length 1, inside the 4 by 1 rectangle with no . remaining rectangles.

We can notice that each divisor q in the Euclidean algorithm represents the length of the side of a square. For instance, the divisor 17 in equation (2.1) represents the length of the sides of the squares that we obtain from the first splitting step. Moreover, gcd(64, 17) is the length of the side of the smallest square which equals 1. 64 13 Now, divide equation (2.1) by 17 to get:  3  17 17 17 4 Also, divide equation (2.2) by 13 to obtain: 1 13 13 13 1 4 Repeat in the same way for equations (2.3) and (2.4):  3  and  4 4 4 1 Then, write each proper fraction in the previous equations in terms of its reciprocal as follows: 64 1  3 (2.5) 17 17 ( ) 13 17 1  1 13 (2.6) 13 ( ) 4 13 1 1  3  3 (2.7) 4 4 4 ( ) 1 Substitute equation (2.7) into equation (2.6) to obtain the following: 14 17 1 1 1 (2.8) 13 3  4 Then, substitute equation (2.8) into equation (2.5) to get:

64 1  3   [3,1,3,4] 1 17 1 1 3  4 64 This is the continued fraction representation of the rational number . 17 64 Note that by writing  [3,1,3,4] , we do not mean an equality, but just a 17 representation of the rational number by its continued fraction [3,1,3,4] .

This expression relates directly to the geometry of the rectangle as squares with the jigsaw pieces as follows: 3 squares each of side length 17, 1 square of side length 13, 3 squares each of side length 4 and 4 squares each of side length 1. So, it’s clear that the partial quotients of the continued fraction [3,1,3,4] represent the number of squares that result from the splitting steps.

However, there is no need to use picture analogy each time we want to express a rational number as a continued fraction. The expansion of rational numbers into continued fractions is related to Euclidean algorithm as we’ve shown in the previous example. This relation will be studied closely in the proof of Theorem 2.2. p Now, to express any rational number as a continued fraction, we q proceed in this manner. We split the rational number into a quotient “ a0 ” a and a proper fraction, say . If a = 1 or b = 1, stop. Otherwise, repeat the b 15 1 a process by considering the reciprocal of the proper fraction instead b b ( ) a p of . Again, split into a quotient “ a ” and a proper fraction, say q 1

1 again. Repeat this process until we get a proper fraction , which is b always the case for any rational number. p It is clear that if the rational number is positive and less than 1, then the q continued fraction begins with zero, i.e., a0  0. Moreover, if the rational number is negative, then the continued fraction is [a0 ,a1,a2,....,an ] where a0  0 and a1,a2 ,...an  0 .

Example 2.4: 14 Expand the rational number into a continued fraction. 19 Solution: 14 Since is less than 1, 19 14 1 then and  0  . 19 19 14 19 5 14 1 But  1 , so  0  . 19 5 14 14 1 14 5 1 1 Also,   14 14 4 2  5 5 14 1 Therefore,  0  19 1 1 4 2  5 4 4 1 1 Repeating the same steps for , we obtain:   5 5 1 5 1 4 4 16 14 1  0   [0,1,2,1,4] Thus, 19 1 1 1 2  1 1 4 1 We stop here since the last proper fraction has a numerator of 1. 4 However, looking at the last partial quotient “4” of the continued fraction, 1 it can be written as 4  3  . So, the continued fraction expansion 1 [0,1,2,1,4]can be also written as: 14 1  0   [0,1,2,1,3,1] 19 1 1 1 2  1 1 1 3  1 14 As a result, the continued fraction expansion of the rational number has 19 two forms which are obtained by changing the last quotient.

Example 2.5: 59 Express the rational number as a continued fraction. 46

Solution: Applying the previous steps, we get:

59 13 1 1 1 1 1 1 1 1 1 1 1 1 1 46 46 46 7 1 1 1 1 3 3 3 3 3 13 13 13 6 1 1 1 1 1 7 7 7 1 1 6 6 =[1,3,1,1,6].

Example 2.6: 17 7 Write the rational number  as a continued fraction. 13 Solution:

7 6 1 1   1  1  1  [1,2,6] 13 13 13 1 2  6 6 The Continued Fraction Algorithm: 4,9

This algorithm is a systematic approach that is used to find the continued fraction expansion of any rational number. Let y be any non-integer rational number. To find its continued fraction expansion, we follow the next steps.

Step 1: Set y  y0 . The first partial quotient of the continued fraction is the greatest integer less than or equal y0 . (i.e., a0 [[y0 ]] ), where [[ . ]] is the greatest integer function. 1 Step 2: Define y1  and set a1 [[y1]]. y0 [[y0 ]]

As long as y j is non-integer, continue in this manner:

1 y2  , a2  [[y2 ]], y1 [[y1 ]]

. . 1 yk  , ak [[yk ]], where yk [[yk ]]  0 . yk1 [[yk1 ]]

Step 3: Stop when we find a value yk  N.

Note 2.1: 18 This algorithm is also true for any real number. In this case, the process may continue indefinitely. This idea will be illustrated in Chapter Three.

Example 2.7: 315 Calculate the continued fraction expansion of using the continued 201 fraction algorithm.

Solution: 315 315 Let y 1.567164179 . Then ay[[ ]]  [[ ]]  1. 0 201 00201 1 1 1 201 y     1.763157895, a [[y ]] 1 1 yy[[ ]]315 315 315 114 1 1 00 [[ ]] 1 201 201 201 1 1 1 114 y     1.310344828, a [[y ]] 1 2 y [[y ]] 201 201 201 87 2 2 1 1 [[ ]] 1 114 114 114 1 1 1 87 y      3.222222222 , a [[y ]]  3 3 y [[y ]] 114 114 114 27 3 3 2 2 [[ ]] 1 87 87 87 1 1 1 27 y      4.5, a  [[y ]]  4 4 y [[y ]] 87 87 87 6 4 4 3 3 [[ ]] 3 27 27 27 1 1 1 6 y      2 , a [[y ]]  2 5 y [[y ]] 27 27 27 3 5 5 4 4 [[ ]]  4 6 6 6

We stop here since yN5 2 . Thus, [1,1,1,3,4,2] is the continued 315 fraction representation of . 201 What about the converse? 8

Given a continued fraction representation of a number y, we find y by using the following relationship repeatedly: 1 [a ,a ,a ,....,a ,a ]  [a ,a ,a ,....,a  ] 0 1 2 n1 n 0 1 2 n1 a n Example 2.8: 19 Find the rational number who has the continued fraction representation [2,2,1,2,1].

Solution: 1 1 4 1 [2,2,1,2,1]  [2,2,1,2  ]  [2,2,1,3]  [2,2,1 ]  [2,2, ]  [2,2  ] 4 1 3 3 ( ) 3 3 11 1 4 26  [2,2  ]  [2, ]  [2  ]  [2  ]  11 4 4 ( ) 11 11 4 Theorem 2.1: 2, p.553

Every finite simple continued fraction represents a rational number.

Proof: [a ,a ,a ,....,a ] th Let 0 1 2 n be a given n - order finite simple continued fraction. We show that this continued fraction represents a rational number using induction on the number of partial quotients.

1 a0a1 1 If n = 1, then [a0 ,a1] = a0  = . a1 a1 a a 1 Since ₀ and are integers, then 0 1 is a rational number. a1

Now assume any finite simple continued fraction with k < n partial quotients represents a rational number. Then: 1 1 [a , a , a ,...., a ]  a   a  0 1 2 k 0 1 0 , a  Y 1 1 a  2 1 a  3 1 ...  1 ak1  ak

Where 20 1 Y  a   [a , a ,....,a ]. 1 1 1 2 k . a  2 1 a  3 1 ...  1 ak1  ak [a ,a ,....,a ] Since 1 2 k is a finite simple continued fraction with k partial d d quotients, it represents a rational number, say . So, Y  , f  0. f f 1 1 f a d  f Thus, [a , a , a ,...., a ]  a   a   a   0 which is 0 1 2 k 0 Y 0 d 0 d d f a rational number since ₀, d and f are integers. [a ,a ,a ,....,a ] So, any finite simple continued fraction 0 1 2 n represents a rational number for any n N.

Theorem 2.2: 2, p.553 & 3, p.10

Every rational number can be represented as a finite simple continued fraction in which the last term can be modified so as to make the number of terms in the expansion either even or odd.

Proof: p Let , q > 0 be any rational number. By the Euclidean algorithm q p  q.a  r ,0  r  q 1 1 1 (2.9) q  r .a  r ,0  r  r 1 2 2 2 1 (2.10)

r1  r2.a3  r3 ,0  r3  r2

r2  r3.a4  r4 ,0  r4  r3 . .

rn3  rn2.an1  rn1,0  rn1  rn2 r  a .r  0 n2 n n1 21

The quotients a2 ,a3,a4 ,...an and the remainders r1,r2 ,r3,...,rn1 are positive integers, while 1 can be a positive integer, negative integer or zero. Now, dividing equation (2.9) by q and then taking the reciprocal of the p r 1 proper fraction we get:  a  1  a  ,0  r  q q 1 q 1 q 1

r1

Also divide equation (2.10) by and take the reciprocal of the proper fraction to get: q r 1  a  2  a  ,0  r  r 2 2 2 1 (2.11) r1 r1 r1

r2

Repeating the same process to each equation in the above Euclidean algorithm, we have: r r 1 1  a  3  a  , 0  r  r 3 3 3 2 (2.12) r2 r2 r2

r3 r r 1 2  a  4  a  ,0  r  r 4 4 4 3 (2.13) r3 r3 r3

r4

. . r r 1 n3  a  n1  a  ,0  r  r n1 n1 n1 n2 (2.14) rn2 rn2 rn2

rn1 r n2  a r n n1 q r Now, substituting and each of i 1 back into equations (2.11) through r r 1 i (2.14) yields:

22 p 1 1 1  a   a   a  q 1 1 1 1 1 1 a  a  a  2 r 2 1 2 1 1 a  a  3 r 3 1 ( 2 ) a  r 4 r 3 ( 3 ) r4

Continue in the same manner to get: p 1 1  a   a  q 1 1 1 1 a  a  2 1 2 1 a  a  3 1 3 1 a  a  4 1 4 1 ... ... 1 1 a  a  n1 r n1 a ( n2 ) n rn1

= [a1,a2 ,...,an ].

Thus, every rational number can be represented as a finite simple continued fraction.

In fact, we can always modify the last partial quotient n of this representation so that the number of terms is either even or odd. 1 1 1   If n = 1, then 1 1 an1 1 an1  an1  an 1 p and  [a ,a ,...,a ,a ]  [a ,a ,...,a 1]. q 1 2 n1 n 1 2 n1 1 1 1   Else, if n > 1, then 1 1 1 a  a  a  n1 a n1 (a 1) 1 n1 1 n n (a 1)  n 1 p and [a ,a ,...,a ,a ] [a ,a ,...,a ,a 1,1]. q 1 2 n1 n 1 2 n1 n

23 Theorem 2.3: 3, p.12

Let p and q be two integers such that p > q > 0. Then [a0 , a 1 , a 2 ,..., ann 1 , a ] p q is a continued fraction representation of if and only if has q p

[0,a0 , a 1 , a 2 ,..., ann 1 , a ] as its continued fraction representation.

Proof: 1 p a  Since p > q > 0, > 1 and equals 0 1 where ₀ q a  1 1 a  2 1 a  3 1 ...  an p p is the greatest integer less than =[[ ]] > 0. q q The reciprocal of is

q 1 1   0   [0, a , a , a ,..., a ] 1 1 0 1 2 n p a  a  0 1 0 1 a  a  1 1 1 1 a  a  2 1 2 1 a  a  3 1 3 1 ...  ...  an an q Conversely, since p > q > 0, 0 < < 1 and equals p q 1 1 0 p 1 = 1 a  a  0 1 0 1 a  a  1 1 1 1 a2  a  1 2 a  1 3 1 a3  ... 1 a ...  n an q The reciprocal of is p 24 p 1 1   a   [a ,a ,a ,...,a ]. q 1 0 1 0 1 2 n a  1 1 1 a  a  0 1 2 1 a  a  1 1 3 1 a  ...  2 1 a a  n 3 1 ...  an

Theorem 2.4: 5, pp.82  83

The continued fraction [a0 ,a1,a2 ,..., an1,an ] and its reversal

[an ,an1,an2 ,...,a1,a0 ] with a0 > 0 have the same numerators.

Proof: This theorem is proved by Euler. See 5 .

For example, the continued fractions [5,3,2,4] and [4,2,3,5] have the same numerator “164”.

25

Section 2.3: Convergents In order to have a thorough understanding of continued fractions, we must study some of their properties in details.

Consider the continued fraction representation [2,2,7] of the rational 37 number . The segments of this continued fraction are: 15 1 1 [2]  2, [2,2]  2  , [2,2,7]  2  2 1 2  7 Since each segment is a finite simple continued fraction, it represents a rational number. These segments are called convergents of the continued fraction .

Definition 2.6: 4,9 [a ,a ,...,a ] Let 0 1 n be a finite simple continued fraction representation of a p rational number . Its segments: q 1 1 c  [a , a ]  a  c2  [a0 , a1, a2 ]  a0  c0  [a0 ]  a0 , 1 0 1 0 , 1 , a1 a1  a2 1 c  [a , a , a ,..., a ]  a  …, n 0 1 2 n 0 1 a  1 1 a  2 1 ...  an

th are all called convergents of the continued fraction with ck is the k convergent, k = 0, 1, . . . , n. 26

Note that we have n+1 convergents and each convergent ck represents a

pk rational number of the form ck  , where pk and qk are integers with qk p c  . n q p We shall use the representation of a convergent c  [a ,a ,..., a ] and k k 0 1 k q k interchangeably to mean the same thing.

Example 2.9: Find all of the convergents for the continued fraction [3,5,1,7].

Solution: c0  [3]  3 1 16 c  [3,5]  3  1 5 5 1 1 19 c  [3,5,1]  3   3  2 1 5  6 6 1 1 1 1 1 8 149 c  [3,5,1,7]  3   3   3   3   3   3 1 1 7 47 5  5  5  47 47 1 8 1 8 8 7 7 rd 149 Note that the 3 convergent c3  represents the fraction itself. 47 The following theorem gives a recursion formula to calculate the convergents of a continued fraction.

Theorem 2.5: 1, p.21& 4, p.7 (Continued Fraction Recursion

Formula)

Consider the continued fraction [a0,a1,...,an ]of a given rational p 1, p  0 p  a p  p number. Define 1 2 . Then k k k1 k2 , for k = 0, 1, 2, q1  0, q2 1 qk  ak qk1  qk2 27

…, n, where p0, p1, p2, …, pn are the numerators of the convergents of the given continued fraction and q0, q1, q2, …, qn are their denominators.

Proof: We prove this theorem using induction on k.

For k = 0, we have:

p0 a0 a0.1 0 a0.p1  p2 c0   a0    q0 1 a0.0 1 a0.q1  q2

p  a p  p q  a .0 1 Therefore, 0 0 1 2 and 0 0

For k = 1, we have:

p1 1 a0a1 1 a1.a0 1 a1.p0  p1 c1   a0     q1 a1 a1 a1.1 0 a1.q0  q1

p  a .p  p q  a .q  q Then, 1 1 0 1 and 1 1 0 1

pk  ak pk1  pk2 Thus, the formula is true for k = 0, 1. qk  ak qk1  qk2

Assume the theorem is true for k = 2, 3, …, j, where j < n.

pk ak pk1  pk2 i.e. ck   , for k = 2, 3, …, j (2.15) qk ak qk1  qk2

So, pk  ak pk1  pk2 and qk  ak qk1  qk2

Now, we prove that the formula is true for the next integer j+1. 28 1 1 c  [a ,a ,..., a ,a ]  a   a  j1 0 1 j j1 0 1 0 1 a  a  1 1 1 1   1 1 a j  (a j  ) a j1 a j1 1  [a0 , a1,..., a j  ] . a j1

This suggests that we can calculate cj+1 from the formula of cj obtained from equation (2.13) after replacing k by j. Before we continue, we must make sure that the values of p j1, p j2 ,q j1,q j2 won’t change if aj in equation (2.13) is replaced by another number. To do this, first replace k in the equation by j-1, and then by j-2, j-3 to get:

p j1 a j1.p j2  p j3 p j2 a j2.p j3  p j4 c j1   , c j2   q j1 a j1.q j2  q j3 q j2 a j2.q j3  q j4

p j3 a j3.p j4  p j5 c j3   q j3 a j3.q j4  q j5

We notice that pj-1 and qj-1 depend only on aj-1 while the numbers

p j2 , p j3,q j2 ,q j3 depend upon the preceding a’s, p’s and q’s. Thus, the numbers depend only on a , a ,..., a and not on a . 0 1 j1 j

This implies that they will remain the same when we replace aj by 1 a j  . a j1 1 Back to equation (2.13), replace aj by a j  to get: a j1

1 a j a j1 1 (a j  ).p j1  p j2 ( ).p j1  p j2 a j1 a j1 c j1   (2.16) 1 a j a j1 1 (a j  ).q j1  q j2 ( ).q j1  q j2 a j1 a j1

Multiply the numerator and denominator of equation (2.14) by a j1 and rearrange the terms to obtain: 29

(a j a j1 1).p j1  a j1 p j2 a j1(a j p j1  p j2 )  p j1 c j1   (a j a j1 1).q j1  a j1q j2 a j1(a j q j1  q j2 )  q j1

But from our assumption, a j p j1  p j2  p j and a jq j1  q j2  q j .

a j1 p j  p j1 Then, c j1  . a j1q j  q j1

Thus, the formula is true for k = j+1. So, by induction, the theorem is true for 0 ≤ k ≤ n.

Note 2.2: p p 1) 1 and 2 are not convergents. p , p , q and q are just initial q q -1 -2 -1 -2 1 2

values used to calculate c0 and c1.

2) qk > 0 , k = 0, 1, …, n.

3) Since ak > 0 for 1 ≤ k ≤ n and qk > 0 for 0 ≤ k ≤ n, it follows that

qk  qk1 , k = 2, …, n .

Example 2.10: Find the convergents of the continued fraction representation of the 320 rational number using Continued Fraction Recursion Formula. 171 Solution: 320 First of all, the continued fraction representation of is [1,1,6,1,3,2,2] 171 and we have a0 1,a1 1,a2  6,a3 1,a4  3,a5  2,a6  2.

p1 1, p2  0 With , calculate pk and qk using the recursion formula. q1  0, q2 1

pk  ak pk1  pk2 , for k = 0, 1, 2, …, 6. qk  ak qk1  qk2

30 For k = 0: For k = 1:

p0  a0 p1  p2 11 0 1 p1  a1 p0  p1 111  2 q  a q  q 1 0 1 1 q  a q  q 11 0 1 0 0 1 2 1 1 0 1

For k = 2: For k = 3:

p2  a2 p1  p0  6 2 1 13 p3  a3 p2  p1 113  2 15 q  a q  q  611  7 q  a q  q 1 7 1  8 2 2 1 0 3 3 2 1

For k = 4: For k = 5:

p4  a4 p3  p2  315 13  58 p5  a5 p4  p3  258 15 131 q  a q  q  38  7  31 q  a q  q  231 8  70 4 4 3 2 5 5 4 3

For k = 6:

p6  a6 p5  p4  2131 58  320 q  a q  q  2 70  31 171 6 6 5 4

p0 1 p1 2 p2 13 p3 15 Thus, c0   1, c1    2 , c2   , c3   , q0 1 q1 1 q2 7 q3 8

p4 58 p5 131 p6 320 c4   , c5   , c6   . q4 31 q5 70 q6 171

The last convergent, c6 in this example, must be equal to the rational number the continued fraction represents.

However, a convergent table can be used to save time in calculating pk and qk. Table 2.1 explains the manner.

31

Table 2.1

k -2 -1 0 1 2 … … … n

ak a0 a1 a2 … … … an

pk p-2= 0 p-1= 1 p0 p1 p2 … … … pn

qk q-2= 1 q-1=0 q0 q1 q2 … … … qn

ck c0 c1 c2 … … … cn

The first row of the table is filled with the values of k that always range from -2 to n. In the second row, we write the partial quotients of the given continued fraction. Now, to fill the 3rd and 4th rows, we write the values p-2 = 0, q-2 = 1, p-1 = 1, q-1 = 0 under k = -2, k = -1, respectively. Then we compute the values of pk’s and qk’s using the recursion formula. For example, to find p1 and q1 , we follow the arrows, (look at the table): a a1 1

p0 q q p - 1 -1 0 This manner gives us the following equations which we obtain when we set k = 1 in the recursion formula:

p1 a 1 p 0 p 1 q a q q 1 1 0 1

In the same process we find pk and qk for each value of k. p The last row contains the convergents c ’s, where ck ,0  k  n . k k q k Back to our example, the table is filled in the same manner and the result is: 32

Table 2.2

k -2 -1 0 1 2 3 4 5 6

ak 1 1 6 1 3 2 2

pk 0 1 1 2 13 15 58 131 320

qk 1 0 1 1 7 8 31 70 171 1 2 13 15 58 131 320  1  2 ck 1 1 7 8 31 70 171

Theorem 2.6: 10, p.358 (Difference of Successive Convergents Theorem) (1)k1 ck  ck1  ,1 k  n qk qk1

To prove this theorem we need the following lemma.

Lemma 2.1: 4, p.7 p Let k be the kth convergent of the continued fraction [a ,a ,...,a ], q 0 1 n k where pk and qk are defined as in Theorem 2.5. Then: k pk11 q k p k q k (  1) ,  1  k  n .

Proof: This lemma will be proved by induction on k and using the formula that we’ve proved in the previous theorem. Direct calculations show the theorem is true for k = -1, 0 and 1.

1 For k = -1: p2q1  p1q2  0.0 1.1 1 (1)

0 For k = 0: p1q0  p0q1 1.1 a0.0 1  (1) 33

1 For k = 1: p0q1  p1q0  a0a1 (a0a1 1).1  a0a1  a0a1 1  1  (1)

s Assume the lemma is true for some integer s < n, i.e. ps1qs  psqs1  (1) .

Now, for k = s+1, we have:

psqs1  ps1qs  ps (as1qs  qs1)  (as1 ps  ps1)qs

 psas1qs  psqs1  as1 psqs  ps1qs  psqs1  ps1qs  1.( ps1qs  psqs1)

 1.(  1)ss  (  1) 1 .

Therefore, the formula is true for k = s+1 and so by induction the lemma is true for 1 kn  .

Proof of Theorem 2.6: For 1 ≤ k ≤ n:

pk pk1 pk qk1  pk1qk pk1qk  pk qk1 ck  ck1      qk qk1 qk qk1 qk qk1 (1)k (1)k1 (1)k1 Using Lemma 2.1, ck  ck1     . qk qk1 qk qk1 qk qk1

Example 2.11: Verify Lemma 2.1 using the convergents of the continued fraction [1,1,6,1,3,2,2].

Solution:

Using the values of pk’s ={1, 2, 13, 15, 58, 131, 320} and qk’s ={1, 1, 7, 8, 31, 70, 171} obtained in Example 2.10, we get: p q  p q  00 11 1 (1)1 For k = -1: 2 1 1 2 0 For k = 0: p1q0  p0q1 1110 1  (1) p q  p q 11 21 1 (1)1 For k = 1: 0 1 1 0 2 For k = 2: p1q2  p2q1  27 1311 (1) 34 p q  p q 138 157  1 (1)3 For k = 3: 2 3 3 2 4 For k = 4: p3q4  p4q3 1531 588 1 (1)

5 For k = 5: p4q5  p5q4  5870 13131  (1)

6 For k = 6: p5q6  p6q5 131171 32070  (1)

k Thus, pk1qk  pk qk1  (1) for -1 ≤ k ≤ 6.

Corollary 2.1: 10, p.358 k (1) ak ck  ck2  , 2 ≤ k ≤ n. qk qk2

Proof: (1)k1 (1)k2 By Theorem 2.6, ck  ck1  and ck1  ck2  qk qk1 qk1qk2

Adding these two equations, we get: (1)k1 (1)k2 (1)k1 q  (1)k2 q (1)k2 (q  q ) c  c    k2 k  k k2 k k2 q q q q q q q q q q k k1 k1 k2 k k1 k2 k k1 k2 But from the continued fraction recursion formula, qk  qk2  ak qk1 k2 k2 k (1) (ak qk1) (1) (ak ) (1) (ak ) Thus, ck  ck2    . qk qk1qk2 qk qk2 qk qk2

Corollary 2.2: 2, p.561

For 1 ≤ k ≤ n, pk and qk are relatively prime.

Proof:

k Let d = gcd(pk, qk). Then d divides pk1qk  pk qk1  (1) ,1 k  n.

Hence, d=1=gcd(pk, qk). So, pk and qk are relatively prime for all 1kn. To illustrate this property, consider the convergents of the continued fraction in Example 2.10. We find that gcd(p1, q1) = gcd(2, 1) = 1; gcd(p2, q2) = gcd(13, 7) = 1, 35 gcd(p3, q3) = gcd(15, 8) = 1; gcd(p4, q4) = gcd(58, 31) = 1, gcd(p5, q5) = gcd(131, 70) = 1; gcd(p6, q6) = gcd(320, 171) = 1.

Thus, pk and qk are relatively prime for each value of k, where 1 ≤ k ≤ 6.

Example 2.12:

Given [1,1,1,3,1,2] is the continued fraction representation of the rational 39 number , find the convergents. 25 Solution: Applying Theorem 2.5, we find the convergents of : 3 11 14 39 c0 = 1, c1 = 2, c2 = , c3 = , c4 = , c5 = . 2 7 9 25 Notice that: 3 1) The even convergents 1, , form an increasing sequence and 2

approach the actual value from below, i.e. c0 < c2 < c4 .

2) The odd convergents 2, , form a decreasing sequence and

approach the actual value from above, i.e. c1 > c3 > c5 .

3) The convergents ck approach the actual value as k increases, where

0 ≤ k ≤ 5. Moreover, they are alternatively less than and greater than

except the last convergent c5. Therefore, we conclude that c0 < c2 < c4 <

= c5 < c3 < c1. Figure 2.1 illustrates these notes.

c1 c3 c5 39

25 c4 c2 c 0 Figure 2.1 These notes lead to the following theorem. 36 Theorem 2.7: 2, p.562

Let c0, c1, …, cn be the convergents of the continued fraction [a0,a1,...,an ] .

Then even–numbered convergents form an increasing sequence and odd- numbered convergents form a decreasing sequence. Moreover every odd- numbered convergent is greater in value than every even-numbered convergent. In other words: c2m < c2m+2, c2m+3 < c2m+1 and c2j < c2r+1 , m, j, r ≥ 0.

Proof: 2k ( 1) a2k By Corollary 2.1, c2kk c 2 2 ,1 k  . (2.17) qq2kk 2 2

Since ak, qk, qk-2 > 0, then cc2kk 2 2 0 . Hence, cc 2kk 2 2 (2.18) Thus, the even–numbered convergents form an increasing sequence c0  c2  c4  .... 21k  ( 1) a21k  Similarly, by Corollary 2.1, c2kk 1 c 2 1 ,1 k  qq2kk 1 2 1 and so c2k1  c2k1 (2.19) Thus, the odd–numbered convergents form a decreasing sequence c1  c3  c5  .... Finally, put k = 2s + 1, s ≥ 0 in Theorem 2.6, we obtain 2s ( 1) 2s cc2ss 1 2   0 . With q2s1,q2s ,(1)  0 , we get qq2ss 1 2

c2s  c2s1 (2.20) From (2.18), (2.19) & (2.20):

c0 < c2 < c4 < …< c2k < c2k+1 < c2k-1 < ... < c3 < c1, if n = 2k+1 and

c0 < c2 < c4 < …< c2k < c2k-1 < c2k-3 < ... < c3 < c1, if n = 2k 37

Section 2.4: Solving Linear Diophantine Equations Many puzzles, enigmas and trick questions lead to mathematical equations whose solutions are required to be integers. Such equations are called Diophantine equations, named after the Greek mathematician Diophantus who wrote a book about them.

Definition 2.7: 1,2,12

Diophantine Equation is an algebraic equation in one or more unknowns with integral coefficients such that only integral solutions are sought. This type of equations may have no solution, a finite number or an infinite number of solutions.

Example 2.13: The following equations are Diophantine equations, where integral solutions are required for x, y and z. 3x  5y  7 , x2  y2 1, x2  y2  z 2 , x2  3y2 1.

Definition 2.8: 2

Linear Diophantine Equation “LDE” in two variables x and y is the simplest case of Diophantine equations and has the form ax  by  c where a, b and c are integers.

Example 2.14:

3x  5y 1, 6x  4y  2,  5x  5y  8 are linear Diophantine equations in two variables. 38 In this section, we are interested in solving linear Diophantine equations in two variables. i.e., finding integral solutions of ax  by  c . If a and b are both zeros, then the equation is either trivially true when c = 0 or trivially false when c ≠ 0. Moreover, if one of a or b equals zero, then the case is also trivial. So we omit these two cases and assume that both a and b are nonzero integers. Geometrically, this equation represents a line in the Cartesian plane that is not parallel to either axis. Solutions of the equation are the points on the line with integral coordinates. Points with integral coordinates are called lattice points.

However, does every linear Diophantine equation have an integral solution? If not, what are the conditions necessary for a LDE to have a solution? The following theorem answers these questions.

Theorem 2.8: 14, p.12

Let a, b & c be integers with ab ≠ 0. The linear Diophantine equation

is solvable if and only if gcd(a, b) divides c. If (x0, y0) is a particular solution of the LDE, then all its solutions are given by: b a (x, y)  (x  t, y  t), where t is an arbitrary integer. 0 gcd(a,b) 0 gcd(a,b)

Proof: First, we show that if the LDE is solvable, then gcd(a, b) divides c.

Suppose (x1, y1) is a solution of . Then, ax1  by1  c . 39 But gcd(a, b) divides both a and b, then , by Theorem 1.1, gcd(a, b) divides ax1  by1 . i.e. gcd(a, b) divides c. Next, we want to prove that if gcd(a, b) divides c, then the LDE ax  by  c is solvable.

Suppose that gcd(a, b) divides c. Then c = k. gcd(a, b) for some integer k. Now, by Theorem 1.4, there exists two integers m and n such that ma  nb  gcd(a,b).

Multiply both sides of this equation by k to get: kma knb  kgcd( a , b )  c .

Thus x0 = km, y0 = kn is a solution of the LDE . Therefore, the

LDE is solvable.

Now assume that (x0, y0) is a particular solution of , then b a x  x0  t and y  y0  t,t  Z also satisfy the LDE: gcd(a,b) gcd(a,b) b a ab ab axbyax  ()()  tby   tax   tby   t 0gcd(a , b ) 0 gcd( a , b ) 0 gcd( a , b ) 0 gcd( a , b )

 ax0  by0  c. b a Thus, (x  t, y  t) is a solution for any integer t. 0 gcd(a,b) 0 gcd(a,b)

Finally, we want to prove that any solution (x′, y′) of the LDE b a is of the form (x  t, y  t) for some integer t. 0 gcd(a,b) 0 gcd(a,b)

Since (x0, y0) and (x′, y′) are solutions of , then:

ax0  by0  c and ax'by' c . That is ax0 by0  ax'by'.

Hence, a(x'x0 )  b(y0  y') (2.21) Dividing both sides of this equation by gcd(a,b) , we have: a b (x'x )  (y  y') gcd(a,b) 0 gcd(a,b) 0 40 ab Note that a&  b  Z are relatively prime by gcd(a , b )11 gcd( a , b )

Theorem 1.5. So, we obtain a1()() x x 0  b 1 y 0  y  This shows that b1 divides a10() x x . But, since gcd(ab11 , ) 1, then by (x'x ) Theorem 1.6, divides 0 . b Hence, x'x  b t  t,t Z . (2.22) 0 1 gcd(a,b) b That is x' x  t. 0 gcd(a,b) a Similarly, is y' y  t. 0 gcd(a,b) ba Thus, every solution (x t , y  t ), t  Z of the linear 00gcd(a , b ) gcd( a , b )

Diophantine equation is of the desired form.

Note 2.3: We conclude from this theorem that every solvable linear Diophantine equation ax  by  c has infinitely many solutions. They are given by the general solution: b a x  x0  t and y  y0  t, where t is an arbitrary gcd(a,b) gcd(a,b) integer. By giving different values to t, we can find any number of particular solutions.

Corollary 2.3: 14, p.13 Suppose that gcd(a,b) = 1. Then the LDE is solvable for all integers c. Moreover, if (x0, y0) is a particular solution, then the general solution is x = x0 + bt, y  y0  at,t Z. 41

Example 2.15: Determine whether the following LDE’s are solvable. a) 6x 18y  30 b) 2x  3y  7 c) 6x  8y 15 d) 59x  29y  5

Solution: a) gcd(6,18) = 6 which divides 30, then the LDE is solvable. b) gcd(2,3) = 1, so is solvable. c) gcd(6,8) = 2, but 2 does not divide 15, then is not solvable. d) gcd(59,29) = 1, so is solvable.

How to find a particular solution to the LDE ax  by  c ?

It is not difficult to find a particular solution. One of the methods that are used is the Euclidean Algorithm method. 2,16 To find a particular solution to a solvable LDE ax  by  c , we follow these steps. 1) Step 1: Write (a,b) as a linear combination of a and b. That is:

ar0  bs0  gcd(a,b), r0 and s0 are integers.

2) Step 2: multiply both sides of this equation by c and then divide it by r  c s  c gcd(a, b): a( 0 )  b( 0 )  c . gcd(a,b) gcd(a,b) r  c s  c 3) Step 3: we obtain ( x  0 , y  0 ) as a particular solution 0 gcd(a,b) 0 gcd(a,b)

of the linear Diophantine equation.

42 LDE’s were known in ancient China and India as applications to astronomy and puzzles. The following puzzle is due to the Indian mathematician Mahavira (ca. A.D. 850).

Example 2.16: Twenty-three weary travelers entered the outskirts of a lush and beautiful forest. They found 63 equal heaps of plantains and seven single fruits, and divided them equally. Find the number of fruits in each heap and the number of fruits received by each traveller.

Solution: Let x denote the number of fruits in a heap and y denote the number of fruits received from each traveller. Then we get the linear Diophantine equation: 63x  7  23y i.e. 63x  23y  7 x and y must be positive, so we are looking for positive integral solutions of the LDE.

Since gcd(63, 23) = 1, then, by Corollary 2.3, the LDE is solvable. To find a particular solution, we apply the Euclidean Algorithm: 63  22317 (2.23)

23 117  6 (2.24)

17  26  5 (2.25) 6 15 1 (2.26)

5  51 43 Now, use equations (2.21), (2.22), (2.23) and (2.24) in reverse order to get:

1  6 15  6 1(17  2 6)  3 6 117  3 (23 117) 117

 3 23  417  3 23  4 (63  2 23)  11 23  4 63

Thus, 63(4)  23(11) 1. Multiplying both sides of this equation by -7, we have: 63(47) 23(117)  7 .

That is: 63(28) (23)(77)   7 .

Therefore, (28, 77) is a particular solution of 63x  23y  7 .

By Corollary 2.3, the general solution of the LDE is: (x, y)  (28  23t,77 63t) , t is arbitrary integer.

Finally, since x > 0 and y > 0, then:

28  23t  0 and 77 63t  0 28 77 t  1.217 and t   1.222 23 63 So, (x, y)  (28  23t,77 63t) , where t is an integer less than or equal 1, is a positive integral solution of the LDE 63x  7  23y .

Continued Fractions and Linear Diophantine Equations 1,2,13

Another way to find a particular solution to a solvable LDE ax  by  c is the continued fraction method. Our approach to explain this method will be a step-by-step process until we’ll be able to find integral solutions to any solvable LDE of the form ax by  c . This method depends on the formula stated in Lemma 2.1. 44 > Solving the LDE ax by 1; a & b are positive relatively prime integers. a To solve this LDE, we express as a finite simple continued fraction. b a  [a ,a ,...,a ,a ] b 0 1 n1 n

Then we calculate the convergents c0, c1, c2, …, cn-1 ,cn. The last two

pn1 pn convergents cn1  and cn  with the relation stated in Lemma 2.1 qn1 qn

n are the key to the solution: pn1qn  pnqn1  (1)

n With pn = a and qn = b we have: bpn1  aqn1  (1)

Or

nn1 a( 1) qnn11  b (  1) p  1 Comparing this equation with the LDE , we conclude that:

nn1 (x0 (  1) qnn 1 , y 0  (  1) p 1 ) is a particular solution of ax by 1.

Therefore, if n is even, then (,)(,)x0 y 0 qnn 1 p 1 and if n is odd, then

(,)(,)x0 y 0 qnn 1 p 1 . We have four cases  ax  by 1 according to the sign of both a and b:

Case 1: ab0& 0 Equation: nn1 Solution: (,x0 y 0 )((1)  qnn 1 ,(1)  p 1 )

Case 2: ab0& 0 Equation: ax by 1 nn11 Solution: (,x0 y 0 )((1)  qnn 1 ,(1)  p 1 )

Case 3: ab0& 0 Equation: ax  by 1 nn Solution: (,x0 y 0 )((1)  qnn 1 ,(1)  p 1 ) 45

Case 4: ab0& 0 Equation: ax  by 1 nn1 Solution: (,x0 y 0 )((1)  qnn 1 ,(1)  p 1 )

Example 2.17: Solve the LDE 204x 91y 1using continued fraction method.

Solution:

First of all, gcd(204 , 91) = 1, then the LDE is solvable. To find a particular solution, we represent 204 as a finite simple continued 91 204 fraction.  [2,4,7,3] 91 Then we construct the convergent table as shown in Table 2.3. From this table: n = 3, pn-1 = p2 = 65 and qn-1 = q2 = 29.

Table 2.3 k -2 -1 0 1 2 3

ak 2 4 7 3

pk 0 1 2 9 65 204

qk 1 0 1 4 29 91

2 9 65 204 ck  2 1 4 29 91

Thus, a particular solution to the LDE is: 2 x0  (1)  29  29 2 y0  (1)  65  65

Finally, by Corollary 2.3, the general solution is: x29  (  91) t  29  91 t , t is an arbitrary integer. yt65 204 46 Now, what if we replace the number 1 in any LDE in the cases above by another integer “c”? In other words, what is the particular solution of the LDE ax  by  c , gcd(a,b) 1?

> Solving the LDE ax  by  c , where a, b and c are integers, .

The first step in solving this LDE is to find a particular solution(x0 , y0 )of the LDE ax  by 1 using the formulas we’ve studied and derived according to the case we have.

ax  by 1 a(cx )  b(cy )  c From 0 0 , we have: 0 0

Thus, (cx0 ,cy0 ) is a particular solution of the LDE .

> Solving the LDE Ax  By  C , where A, B and C are integers, gcd( A, B) 1.

As we have proved in Theorem 2.8, the LDE is solvable if and only if gcd(A, B) divides C. If so, divide both sides of the LDE by gcd(A, B) to reduce it to the equation of the form: ax  by  c , (2.27) where a, b and c are integers, gcd(a, b)=1.

The solution of equation (2.27) has been discussed and is easy to solve. Finally, any solution of this equation is automatically a solution of the original equation .

Example 2.18:

Solve the LDE 65x 182y  299 using continued fraction method.

Solution: 47 gcd(65,182) = 13, and 13 divides 299. So, the LDE 65x 182y  299 is solvable.

Divide both sides of the equation by 13 to get the LDE 5x 14y  23.

Now, we find a particular solution to the LDE 5x 14y 1. 5 [0,2,1,4]. The following table is the convergent table. 14

Table 2.4

k -2 -1 0 1 2 3

ak 0 2 1 4

pk 0 1 0 1 1 5

qk 1 0 1 2 3 14 1 1 5 ck 0 2 3 14

From this table: n = 3, p2 = 1 and q2 = 3. Thus, a particular solution to the LDE 5x 14y 1 is: 2 x0  (1) 3  3 2 y0  (1) 1 1

So, (23x0, 23y0) = (69, 23) is a particular solution to the LDE 5xy 14 23

Finally, the general solution of 5x 14y  23is: x  69  14t  69 14t , t is an arbitrary integer. y  23  5t

Note 2.4: The continued fraction method for finding a particular solution for a solvable LDE is equivalent to the Euclidean algorithm method. This is due 48 a to the fact that the continued fraction of is derived from the Euclidean b algorithm as we have already studied in Chapter Two. However, generating the convergents using the recurrence relations to solve a LDE is quicker than to find Euclidean algorithm equations and then use them in reverse order. 49 Chapter Three Infinite Simple Continued Fractions Section 3.1: Properties and Theorems Irrationals are numbers that cannot be written as a of two integers. A  B Some irrationals are of the form , where A and C are integers, B is a C positive no-perfect square integer. Irrationals of this form are the roots of the quadratic equation C 2 X 2  2ACX  (A2  B)  0, so they are called quadratic irrationals or quadratic surds. However, there are irrational numbers which are not quadratic surds such as 휋, e, cube roots, fifth roots, etc. Our discussion will concentrate on the continued fraction expansions of quadratic irrationals. The numbers 휋 and e are examples of transcendental numbers. The expansion of transcendental numbers into continued fractions is not easy, but using approximations to them, such as 휋 = 3.141592….. and e = 2.7182818…., we can find some of the first terms of their continued fraction expansions: e  [2,1,2,1,1,4,1,1,6,1,1,8,1,.....] and  [3,7,15,1,292,1,1,1,2,1,.....] As we can see, e has apparent pattern occurs in its expansion, but the expansion of the irrational number 휋 does not appear to follow any pattern. However, mathematicians found the expansions of 휋 and e using methods which are beyond the scope of this thesis. In Chapter Two, we’ve defined the infinite simple continued fraction that has the form 50 1 a  0 1 a  1 1 a  2 1 a  3 a4 

But, in that chapter, our study of continued fractions has been limited to the expansion of rational numbers. In this chapter, we study the continued fraction expansion of irrational numbers, state their properties and some related theorems.

The Continued Fraction Algorithm: 4, p.3 For the continued fraction expansion of irrational numbers, we’ll use the same algorithm as in the continued fraction expansion of rational numbers. Let y be an irrational number.

Set y  y0 and let a0 [[y0 ]]; 1 y1  , a1  [[y1]]; y0 [[y0 ]] 1 y2  , a2 [[y2 ]]; y1 [[y1 ]] . . 1 yk  ; ak [[yk ]], yk1 [[yk1 ]] . . . We continue in this manner. Here, the process will continue indefinitely but the expansion exhibit nice periodic behavior for quadratic irrationals. We’ll prove this algorithm in Theorem 3.5. 51

Example 3.1: Find the continued fraction expansion of 2 .

Solution: Let y  2 , 1 2  2, ; 0 ay00[[ ]]  [[ 2]]  1 1 y1  . Rationalize the denominator of y1: 2 1 1.( 2 1) 2 1 ya  2  1,  [[ 2  1]]  2; 11( 2 1)( 2 1) 1 11 y  2  1  y , a  [[ 2  1]]  2 . 22 1  2 2  1 1 2

Since y1 = y2, it is clear that y2 y 3  y 4  y 5 ...  2  1 and

a2  a3  a4  a5  .....  2.

Hence, 1 2  1  [1,2,2,2,...]  [1,2] 1 , where the bar over 2 indicates that 2  1 2  1 2   the number 2 is repeated over and over.

Example 3.2: Using the continued fraction algorithm, find the first 6 terms of the infinite continued fraction expansion of e.

Solution:

Let y0 e 2.7182818285..., a 0  [[ y 0 ]]  [[ e ]]  2 ; 1 y 1.3922111911..., a  [[ y ]]  1; 12.7182818285... 2 1 1 1 y2 2.5496467788..., a 2  [[ y 2 ]]  2; 1.3922111911... 1 52 1 y3 1.8193502419..., a 3  [[ y 3 ]]  1; 2.5496467788... 2 1 y 1.2204792881..., a  [[ y ]]  1; 41.8193502419... 1 4 4 1 y5 4.5355734255..., a 5  [[ y 3 ]]  4 . 1.2204792881... 1 Thus, e [2,1,2,1,1,4,...].

Convergents: 1,2,6,9

The corresponding convergents to any infinite continued fraction form an infinite sequence:

p0 p1 pi c0  ,c1  ,... ,ci  ,... . q0 q1 qi

These convergents are evaluated in the same way as convergents of finite simple continued fractions since each convergent is finite and represents a rational number. So we calculate them using the formula:

pk  ak pk1  pk2 p 1, p  0 , k ≥ 0 and 1 2 . qk  ak qk1  qk2 q1  0, q2 1

They also have the same properties of convergents of finite simple continued fractions, and we can summarize them as follows:

p q  p q  (1)k k 1 * k1 k k k1 , (1)k1 * ck  ck1  , k ≥ 1. qk qk1 k (1) ak * ck  ck2  , k ≥ 2. qk qk2

* For k ≥ 1, pk and qk are relatively prime.

* c0 < c2 < c4 < ... < c2k < ... < c2k+1 < ... < c3 < c1. 53 The proofs of these properties are the same as before since the proofs given there were independent of whether the continued fraction is finite or infinite. a q Moreover, it is important to note here that since s and k , are positive s 1 k  0 q  a q  q integers for & , it follows from the equation k k k1 k2 that {qkk , 0, 1, 2,...}is an increasing unbounded sequence.

Theorem 3.1: 4, p.10

pk a) [akk , a1 ,..., a 1 , a 0 ], k  0, a 0  0 . pk 1

qk b) [akk , a11 ,..., a ], k 1. qk 1

Proof: We only prove a). The proof of b) is similar. Using induction on k:

p0 a0 For k = 0:   a0  [a0 ] p1 p1

p1 a1 p0  p1 p1 1 For k = 1:   a1   a1   [a1,a0 ] p0 p0 p0 a0

Suppose the statement is true for k = n > 1. That is,

pn  [an , an1,..., a1, a0 ] pn1

Now, pn1  an1 pn  pn1 . Divide both sides by pn to get: 54

pn1 pn1 1  an1   an1  pn pn pn

pn1 1  a   [a , a ,..., a , a ] n1 1 n1 n 1 0 a  n 1 a  n1 1   a0

Thus, the statement is true for k ≥ 0.

Example 3.3: Find the first seven convergents of the continued fraction expansion of 휋.

Solution: We can find some of the first terms of the infinite continued fraction for 휋:  [3, 7, 15, 1, 292, 1,1,1, 2, 1,...].

We want to find ci for each 0 ≤ i ≤ 6, so we construct the following convergent table:

Table 3.1

k -2 -1 0 1 2 3 4 5 6

ak 3 7 15 1 292 1 1

pk 0 1 3 22 333 355 103993 104348 208341

qk 1 0 1 7 106 113 33102 33215 66317 22 333 355 103993 104348 208341 ck 3 7 106 113 33102 33215 66317 55

Now, c0  3

22 c1   3.1428571428571429 7 333 c2   3.1415094339622642 106 355 c3   3.1415929203539823 113 103993 c4   3.1415926530119026 33102 104348 c5   3.141592653921421 33215 208341 c6   3.1415926534674367 66317 and 휋 = 3.1415926535897932….

Notice that the convergents c0 ,c1,...,c6 are good approximations for 휋 to 0,

2, 4, 6, 9, 9, 9 decimal places, respectively. Hence, they give successively better approximations to 휋.

Now, from the property c0 < c2 < c4 < …< c2m < … < c2m+1 < . . . < c3 < c1, the sequence of even convergents {c2m} is an increasing sequence that is bounded above by c1, so it is a convergent sequence. Moreover, the sequence of odd convergents {c2m+1} is a decreasing sequence that is bounded below by c0, so it is also a convergent sequence. Hence as m approaches , the sequence {c2m} approaches a limit Me and the sequence

{c2m+1} approaches a limit Mo. That is, c2m = Me and

c2m1 = Mo.

Since even convergents are less than all odd convergents, then the limit Me is less than all odd convergents. Similarly, the limit Mo is greater than any even convergent. 56 These two limits are equal according to the following theorem:

Theorem 3.2: 1, pp.68  70& 2, p.568

Let [a0 ,a1,a2 ,....] be an infinite simple continued fraction expansion of a

th number y and let ci  [a0 ,a1,...,ai ] denotes the i convergent of the continued fraction, then:

1) c2m = c2m1 .

2) cm = y.

Proof: (1)k1 1) Using the property ck  ck1  , k ≥ 1, we obtain: qk qk1 (1)2m 1 c2m1  c2m   , m ≥ 0. q2m1q2m q2m1q2m q  q 11 But we know that 2m1 2m , then  2 . qq2mm 1 2 q2m 2 1 Now, as m increases, q2m and q2m both increase and so {}is a bounded q2 2m decreasing positive sequence, hence it is convergent to 0.

So, lim m (c2m1  c2m ) = 0 and hence, c2m1 c2m .

2) Now, {c2m} and {c2m+1} are subsequences of the sequence {cm} and they

both have a common limit, say M. Then cm = M.

Hence, we can say that every infinite simple continued fraction converges to a limit M. This limit is greater than all even convergents and less than all odd convergents. We prove that the limit M equals the number y. 57 1 y  a  Given 0 1 , a  1 1 a  2 1  1 a  n1 1 an  a  n1  1 1 define y  a  , y  a  , … and so on. n n 1 n1 n1 1 an1  an2  a  a  n2  n3  1 1 y  a  y  a  Then, we can write 0 1 and n n . a  yn1 1 1 a  2 1  1 an1  yn

It is clear that yn+1 > 0. So, yn > an for all n  0. 1 Hence, an  yn  an  . (3.1) an1

Now, comparing the three following expressions: 1 c  a  n 0 1 (3.2) a  1 1 a  2 1  1 an1  an 1 y  a  0 1 (3.3) a  1 1 a  2 1  1 an1  yn and 58 1 c  a  n1 0 1 (3.4) a  1 1 a  2 1  1 a  n1 1 an  an1 1 a  We can see that they have the term 0 1 in common and a  1 1 a  2 1  an1 1 1 1 differ in the terms , , , respectively. 1 an yn an  an1

Using inequality (3.1), we get: 1 1 1   (3.5) 1 yn an an  an1

Thus, from equations (3.2), (3.3), (3.4) and inequality (3.5), we conclude that y must lie between two consecutive convergents cn and cn+1. That is:

cn  y  cn1 or cn1  y  cn

But we know that even convergents are less than odd convergents. Thus, we conclude that

c2m  y  c2m1 , m = 0, 1, 2, … and in expanded form, we write: c0  c2  c4  ...  c2m  ...  y  ...  c2m1  ...  c5  c3  c1

Thus, as m increases, even convergents approach y from the left and odd convergents approach y from the right. Hence, the limit M obtained in the previous proof is the same as the number y. In symbols, cm = y.

59 Definition 3.1: 20

Given an infinite simple continued fraction [a0 ,a1,a2 ,a3 ,...], the term y  [a ,a ,a ,...] n n n1 n2 is called the (n+1)-st complete quotient of the continued fraction.

Theorem 3.3: 2, p.569

Any infinite simple continued fraction represents an irrational number.

Proof: (by contradiction)

Let y  [a0 ,a1,a2 ,....] be an infinite simple continued fraction. Then, by

Theorem 3.2, y = cm and c2m  y  c2m1 . 1 c  c  Thus, 0  y  c2m  c2m1  c2m . But, 2m1 2m . q2m1q2m p 1 So, 0  y  2m  q2m q2m1q2m l Now, suppose by contradiction that y is a rational number, say y  , s where s > 0.

Then, l p 1 0   2m  . s q2m q2m1q2m

That is, s 0  lq2m  sp2m  . q2m1 s lq  sp So, 2m 2m is a positive integer less than . q2m1 q As we studied before, as m increases, 2m1 also increases. Thus, there is an integer i such that q2i1  s . 60 s 1 0  lq  sp 1 lq  sp Then, . This implies that 2i 2i . Hence 2i 2i is a q21i  positive integer less than one, which is a contradiction. So, y is an irrational number.

Theorem 3.4: 4, p.7 p Let { k , k  0,1,2,...} be the sequence of convergents of an irrational qk number y. Define yk as in the continued fraction algorithm, 1 y p  p i.e., y  . Then: y  k k1 k2 , k  0. k y [[y ]] y q  q k1 k1 k k1 k2

Proof: We prove this theorem using induction on k. First, remember that

p1 1, p2  0 , q1  0,q2 1, pk  ak pk1  pk2 and qk  ak qk1  qk2 .

For k = 0:

y0 p1  p2 y0.1 0   y0  y y0q1  q2 y0.0 1

For k = 1: 1 ( ).a 1 y p  p y .a 1 y  a 0 1 0 1  1 0  0  y y q  q y .1 0 1 1 0 1 1 ( ) y  a0

So, the statement is true for k = 0 and k = 1. Assume that the statement holds for an arbitrary number j ≥ 2. That is,

y j p j1  p j2  y. y j q j1  q j2 61 Now, 1 ( ) p j  p j1 y j1 p j  p j1 y j  a j p j  p j1(y j  a j ) a j p j1  p j2  p j1(y j  a j )    y j1q j  q j1 1 q j  q j1(y j  a j ) a j q j1  q j2  q j1(y j  a j ) ( )q j  q j1 y j  a j y p  p  j j1 j2  y. y j q j1  q j2

So, the statement is true for j+1. Thus, the theorem is true for k ≥ 0.

Note 3.1: 3,4

The property considered in Theorem 3.4 is also true for rational numbers.

yk pk1  pk2 That is [a0 , a1,..., an ]  ,0  k  n. yk qk1  qk2

The following theorem shows that any irrational number can be written as an infinite simple continued fraction.

Theorem 3.5: 2, p.570  Let y = y0 be an irrational number. Define the sequence{ak }k0 of integers ak recursively as follows: 1 ak  [[yk ]] , yk1  , k  0 yk  ak y  [a ,a ,a ,a ,...]. Then 0 1 2 3

Proof:

It is clear that, for any k ≥ 0, ak is an integer.

By induction, we prove that yk is an irrational number for every k ≥ 0. a  [[y ]]  y . y  a Note that y0 is an irrational number and 0 0 0 Then, 0 0 is 1 y  irrational and so 1 is irrational. y0  a0 62

Assume that yk is an irrational number for an arbitrary integer k ≥ 0. This 1 y  a implies that k k and are also irrationals, which means that yk+1 yk  ak is irrational. So, by induction, yk is an irrational number for every k ≥ 0.

Next, we show that ak ≥ 1 for every k ≥ 1. yk is an irrational number and a  [[y ]] a  y y  a  0. k k is an integer, then k k and k k y  a  y [[y ]] 1. 0  y  a 1 But, k k k k Then, k k and so 1 y   1. a  [[y ]] 1. k1 Therefore, k1 k1 It means that yk  ak a1, a2 , a3 ,...are all positive integers.

Finally, we prove that y [a0 ,a1,a2 ,...].

Using the recursive formula: 1 yk1  , yk  ak we find that 1 y  a  , k  0. k k yk1 1 Now, y0  a0  . Successively substituting for y1, y2, y3, … yields: y1 1 y0  a0   [a0 , y1 ] y1 1  a   [a ,a , y ] 0 1 0 1 2 a1  y2 63 1  a   [a ,a ,a , y ] 0 1 0 1 2 3 a  1 1 a2  y3   1  a   [a ,a ,a ,a ,...,a , y ] , m  0. 0 1 0 1 2 3 m m1 a  1 1 a  2 1 a  3 1  1 am  ym1

Using Theorem 3.4, we get:

ym1 pm  pm1 y0  ym1qm  qm1 p Let c  k be the kth convergent of the continued fraction [a ,a ,a ,a ,...]. k q 0 1 2 3 k Then

ym1 pm  pm1 pm y0  cm   ym1qm  qm1 qm p q  p q  m1 m m m1 (ym1qm  qm1 )qm

m But, pm1qm  pmqm1  (1) . Then, (1)m y0  cm  . (ym1qm  qm1)qm 1 So, y0  cm  . (ym1qm  qm1)qm 1 1 But, ym1  am1 , so y0  cm   . (am1qm  qm1)qm qm1qm 1 As m approaches ∞, qm gets larger and larger, and so, approaches qm1qm c  y m  zero. It means that m 0 as . 64

Hence, y  y0  lim m cm [a0 ,a1,a2 ,...].

We conclude that we can approximate any irrational number by a rational number.

Theorem 3.6: 20, p.253

The infinite simple continued fraction expansion of an irrational number is unique.

Proof: Let x be an irrational number. Suppose that there are two infinite simple continued fractions representing the irrational number x.

x [d0 ,d1,d2 ,...] [h0 ,h1,h2 ,...] d [[x]] h  [[x]] d  h It is clear that 0 and 0 . So, 0 0 . 1 Next, using the continued fraction algorithm, we find that d  [[ ]] 1 x [[x]] 1 and h  [[ ]] . So, d  h . 1 x [[x]] 1 1

Suppose that dk  hk for all k < n. We’ll prove that dn  hn .

Using the complete quotient, we can write:

x [d0 ,d1,d2 ,...dn1,xn ] [d0 ,d1,d2 ,...dn1, xn ]

Now x p  p x p  p x  n n1 n2  n n1 n2 . xnqn1  qn2 xnqn1  qn2

So

(xn pn1  pn2 )(xnqn1  qn2 )  (xnqn1  qn2 )(xn pn1  pn2 ) .

This implies that

xn pn2qn1  xn pn1qn2  xnqn1 pn2  xn pn1qn2 65 Then

(xn  xn )pn2qn1 (xn  xn ) pn1qn2  0

(xn  xn )[ pn2qn1  pn1qn2 ]  0

But

n1 pn2qn1  pn1qn2  (1)

Thus

xxnn 0 .

As a result, xn  xn . So, dn [[xn ]] [[xn ]]  hn .

Thus, we deduce that dn  hn .

Therefore, we’ve proved by induction that the simple continued fraction representation of an irrational number is unique. 66 Section 3.2: Periodic Continued Fractions

In the previous section, we studied the representation of irrational numbers as infinite simple continued fractions. We also discussed their convergents and some related theorems. In this section, we study quadratic irrationals in details, i.e., irrationals of the form A  B , where A and C are integers, C B is a positive non-perfect square integer.

Definition 3.2: 3,6,9,18 [a ,a ,a ,a ,...] The infinite continued fraction 0 1 2 3 is periodic with period d if there exists a smallest positive integer d and a nonnegative integer f such that and  an for all n ≥ f . It can be represented as

[a0 ,a1,...,a f 1,a f ,...,a f d1]. The quotients a ,a ,..., a are called non-repeating quotients and the 0 1 f 1 quotients a f ,a f 1,...,a f d1 are called the repeating quotients of the fraction.

A continued fraction is called purely periodic with period d if it is periodic with f = 0, that is if there is no non-repeating quotients. It can be represented as [a0 ,a1,...,ad1].

Example 3.4: 1 35 Find the continued fraction expansion of . 2

Solution: 1 35 Let y  ,a  [[y ]]  3 0 2 0 0 1 1 2 2( 35  5) 35  5 y1      ,a1  2. y  a 1 35 35  5 35  25 5 0 0  3 2 67 1 1 5 5( 35  5) 35  5 y2      ,a2  5. y  a 35  5 35  5 35  25 2 1 1  2 5 1 2 35  5 y     y ,a  a  2. 3 35  5 35 5 5 1 3 1 5 2

Since y3 = y1, it is clear that y4  y2 , y5  y1 , …, y2k  y2 , y2k1  y1 , and the corresponding partial quotients alternate between 2 and 5 indefinitely. 1 35 Hence,  [3,2,5,2,5,2,...]  [3,2,5]. 2 The continued fraction expansions of the irrational numbers 2 (in 1 35 Example 3.1) and are periodic but not pure. 2

Example 3.5:

Find the continued fraction expansion of 3 11.

Solution: y  11  3,a  [[y ]]  6 Let 0 0 0 1 1 1 1( 11  3) 11  3 y      , a  3 1 1 y0  a0 3  11  6 11  3 ( 11  3)( 11  3) 2

1 1 2 2( 11  3) y      11  3 , a  6 2 y  a 11  3 11  3 11 9 2 1 1  3 2

Since y2  y0 , it is clear that y3  y1 , y4  y0 , …, y2k  y0 , y2k1  y1 , and the corresponding partial quotients alternate between 6 and 3 indefinitely. Therefore, 11 3 [6,3,6,3,6,...] [6,3] is purely periodic with period 2.

Now, if we want to convert a periodic continued fraction to a quadratic irrational, what shall we do? 1,11

We’ll explain the method by the following example. 68

Example 3.6: A  B Convert the continued fraction [2,3,1,2,1] to the form . C

Solution: 1 Let x  2  and y represents the repeating quotients of the 1 3  1 1 1 2  1 1 1  continued fraction. 1 That is y  1 . 1 2  1 1 1 1 1 2  1  1 1 y 1 4y  3 Now, y  1  1  1  . 1 y 3y  2 3y  2 2  2  1 y 1 1 y

And so, 3y 2  2y  3  0 . Solving this quadratic equation, we get: 1 10 y  . 3 1 10 Since y is positive, then y  . 3 1 But, x  2  . Substitute the value of y in this equation to find the 1 3  y value of x: 1 1 7 10 13 x  2   2   . 1 3  3 10  6 3 10  6 1 10 1 10 3 69 Rationalize the denominator to get: 132  3 10 44  10 44  10 x   . Hence, [2,3,1,2,1]  . 54 18 18

Definition 3.3: 3,21

An irrational number is called a quadratic irrational if it is a root of a quadratic equation ay 2 by  c  0where a, b, c are integers, a ≠ 0 and its

2 discriminant b  4ac is a positive non-perfect square integer.

Lemma 3.1: 22, p.281 ax  b Let x be a quadratic irrational and let y  , where a, b, c and d are cx  d integers, c and d are not both zeros. Then x is a quadratic irrational if and only if ad bc  0.

Proof: see 22.

Theorem 3.7: 3, p.20

If the continued fraction expansion of y is purely periodic, then y is a quadratic irrational.

Proof: Let y be represented by a purely periodic continued fraction. That is

y [a0 ,a1,...,ad1].

Then 1 y  a   [a ,a ,...,a , y] 0 1 0 1 d 1 a  1 1 a  2 1  1 ad 1  y 70 and y  y0  yd  y2d  ....

yp  p Using Theorem3.4, y  d 1 d 2 . yqd 1  qd 2

2 So, qd1 y  (qd2  pd1)y  pd2  0.

Hence y is a root of a quadratic equation. If y is rational, then it has a finite simple continued fraction representation, not an infinite pure periodic continued fraction presentation. Thus y is a quadratic irrational.

Corollary 3.1: 21, p.168 & 22, p.281

A periodic continued fraction represents a quadratic irrational.

Proof: Let y be a real number represented by a periodic continued fraction. That is y [a0 ,a1,...,a f 1,a f ,a f 1,...,a f d1].

Let x be represented by the periodic part of y. That is

x [a f ,a f 1,...,a f d1]. Then, by Theorem 3.7, x is a quadratic irrational. 1 y  a  0 1 a  1 1 a  2 1  1 a  f 1 1 a  f 1 a  f 1 1  So, 1 a  f d 1  1  a   [a ,a ,...,a , x] 0 1 0 1 f 1 a  1 1 a  2 1  1 a  f 1 x 71 xp  p Using Theorem 3.4, y  f 1 f 2 .Then, by Lemma 3.1 , y is a quadratic xq f 1  q f 2

f irrational since p f 1q f 2  p f 2q f 1  (1)  0.

The quadratic equation ay 2 by  c  0, where a ≠ 0, b and c are integers with a positive non-perfect square discriminant has two roots. b  b2  4ac A B The first one is    and the second is 2a C  b  b2  4ac A  B    , where A  b, B  b2  4ac, C  2a are 2a C 2A b integers.  and are conjugates. Notice that    and C a A2  B c    . C 2 a

For instance,  5 is the conjugate of 5 and 14  7 is the conjugate of

14  7 .

Definition 3.4: 1,23

Let be a quadratic irrational satisfying the quadratic equation

, where a, b and c are integers. Then is called a reduced quadratic irrational if  1 and 1  0.

Example 3.7:

The quadratic irrational 3 10 is greater than 1 and satisfies the quadratic 2 2 equation (x 3) 10 , that is x 6x 1 0.also, its conjugate 3 10 lies between -1 and 0. Thus, is a reduced quadratic irrational. In general, we know that if B is a positive non-perfect square integer, then

0  B [[ B]] 1 and so, 1[[ B]] B  0 . Thus, B [[ B]] 1 is a reduced quadratic irrational.

72 Theorem 3.8: 24, p.405

If y has a purely periodic continued fraction expansion, then y is a reduced quadratic irrational.

Proof: y  [a , a ,..., a ] Let 0 1 d1 be the value of a purely periodic continued fraction. In Theorem 3.7, we’ve proved that y is a root of the quadratic equation: q y2 ( q  p ) y  p  0 d1 d  2 d  1 d  2 , hence y is a quadratic irrational. Now, we shall prove that y is reduced.

Since ak’s are positive integers for k ≥ 1 and y is purely periodic, a  a  a  ... 1 0 d 2d and so y > 1. Also, notice that pk’s and qk’s are positive for all k. y and its conjugate y are the roots of the quadratic polynomial: g(x)  q x2  (q  p )x  p d1 d2 d1 d2 Now, g(1)  (q  q )  (p  p )  0 p  p q  q d1 d2 d1 d2 since d1 d2 and d1 d2 and g(0)  pd2  0.

By the Intermediate Value Theorem, there is a root of g(x) between –1 and

0. But y is greater than 1, so the root is its conjugate . Thus, 1 y  0. As a result, y is a reduced quadratic irrational.

Theorem 3.9: 1, p.93& 23, p.169 w  [a , a ,..., a ] Let 0 1 n be a purely periodic continued fraction. Then: 1  [a ,a ,...,a ,a ], where w′ is the conjugate of w. w n n1 1 0

73

Proof: w represents the purely periodic continued fraction [a0 ,a1,...,an ]. Then, it can be written as w  [a ,a ,..., a , w] 0 1 n

Using Theorem 3.4, wpn  pn1 w  wqn  qn1 p p th st where n and n1 are the n and (n-1) convergents of the continued q p n n1 fraction , respectively.

This implies that (by Theorem 3.7), q w2  (q  p )w  p  0 n n1 n n1 (3.6) Next, let v be the purely continued fraction representation of of w but in reverse order,

v  [an , an1,..., a1, a0 ] i.e.,  [an , an1,..., a1, a0 ,v]

Again, using Theorem 3.4,

vrn  rn1 v  (3.7) vsn  sn1 r r th st where n and n1 are the n and (n-1) convergents of the continued s s n n1 fraction [an ,an1,...,a1,a0 ], respectively.

We have: p r n  [a ,a ,...,a ]  n n n1 0 pn1 sn q r n [a ,a ,...,a ]  n1 and n n1 1 qn1 sn1

Then 74

pn  rn , pn1  sn q  r , q  s n n1 n1 n1 since convergents are in their lowest terms. Substituting these results in equation (3.7), we get:

vpn  qn v  vpn1  qn1

2 So, pn1v  (qn1  pn )v  qn  0

Dividing both sides of this equation by –v2 (v > 1) 1 1 q ( )2  (q  p )( )  p  0 n v n1 n v n1 1 Thus, is a root of equation (3.6) and since v and w are positive, is v negative and different from w. so, must be the conjugate w′ of w. 1 1 Hence, w  and so v   [a , a ,..., a ]. v w n n1 0

Theorem 3.10: 23, p.169

Let w be a quadratic irrational and w′ be its conjugate. If d and l are rational numbers, then d  lw is the conjugate of d  lw . Moreover, l l d  is the conjugate of d  . w w

Proof: see 23 .

Theorem 3.11: 3, p.21 (Lagrange’s theorem)

If w is a quadratic irrational number, then it has a periodic continued fraction expansion.

Proof: see 3.

75 Theorem 3.12: 24, p.405& 25, p.45

If w is a reduced quadratic irrational number, then it has a purely periodic continued fraction expansion.

Proof:

Let w  w0 be a reduced quadratic irrational. So, w  1 and its conjugate w lies between -1 and 0. w , k  1 First, we prove that each complete quotient k is a reduced quadratic irrational. 1 1 1 w  a0  , a0  [[w]] . So, w1  1. By Theorem 3.10, w  a0  w1 w a0 w1 1 and so w1  . w  a0

w1 lies between -1 and 0 since 1 w  0 . So, w1 is a reduced quadratic irrational. w w 1 10 w   Suppose n is reduced. That is, n and n . 1 1 Now, wn a n , a n  [[ w n ]] . So, we have w n 1 1 and w n 1 wann 1 w  . n1 w  a n n an [[wn ]] 1 since wn 1. So, wn  an  an  1 and 1 wn1  0 .

Hence, wn1 is a reduced quadratic irrational and by induction, wk is reduced for k ≥ 0. Next, we complete the proof using contradiction. Suppose that the continued fraction expansion of w is not purely periodic and has the form

[a0 ,a1,...,an1,an ,an1,...,and1] , where an is the first repeating quotient. 1 1 wn1  wnd1  (an1  )  (and1  ) . wn wnd 76

But wn  wnd . So, wn1  wnd1  an1  and1 is a non-zero integer since otherwise an1 and and1 would be equal and hence the period would begin one position sooner. w  w 1 w  0 This implies that n1 nd1 is also a non-zero integer. But, n1 and 1 wnd1  0 . So, 1 wn1  wnd1 1, a contradiction.

As a result, the continued fraction expansion of a reduced quadratic irrational is purely periodic.

Theorem 3.13: 1, p.112 & 25, p.47 (The continued fraction expansion for T ) Let T be a positive integer, not a perfect square. Then T  [a ,a ,a ,a ,..., a , a ,2a ] 0 1 2 3 n1 n 0 where an1 j  a j , j 1,2,..., n.

T[ a , a , a , a ,..., a , a ,2 a ] i.e., 0 1 2 3 2 1 0

Proof:

At first, notice that T  1and so  T  1. Thus, T is not a reduced quadratic irrational.

1 T  [a ,a ,a ,...]  a  Let 0 1 2 0 1 (3.8) a  1 1 a  2 

Since a0  [[ T ]], a0  T 1and its conjugate 1 a0  T  0 . Then, a0  T is a reduced quadratic irrational and has a purely periodic continued fraction.

Add a0 to both sides in equation (3.8) to get: 77 1 a  T  2a  0 0 1 a  1 1 a  2  But the expansion of a reduced quadratic irrational is purely periodic. Then, 1 a  T  2a   [2a ,a ,a ,...,a ] 0 0 1 0 1 2 n a  1 1  1 a  n 1 2a  0 1 a  1  So, 1 T  a   [a ,a ,a ,...,a ,2a ] 0 1 0 1 2 n 0 a  1 1  1 a  n 1 2a  0 1 a  1 1  1 a  n 1 2a  0  (3.9) Now, using Theorem 3.9, 1 1   [an ,an1,...,a1,2a0 ] (3.10) a0  T T  a0 1 Moreover, using equation (3.9), we can find . Subtract a0 from T  a0 both sides to get: 78 1 T  a  0   [0,a ,a ,...,a ,2a ] 0 1 1 2 n 0 a  1 1  1 a  n 1 2a  0 1 a  1 1  1 a  n 1 2a  0  Thus, by Theorem 2.3, 1 1  a   [a ,a ,...,a ,2a ] 1 1 1 2 n 0 (3.11) T  a0  1 a  n 1 2a  0 1 a  1 1  1 a  n 1 2a  0  However, since the continued fraction expansion is unique and comparing both equations (3.10) & (3.11), we find:

an  a1,an1  a2 ,..., a2  an1,a1  an

So, T  [a0 ,a1,a2 ,...,a2 ,a1,2a0 ].

In other words, the periodic part is symmetrical except for the term 2a0. It may or may not have a central term. For instance, the symmetrical part of the periodic expansion for

29  [5,2,1,1,2,10] has no central term. But, in the periodic expansion for 31  [5,1,1,3,5,3,1,1,10], 5 is the central term.

Example 3.8:

Find the continued fraction expansion of 11 . 79

Solution: y  11,a  [[ 11]]  3. Let 0 0 1 11  3 y   , a  3 1 11 3 2 1 1 2 y    11  3, a  6 2 11  3 11 3 2 3 2 1 11  3 y3    y1, a3  a1  3 11  3 6 2

Since y3 = y1, it is clear that y1 = y3 = y5 = … and a1 = a3 = a5 = … = 3. So, y2 = y4 = y6 = … and a2 = a4 = a6 = … = 6 1 11  3   [3,3,6,3,6,...]  [3,3,6] Hence, 1 . Notice that 3  1 6  1 3  1 6  

6  2(3)  2a0 .

For more examples, look at Table 3.2.

80

Table 3.2 T The continued fraction expansion for T

2 [1,2] 3 [1,1,2] 5 [2, 4] 6 [2, 2,4] 7 [2,1,1,1,4] 8 [2,1,4] 10 [3,6] 11 [3,3,6] 12 [3, 2,6] 13 [3,1,1,1,1,6 ] 14 [3,1,2,1,6] 15 [3,1,6] 17 [4,8] 18 [4, 4,8] 19 [4, 2,1,3,1,2 ,8] 20 [4, 2,8] 21 [4,1,1,2,1,1, 8] 22 [4,1,2,4,2,1,8] 23 [4,1,3,1,8] 24 [4,1,8] 26 [5,10] 27 [5,5,10] 28 [5,3,2,3,10 ] 29 [5, 2,1,1,2,10] 30 [5, 2,10]

81

Section 3.3: Solving Pell’s Equation In this section, we study the solution of one type of Diophantine equations, called Pell’s equation, using continued fractions method. The continued fraction expansion of T plays an important role in our discussion.

Definition 3.5: 5,9,12 Pell’s equation is a Diophantine equation of the form x2 Ty2  M , where T is a positive non-perfect square integer and M is a fixed natural number. Indian mathematicians Brahmagupta and Bhaskara are the first to study Pell’s equation. This equation appears in problems in mathematics. One of these problems is “The Cattle Problem” of Archimedes. In this problem, there are eight unknowns represent the number of cattle in different kinds. After many steps, one can reduce the problem to x2  4729494y2 1.

In this section, we are interested in solving the Pell’s equation x2 Ty2  1

, where T is not a perfect square since if T is a square natural number, i.e.

2 T  s for some natural number s, then we get a linear system of equations and so the case is trivial. For the case of x2 Ty2 1: x2 Ty2 1 2 2 2 x  s y 1 (x  sy)(x  sy) 1 x  sy  1 x  sy  1 Thus, or x  sy  1 x  sy  1 Solving these two linear systems, we get (xy , ) (1,0) or (xy , ) ( 1,0), respectively. 82 And for the case of x2 Ty2  1: x 2 Ty2  1 2 2 2 x  s y  1 (x  sy)(x  sy)  1 x  sy 1 x  sy  1 or x  sy  1 x  sy 1 1 1 Solving these two linear systems, we get (x, y)  (0, ) or (x, y)  (0, ) , s s respectively. So, we have the trivial solutions (x, y)  (0,1) or (x, y)  (0,1) if s = 1.

Another note about Pell’s equation is that if (,)mn is a solution, then there are three other solutions located at the vertices of the rectangle centered at the origin and having as one of its vertices, i.e., the other three solutions are (m , n ),( m , n ) &(,)mn. Thus, it is enough to consider positive solutions only, i.e., m & n are positive integers.

Remark 3.1:

2 2 If (a,b) is a solution of the equation x Ty  1, then gcd(a,b) =1. Otherwise if gcd(a,b) = c ≠ 1 then c2 (r 2 Ts2 )  1 . But c, r, s and T are all integers. So c = 1.

Theorem 3.14: 14, p.88& 26, p.332 a If is a positive solution of the equation x2 Ty2  1, then is a b convergent of the continued fraction expansion of T .

Before we write the proof of this theorem, we need the following lemma:

Lemma 3.2: 26, p.326 83 u Let y be an irrational number. If ,v  1 and gcd(u,v) 1 satisfies v u 1 u y   , then is one of the convergents of the continued fraction v 2v2 v expansion of y.

Proof: see 26.

Proof of Theorem 3.14:

2 2 2 2 First, if (a,b) is a positive solution of x Ty 1, then a Tb 1and a  b T .

Now, a2 Tb2 1

(a b T )(a  b T ) 1 a 1 1 1 1 So, 0   T     b b(a  b T ) b(b T  b T ) 2b2 T 2b2 a By Lemma 3.2, is a convergent of the continued fraction expansion of b

T .

2 2 2 2 Second, if is a positive solution of x Ty  1, then a Tb  1. 1 1 Rewrite the equation as b2  a2  . T T 1 1 1 Now, (b  a)(b  a)  . T T T 1 b 1 Notice that  0 and so  . T a T b 1 1 1 1 1 Therefore, 0       . a 1 1 1 2 2 T Ta(b  a) Ta( a  a) 2a T 2a T T T

This implies that 1 b 1   2 T a 2a 84 b 1 and thus, by Lemma 3.2, is a convergent of . a T 1 Let T  [a , a , a ,...]. Then, by Theorem 2.3,  [0, a , a , a ,...] . Since 0 1 2 T 0 1 2 b is a convergent of , then  [0,a , a , a ,..., a ] for some n. a 0 1 2 n a a But,  [a , a , a ,..., a ]. Therefore, is a convergent of T . b 0 1 2 n b

Definition 3.6: 14 (x , y ) x2 Ty2  1 The positive solution 0 0 to Pell’s equation is called the x  f y  g least positive solution or the fundamental solution if 0 and 0 for every other positive solution ( f , g). 2 2 It is easy to find the solution of Pell’s equation x Ty 1 using the continued fraction expansion of T  [a0 ,a1,a2 ,a3,..., an1,an ,2a0 ]. p p Now, n  [a , a ,..., a , a ] and n1  [a , a ,..., a ] are the nth and (n- q 0 1 n1 n q 0 1 n1 n n1 1)st convergents of the continued fraction expansion of T . t p  p Using Theorem 3.4, T  n1 n n1 , tn1qn  qn1 where tn1  [2a0 ,a1,..., an ]  a0  T . (a  T ) p  p Thus, T  0 n n1 (a0  T )qn  qn1

If we multiply and rearrange the terms we obtain:

T (a q  q )  Tq  a p  p  p T 0 n n1 n 0 n n1 n T a ,q ,q , p , p ,T But is an irrational number and 0 n1 n n1 n are all integers. a0qn  qn1  pn This implies that Tqn  a0 pn  pn1

So

qn1  pn  a0qn (3.12) pn1  Tqn  a0 pn 85 Remember that p q  p q  (1)n n1 n n n1 (3.13) Substitute equations (3.12) in equation (3.13) to get: (Tq  a p )q  p (p  a q )  (1)n n 0 n n n n 0 n 2 2 n Then Tqn  pn  (1)

2 2 n1 or pn Tqn  (1) . ( p , q ) x2 Ty2  (1)n1 Therefore, n n is a solution to the equation . We have two cases. If n is odd, then is a particular solution to the

2 2 equation x Ty 1. Notice that the period length “ d ” of the continued fraction expansion of T is n+1. So, we can write the particular solution ( p , q ) as d1 d1 . However, if n is even, then is a particular solution to the equation x2 Ty2  1. So, we try to use convergents of the second period to find a particular solution to .

Now, the term that occurs for the second time is the term a2n1 . So, p 2n  [a , a ,...a , a ,2a , a ,...a ] 0 1 n1 n 0 1 n1 q2n p and 2n1  [a , a ,...a , a ,2a , a ,..., a , a ] q 0 1 n1 n 0 1 n1 n 2n1 t2n2 p2n1  p2n T  , where t2n2  [2a0 ,a1,..., an ]  tn1  a0  T . t2n2q2n1  q2n

(a0  T ) p2n1  p2n T  (a0  T )q2n1  q2n

Continuing as before yields:

q2n  p2n1  a0q2n1 (3.14) p2n  Tq2n1  a0 p2n1 p q  p q  (1)2n1 Now, 2n 2n1 2n1 2n (3.15) 86 Substituting equation (3.14) in equation (3.15) and then dividing the resulting equation by -1 yield p2 Tq2  (1)2n 1 2n1 2n1 2 2 Thus, (p2n1,q2n1)  (p2d1,q2d1) is a particular solution to x Ty 1 where either n is even and d is odd or vice versa. Notice that whatever the case is, we can always find an integral solution to the equation x2 Ty2 1.

The following theorem gives us the set of all positive solutions of

2 2 x Ty  1.

Theorem 3.15: 14, p.89 p Let T be a non-perfect square positive integer and i is the ith convergent qi of T  [a0 ,a1,a2 ,..., ad1,ad ], where d is the period length. Then:

(a) All positive solutions of are given by

( pkd 1,qkd 1 ),k  N (x, y) { ( p2kd 1,q2kd 1),k  N

2 2 (b) On the other hand, all positive solution of x Ty  1 are given by (p ,q ),k  N { (2k1)d1 (2k1)d1

( p , q ) Moreover, d1 d1 is the fundamental solution of x2 Ty2 1 {

( p , q ) and 2d1 2d1 is the fundamental solution of if d is odd.

Proof: see 14 .

Example 3.9: 87 Find the fundamental solution to the equation: (a) x2 19y2 1 (b) x2 13y2 1

Solution:  (a) First, 19 [4,2,1,3,1,2,8]a0 , a 1 , a 2 , a 3 , a 4 , a 5 , a 6 .

The period length d = 6. So, the fundamental solution is ( p5 , q5 ) .

The first six convergents of 13 are: 9 13 48 61 170 4, , , , , 2 3 11 14 39 Thus, (170,39) is the fundamental solution to .

In addition, the set of all positive solutions of is (x, y)  (p ,q ), k  N  6k1 6k1  The following table shows solutions for k = 1, 2, …, 5.

Table 3.3

K ( p6k1, q6k1)

1 (p5 ,q5 )  (170,39)

2 (p11,q11)  (57799,13260)

3 (p17,q17)  (19651490,4508361)

4 (p23,q23)  (6681448801,1532829480)

5 (p29,q29)  (2271672940850,521157514839)

(b) 13  [3,1,1,1,1,6]  [a ,a ,a ,a ,a ,a ] 0 1 2 3 4 5 88 The period length d = 5. So, the fundamental solution of x2 13y 2 1

is ( p9 , q9 ) .

The first ten convergents of 13 are: 7 11 18 119 137 256 393 649 3,4, , , , , , , , 2 3 5 33 38 71 109 180 So, the fundamental solution is (649,180). (p ,q )  (18,5) x2 13y2  1 Notice that 4 4 is the fundamental solution of . Moreover, we can find all other positive solutions of Pell’s equation using the fundamental solution as the following two theorems illustrate.

Theorem 3.16: 26, p.339& 28, p.354 (x , y ) x2 Ty2 1 Let 0 0 be the fundamental solution of Pell’s equation . (x , y ) Then, all other positive solutions n n can be obtained from the equation

n xn  yn T  (x0  y0 T ) ,n N .

Proof: see 28.

Theorem 3.17: 18, p.63 Let be the fundamental solution of the negative Pell’s equation 2 2 2 2 x Ty  1. Then, all positive solutions (xn , yn ) of x Ty  1are

x  y T  (x  y T )n ,n N given by n n 0 0 where odd values of n gives all positive solutions to and even values of n gives all positive solutions to .

Proof: see 18 .

Remark 3.2: 89 (x , y ) We find the values of n n by expanding x  y T  (x  y T )n ,n N n n 0 0 by the Binomial Theorem and equating rational parts and purely irrational parts of the resulting equation. For example, for n = 3, we have:

3 3 3 3 2 3 1 2 3 3 x3  y3 T  (x0  y0 T )   x0   x0 y0 T   x0 y0T   y0T T 0 1 2 3 3 1 2 2 3  x0  3x0 y0T  T (3x0 y0  y0T)

3 1 2 2 3 So, (x3, y3 )  (x0  3x0 y0T,3x0 y0  y0T)

Example 3.10:

2 2 (1) In Example 3.9, the fundamental solution of x 13y 1 is (649, 180). 2 Set n = 2, we have: x2  y2 13  (649 180 13)  842401 233640 13 So, (842401, 233640) is the second solution of .

Set n = 3, we get:

3 x3  y3 13  (649 180 13) 1093435849  303264540 13

So, (1093435849, 303264540) is the third solution of . (2) By Theorem 3.17 and using convergents in Example 3.9, we find that x2 13y2  1 the fundamental solution of is (18, 5). To find the second solution of this equation, set n = 3:

3 x3  y3 13  (18  5 13)  23382  6485 13 So, (23382, 6485) is the second solution of x2 13y2  1. If we set n = 2, we get a solution of :

2 x2  y2 13  (8  5 13) 169 180 13

Notice that we get the fundamental solution (169, 180) of . 90 Chapter Four

Best Approximation and Applications We discuss in the first section the best approximation and its relation with convergents. In the second section we study some interesting applications of continued fractions in different fields.

Section 4.1: Continued Fractions and Best Approximation A very important use of continued fractions is the approximation of irrational numbers by rational numbers. The problem of approximation includes determining which of the rational numbers that have a difference “no more than a specific value” from a given irrational number has the lowest positive denominator. This way is also used to approximate rational numbers whose numerators and denominators are extremely large by a fraction with smaller numerator and denominator. Convergents have an important role in solving the problem of best approximation of a real number since, from our study of them, they are completely determined by the number represented and closely connected with it.

Definition 4.1: 30 a A rational number is a best approximation of a first kind of a real b c a number x provided that, for every rational number  such that d b a c 0  d  b , we have x   x  . b d 91 a In other words, is a best approximation of the first kind if we cannot b find a different rational number closer to x with denominator ≤ b.

Definition 4.2: 3 A rational number is a best approximation of a second kind of a real c a number x provided that, for every rational number  such that d b 0  d  b , we have bx  a  dx  c

Theorem 4.1: 30, p.386

Every best approximation of a second kind of a real number x is a best approximation of a first kind of x.

Proof: c Let be a best approximation of a second kind of x. Let be a rational d number with . Then

a bx  a dx  c dx  c c Now, x      x  b b b d d a c So, x   x  . Thus, is a best approximation of a first kind. b d

Remark 4.1: 30, p.386

The converse of Theorem 4.1 is not true. The following example shows that a best approximation of a first kind may not be a best approximation of a second kind.

92

Example 4.1: 13 The rational number is a best approximation of the first kind to 휋 since 4 there are no rational numbers closer to 휋 with denominator ≤ 4. 10 7 3 , and are the closest distinct rational numbers to 휋 with 3 2 1 denominators 3, 2 and 1 respectively. 13    0.108407346... 4 10    0.191740679... 3 7    0.358407346... 2 3    0.141592653... 1 c 13 Thus, for every rational number  with 0  d  4 , we get d 4 13 c      . 4 d

However, is not a best approximation of the second kind to 휋 since

3 13  and 0 1 4 but 1.  3  4. 13 . 1 4 The following theorem is a generalization of the idea in Example 3.3.

Theorem 4.2: 3, p.31& 11, p.404

For an infinite simple continued fraction representing an irrational number y, each convergent is nearer to y than the preceding convergent.

Proof:

Let [a0 ,a1,..., an ,...] be the infinite simple continued fraction representation of y. Then y  [a0 ,a1,..., an , yn1] where yn1  [an1,an2 ,...] . 93 By Theorem 3.4, y p  p y  n1 n n1 . yn1qn  qn1

This implies that

yn1qn y  yn1 pn  qn1 y  pn1

pn1 Thus yn1(qn y  pn )  qn1(y  ) for n  1. qn1

Dividing both sides by yn1qn yields: p  q p y  n  n1 (y  n1 ) qn yn1qn qn1

Then, take absolute value to both sides to obtain: p q p y  n  n1 y  n1 qn yn1qn qn1

qn 1 But qn  qn1  0 and yn1  1 for . Therefore 01. yqnn1

pn pn1 Thus, y   y  or y cnn  y  c 1 for . qn qn1

So, y is closer to the nth convergent than to the (n  1)st convergent.

Theorem 4.3: 30, p.387 p Let y be a real number and let c  n be the nth convergent of the simple n q n continued fraction representation of y. Then 1 y  cn  . q q n n1

Proof: We’ll prove the theorem for irrational numbers. The proof of rational numbers is in the same manner provided that cn+1 exists (that is y ≠ cn). First, we use the inequalities: 94

cn  cn2  y  cn1 , if n is even

cn1  y  cn2  cn , if n is odd ( 1)n and the property cnn1  c , n  0. qqnn1 Now, from the inequalities, we conclude:

y  cn  cn1  cn n (1) 1 and cn1  cn   qnqn1 qnqn1 1 Thus, y  cn  . qnqn1

Theorem 4.4: 25, p.20

Every best approximation of the second kind of a real number x is a convergent of the simple continued fraction representation of x.

Proof: We prove this theorem with the assumption that x is an irrational number.

When x  [a0 ,a1,..., an1,an ] is a rational number, the proof is in the same manner but assume that the last partial quotient an  1. a Let x [a ,a ,a ,...] and let be a best approximation of x of a second 0 1 2 b kind. By contradiction, suppose that is not a convergent. We have only three cases to consider.

a p Case I:  0 b q0

a p0 a Now,  a0  x since  a0 . This implies that x  a0  x  . b q0 b 95 a Then, 1.x  a  b x  a  b x   bx  a ,0  1  b which 0 0 b a contradicts that is a best approximation of a second kind. b a p Thus,  0 . b q0

a p Case II:  1 b q1 p p p p p p Recall that 0  2  4  ...  x  ...  5  3  1 . q0 q2 q4 q5 q3 q1 p a Then, x  1  . Multiply this inequality by b and then subtract a from q1 b the result to get: p bx  a  b 1  a  0. q1

Thus, bp  aq 0  1 1  bx  a . q1 bp aq Note that bp  aq is an integer and since 11 0 then 1 1 q 1

bp1  aq1 1. Therefore, 1  bx  a . q1 1 But q1  a1 , so  bx  a . a1 1 Remember that x  a0  , where x1 [a1,a2 ,a3,...] and a1 [[x1]]  x1. x1 1 1 So, x  a0    bx  a which contradicts the assumption that that x1 a1 a is a best approximation of a second kind. b

p p Case III: lies between 0 and 1 and is not a convergent, then q0 q1 96 p a p p a n   n2  x  n1 if is to the left of x qn b qn2 qn1 b

pn1 pn2 a pn a (4.1) or  x    if is to the right of x qn1 qn2 b qn b Now

aqn  pnb a pn pn1 pn 1 0       cn1  cn  . bqn b qn qn1 qn qnqn1 Then 1 1  . bqn qnqn1

a pn This is since  and therefore the integer aqn  pnb 1. b qn So, 1 1  . b qn1 That is

qn1  b . (4.2) Moreover, the inequalities (4.1) imply that aq p b aap nn22 n 2 x  bqnn22 b q b

a pn2 But aqn2  pn2b 1 since  . b qn2 Thus 1 a  x  bqn2 b That is 1  bx  a (4.3) qn2 Next,

pn1 qn1x  pn1  qn1 x  qn1 By Theorem 4.3, 97 p 1 x  n1  qn1 qn1qn2 1 So, qn1x  pn1  qn2 From (4.2) and (4.3), we get: q x p  bx  a , 0  q  b nn11 n1 a which contradicts the fact that is a best approximation of a second kind. b a Hence must be a convergent of the continued fraction expansion of x. b

Theorem 4.5: 25, p.21 1 Let x be a real number not of the form a  . Then every convergent of 0 2 the simple continued fraction expansion of x is a best approximation of a second kind to x.

Proof: see 25 .

Remark 4.2: 25 If the real number x lies in the middle between two integers (i.e. 1 x  a  , a is an integer), then x  (a 1)  x  a since both sides 0 2 0 0 0 a a 1 equal to a half, where 0  0 . So, the convergent c  a is not a best 1 1 0 0 approximation of a second kind.

98

Section 4.2: Applications

4.2.1 Calendar Construction 3,31,33

There are many activities whose success depends on accurate planning. Some of them should be done during a certain period of a year, such as sowing and plowing. So, calendar construction is an important issue since ancient times and calendars are found in every old civilization. By counting the days, calendars help us to determine the seasons which depend on the rotation of the Earth around the sun. A tropical “solar” year is the time it takes the Earth to make one 315569259747 revolution around the sun =  365.24219878125 days. 864000000 Remark 4.3: There are 365 days, 5 hours, 48 minutes and 45.9747 seconds in a year. So, there are (365*24 5  48 / 60)*3600  45.9747  31556925.9747 seconds in one year. On the other hand, there are 24*3600 86400seconds a day. Babylonian Calendar “the oldest” contained 12 months with 29 and 30 days alternately. One year in this calendar had 354 days. After that, the

Babylonian calendar was replaced by the Egyptian Calendar which consisted of 12 months, each month contained 30 days. One year in this calendar consisted of 360 days. Then, five days were added to adjust the calendar in Pharaonic times. This calendar was effective for more than 3000 years. However, it led to an error of quick accumulation and therefore a noticeable shift of seasons. Next, a sixth day was introduced every fourth year to give a calendar called the Alexandrian Calendar. 99 Our calendar comes from the ancient Roman calendar. A year in Roman calendar consisted of 365 days until an Alexandrian astronomer advised Romans to create the Julian calendar in which every year divisible by 4 was a leap year “consisting of 366 days” and every other year was a common year “consisting of 365 days”. Julian calendar was a good calendar as it accumulated a small error in a hundred years. However, over the next millennium, the discrepancy was noticed. Finally, a new more precise calendar construction was created by Pope Figure 4.1: The first page of the Gregory XIII. He decreed to omit a leap papal bull "Inter Gravissimas" by which Pope Gregory XIII year every century except those years introduced his calendar. that are divisible by 400. The Gregorian calendar is both accurate and easy to remember. The question now is what is the science behind this construction? In fact, continued fractions provide such a science.

The idea of constructing a modern calendar is to have a cycle of q years such that p of them are leap years. So, q – p are common years. When p and q are chosen, we should take into consideration that the mean year length is very close to the tropical year. Moreover, the rule for selecting p leap years should be convenient and simple to use. 100 During the q-cycle with p leap years, there are 365q + p days. Thus, the p mean year length is 365  . q

Recall that a tropical year consists of 209259747 7750361 315569259747  365   365   365.24219878125 864000000 864000000 32000000 days. p 7750361 Now, our purpose is to find a good approximation for . The q 32000000 last fraction represents the error between a tropical year and a common year.

Representing this fraction as a continued fraction yields 7750361 [0,4, 7, 1, 3, 5, 6, 1,1, 3, 1, 7, 7, 1,1,1,1, 2] 32000000 The first 8 corresponding convergents are 1 c  0 c   0.25 0 1 4 7 8 c   0.24137931034 c   0.24242424242 2 29 3 33 31 163 c   0.2421875 c   0.24219910846 4 128 5 673 1009 1172 c   0.24219875180 c   0.24219880141 6 4166 7 4839

The Julian Calendar is realized by the first convergent c1 which gives a 4- year cycle with one leap year in it.

The annual error considered in Julian Calendar is 1 7750361   0.00780121875 4 32000000 which means that the calendar accumulates about 8 extra days in 1000 years. That is a bit less than a day in 100 years. 101 Looking at the denominators next convergents, we realize that the numbers

29, 33, 128, 673, … provide uncomfortable lengths of a cycle. For 31 example, the fourth convergent determines a 128-year cycle with 31 128 leap years in it. We can construct a corresponding calendar in which there is a leap year every fourth year in the cycle with the thirty-second leap year deleted and this construction gives an annual error 31 7750361    0.00001128125  0.00001128125 128 32000000 which means a loss of about one day every 100000 years. This construction is more accurate than Julian Calendar but it is uncomfortable to use. So, no one used this calendar. Now, we try to find a cycle several centuries long with easy and simple selection rule of leap years. Suppose that q = 100t, t is an integer lies between 1 and 9. This assumption matches with the problem of 7750361 7750361 approximating the fraction 100   . 32000000 320000 7750361 [24,4, 1,1, 4, 1, 2, 2, 6, 11, 2, 1,1, 2] 320000 The first corresponding 6 convergents are 97 c  24 c   24.25 0 1 4 121 218 c   24.2 c   24.22222222222 2 5 3 9 993 1211 c   24.21951219512 c   24.22 4 41 5 50 97 The first convergent c1  gives a 400-cycle with 97 leap years in it. 4 The selection rule of leap years in the cycle is that every year divisible by 4 102 is a leap year except 100th, 200th, 300th years. This calendar is called

Gregorian Calendar which is used nowadays in most countries. The error results in a century from this calendar is

97 7750361   0.030121875 4 320000

That is an accumulation of about one extra day every 3320 years. 121 Another calendar could be constructed using the convergent c2  5 which gives a 500-year cycle with 121 leap years in it. The selection rule of leap years in this cycle is that every year divisible by 4 is a leap year except 100th, 200th, 300th, 400th years.

The error results from this calendar in a century is

121 7750361    0.019878125  0.019878125 5 320000 which implies that there is a loss of nearly a day every 5031 years. Moreover, we can construct a calendar using a 900- year cycle with 218 leap years in it. The selection rule of leap years in this calendar implies 7 exceptions to the fourth year rule since (900 4)  7  218. This calendar is accurate since it accumulates only one day in about 42660 years. However, it is more complicated than the previous calendars and the 900- year cycle is long and therefore inconvenient. So, we reject this calendar and prefer the simpler ones. A small correction can be done in future to the Gregorian Calendar to make it more accurate. Continued fractions give an easy method to carry out his correction. The idea is to find a longer cycle length q consisting of 103 a number of 400- year cycles. Suppose q = 400s, where s is the number of 400 year cycles in the new longer cycle.

7750361 7750361 Represent 400  as a simple continued fraction to get 32000000 80000

7750361 [96,1, 7, 3, 2, 1, 25, 2, 1, 5, 2] 80000 The first corresponding four convergents are

c0  96 c1  97 775 2422 c  c  2 8 3 25 775 The second convergent c2  provides us with a 3200- year cycle with 8 775 leap years in it. The error of this construction is

775 7750361    0.0045125  0.0045125 8 80000 which implies that there is a loss of about one day every 88643 years. Remember that in Gregorian Calendar, there are 97 leap years in every 400- year cycle. So, we get 97×8 = 776 leap years within every 3200 years. Therefore, omitting one leap year every 3200 years will provide us with a modified Gregorian Calendar which has nearly the same construction as Gregorian Calendar but is more accurate.

104 4.2.2 Piano Tuning 3,30,32

Musicians know that we cannot tune a piano perfectly. In this discussion, we study the role of continued fractions in piano tuning. The keyboard of a piano consists of white and black keys. The standard white keys are A, B, C, D, E, F and G. A black key is called sharp and flat. It is a sharp key “#” of the white key that precedes it and a flat key “b” of the white key that follows it as Figure 4.2 shows.

2:1 3:2 Figure 4.2

Sounds that have frequencies with small integer ratios are consonant and harmonious. Musical intervals represent the ratios of frequencies of two notes. For example, an octave, which represents the ratio 2:1, is the interval between two notes, one having double the frequency of the other. A perfect fifth is an interval represents the ratio 3:2. There are many other intervals such as perfect fourth “4:3”, whole step “9:8”, etc. In fact, our study here is about the first two intervals which are the most consonant intervals.

Pythagorean used only octaves and perfect fifths. The problem we are trying to solve comes from trying to find an integer solution to the 105 y  3  equation 2x    in order to keep the scale finite. This equation has no  2  integer solution except x = y = 0. So, we need to approximate the solution using continued fractions.

3 Now, implies that 2x / y  . 2

x 3 So, log ( )  log (3)  1  0.5849625007211562 and its continued y 222 fraction expansion is [0,1,1, 2, 2, 3,1, 5, 2, 23, 2,...]

1 3 7 24 31 The kth convergents, 2  k  6 are: , , , , 2 5 12 41 53 3  2(7 /12) 1.4983070768766815. Taking the fourth convergent, we get 2 7 The approximation 12 implies that the octave consists of 12 semitones with a perfect fifth equal to 7 semitones, “a semitone is the musical interval between two adjacent notes in a 12-tone scale”. In fact, in western music, they use this approximation, i.e., the octave is divided into 12 semitones. 24 31 Other approximations are inconvenient since and give 41 and 53 41 53 notes within an octave, respectively which are too many notes. Moreover, 1 3 2 and 5 give 2 and 5 notes within an octave, respectively which are too few notes. The percentage error results from choosing as an

(log (3) 1) 7 approximation is: 2 12 .100% 0.278508% 0.3% . log2 (3) 1

106 References [1] C. D. Olds, Continued Fractions, New York: Random House, Inc. 1963. [2] Thomas Koshy, Elementary Number Theory with Applications,

Second Edition, Academic Press, 2007. [3] Yu Tung Cheng, Continued Fractions, Cornell University, AMS Classification: 11A55, May 2007.

[4] Samuel Wayne Judnick, Patterns in Continued fraction Expansions, Master Thesis, University of Minnesota, May 2013. [5] H. Davenport, The Higher : An Introduction to the

Theory of Numbers, Seventh Edition, Cambridge University Press, 1999. [6] A.Ya.Khinchin, Continued Fractions, Dover Publications, INC,

New York, 1997. [7] Kesha King, Continued Fractions and the Man Who Knew Infinity, June 2011.

[8] http://www.maths.surrey.ac.uk/hostedsites/R.Knott/Fibonacci/cfINT

RO.html [9] Wieb Bosma, Cor Kraaikamp, Continued Fractions.

https://www.math.ru.nl/~bosma/Students/CF.pdf [10] Kenneth H. Rosen, Elementary Number Theory and Its Applications, Addison-Wesley Publishing Company, 1984.

[11] John J. Watkins, Number Theory: A Historical Approach, Princeton University Press, 2013. 107 [12] Sagar Panda, Diophantine Equation, National Institute of

Technology Rourkela, 2011. [13] Song Y. Yan, Primality Testing and Integer Factorization in Public-Key Cryptography, Springer, 2013.

[14] Lars- Ake Lindahl, Lectures on Number Theory, Uppsala University, 2002. [15] Bassam A. Manasrah, Invitation to Number Theory, First Edition,

Al-Huda, 2003. [16] http://www.cs.cmu.edu/~adamchik/21127/lectures/divisibility_5_prin t.pdf

[17] https://www.math.upsud.fr/~fischler/inde/inde_fischlerpondichery.pd f [18] Peter J. Cameron, A Course on Number Theory, Queen Mary

University of London, 2009. [19] Charles G. Moore, An Introduction to Continued Fractions, The National Council of Teachers of Mathematics, INC, 1964.

[20] L-K. Hua, Introduction to Number Theory, Springer, 2012. [21] http://nptel.ac.in/courses/111103020/module8_lec4.pdf [22] David Garth, Martin Erickson, Introduction to Number Theory,

CRC Press, 2007. [23] http://14.139.172.204/nptel/CSE/Web/111103020old/module8/lec5.p df

[24] Lawrence C. Washington, An Introduction to Number Theory with Cryptography, CRC Press, 2016. 108 [25] Peter Szusz, Andrew M. Rochett, Continued Fractions, World

Scientific, 1992. [26] David M. Burton, Elementary Number Theory, Allyn and Bacon, Inc, 1980.

[27] Seung Hyun Yang, Continued Fractions and Pell’s Equation, August, 2008. [28] Ivan Niven, An Introduction to the Theory of Numbers, Fifth

Edition, John Wiley and Sons, Inc, 1991. [29] Herbert Aleksandr, Continued Fractions, Courier Corporation, 1964.

[30] http://www.math.binghamton.edu/dikran/478/Ch7.pdf [31] Friedrich Eisenbrand, Pope Gregory, The Calendar, And Continued Fractions, Documenta Mathematica, Extra Volume

ISMP (2012) 87–93. [32] Matthew Bartha, Piano Tuning and Continued Fractions. https://www.whitman.edu/Documents/Academics/Mathematics/barth

a.pdf [33] Yury Grabovsky, Modern Calendar and Continued Fractions, TempleUniversity.

https://www.math.temple.edu/~yury/calendar/calendar.pdf [34] Ben-Menahem, Ari, Historical Encyclopedia of Natural and Mathematical Sciences, Springer, 2009. 109 [35] Wooster Woodruff Beman and David Eugene Smith, History of

Mathematics, Second Revised Edition, The Open Court Publishing Co. London Agents, 1903. [36] Rosanna Cretney ,The origins of Euler’s early work on continued

fractions, Elsevier Inc., 2014. [37] David Eugene Smith , A Source Book in Mathematics, Courier Corporation, 2012.

[38] Wissam Raji, An Introductory Course in Elementary Number Theory, The Saylor Foundation, 2013.

[39] http://en.wikipedia.org/wiki/Continued_fraction#History_of_co

ntinued fractions [40] http://www.pi314.net/eng/lambert.php [41] George M. Rassias, Themistocles M. Rassias, Differential

Geometry, Calculus of Variations, and Their Applications, CRC Press, 1985.

[42] http://en.wikipedia.org/wiki/Generalized_continued_fraction#

History of_continued_fractions [43] http://en.wikipedia.org/wiki/Periodic_continued_fraction

110 Appendix Would it be possible to find convergents for a continued fraction without finding first all of the preceding convergents? It can be done using determinants.

Consider the continued fraction expansion [a0 , a1, a2 ,....] of a real number.

Using the continued fraction recursion formula:

pk  ak pk 1  pk 2 p 1, p  0 , k ≥ 0 and 1 2 qk  ak qk 1  qk 2 q1  0,q2 1

We have

p0  a0

p1  a1 p0  1

p2  a2 p1  p0

p3  a3 p2  p1 . .

pk 1  ak 1 pk 2  pk 3

pk  ak pk 1  pk 2 . .

To compute pk, we find the following system of linear equations in k + 1 unknowns, p0 through pk:

 p0  a0 a1 p0  p1  1

p0  a2 p1  p2  0

p1  a3 p2  p3  0 . .

pk3  ak1 pk2  pk1  0 p  a p  p k2 k k1 k  0

To solve for pk, we may use Cramer’s Rule: 111

1 0 . . . 0  a0

a1 1 0 . 1

1 a2 1 . . 0

0 1 a3 1 . . . . . 1 ...... 0 .

. . 1 ak 1 1 . 0 . . . 0 1 a 0 p  k k 1 0 . . . 0 0

a1 1 0 . 0

1 a2 1 . . 0

0 1 a3 1 . . . . . 1 ...... 0 .

. . 1 ak 1 1 .

0 . . . 0 1 a 1 k In the denominator we have a lower triangular matrix, so its determinant is

(-1)k+1. For the numerator, we interchange successively kth columns until we get the last column in the first position and then multiply its entries by -1 to get:

a0 1 0 . . . . 0

1 a1 1 . . .

0 1 a2 1 . . . . . 1 . . . . . (1)k 1 ...... 0

. . . 1 ak 1 1 0 . . . . 0 1 a p  k k (1)k 1

Then, 112

a0 1 0 . . . . 0

1 a1 1 . . .

0 1 a2 1 . . . . . 1 . . . . . p  k ...... 0

. . . 1 ak 1 1

0 . . . . 0 1 ak

Again to find the value of qk, we have:

 q0  1

a1q0  q1  0

q0  a2q1  q2  0

q1  a3q2  q3  0 . .

qk3  ak1qk2  qk1  0

qk2  ak qk1  qk  0

Applying Cramer’s Rule to find qk and proceeding in the same way as we did for pk we get:

1 1 0 . . . . 0

0 a1 1 . . .

0 1 a2 1 . . . . . 1 . . . . . q  k ...... 0

. . . 1 ak 1 1

0 . . . . 0 1 ak

This determinant can be simplified to get: 113

a1 1 0 . . . . 0

1 a2 1 . . .

0 1 a3 1 . . . . . 1 . . . . . q  k ...... 0

. . . 1 ak 1 1

0 . . . . 0 1 ak

Therefore,

a0 1 0 . . . . 0

1 a1 1 . . .

0 1 a2 1 . . . . . 1 ...... 0

. . . 1 ak 1 1

0 . . . . 0 1 ak ck  ,k  1 a1 1 0 . . . . 0

1 a2 1 . . .

0 1 a3 1 . . . . . 1 ...... 0

. . . 1 ak 1 1

0 . . . . 0 1 ak

Example: Using determinants find the 4th convergent of the continued fraction for each of the following:

1 11 a) 2 114 6211 b) 215

Solution:

1 11 a)  [2,6,3] 2

2 1 0 0 0 1 6 1 0 0 0 1 3 1 0 0 0 1 6 0 0 0 0 1 3 818 c   4 6 1 0 0 379 1 3 1 0 0 1 6 1 0 0 1 3

6211 b)  [28,1,7,1,23] 215

28 1 0 0 0 1 1 1 0 0 0 1 7 1 0 0 0 1 1 1 0 0 0 1 23 6211 c   4 1 1 0 0 215 1 7 1 0 0 1 1 1 0 0 1 23

115 Note:

pk and qk are determinants of tridiagonal matrices which can be calculated inductively as follows:

Given the tridaigonal matrix Ann ,3 :

a1 b1 0 . . . . 0  c a b . . .   1 2 2 

 0 c2 a3 b3 . . .    . . c . . . . . A   3  n  ......     . . . . . bn1 0   . . . c a b   n1 n1 n  0 . . . . 0 c a  n n 

Then, detAk1 a k  1 det A k  b k  1 c k  1 det A k  1 , k  2,3,..., n  1

جامعة النجاح الوطنية كمية الدراسات العميا

الكسور المستمرة وتطبيقاتها

إعداد رنا بسام بدوي

إشراف د. محمد عثمان عمران

قدمت هذه األطروحة استكماالً لمتطمبات الحصول عمى درجة الماجستير في الرياضيات بكمية الدراسات العميا في جامعة النجاح الوطنية في نابمس، فمسطين 7112

ب الكسورالمستمرة وتطبيقاتها إعداد رنا بسام بدوي إشراف د. محمد عثمان عمران

الممخص حن في ُزٍ األطشّحت دساست الكسْس الوسخوشة البسيطت الوٌخِيت ّغيش الوٌخِيت ّخصائصِا

ّحل أهثلت عليِا ّإثباث بعض الٌظشياث الِاهت . حن أيضاً اسخخذام الخقاسيب ّبعض الٌظشياث الخاصت بِا لحل هعادلت ديْفاًخايي الخطيت بوخغيشيي. حن بعذ رلك دساست بعض الٌظشياث الوخعلقت بالكسْس الوسخوشة الذّسيت ّاسخخذام الكسش الوسخوش

الذّسي للجزّس الصواء ّالخقاسيب الخاصت بِا لحل حالت خاصت هي هعادلت بيل. أخيشاً حن دساست العالقت بيي الخقاسيب الخاصت بالكسش الوسخوشألي عذد حقيقي ّأفضل حقشيب هي الٌْع الثاًي لِزا العذد ّاسخخذام ُزٍ الخقاسيب إليجاد أفضل حقشيب لألعذاد الحقيقيت في بعض

الخطبيقاث هثل بٌاء حقْين هيالدي دقيق ّضبظ البياًْ.