Continued Fractions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 26

N.E.

S RATNAM COLLEGE OF ART SCIENCE & COMMERCE


BHANDUP(W), MUMBAI-400078

DEPARTMENT OF MATHEMATICS AND STATISTICS

Continued Fractions

PROJECT SUBMITTED UNDER


DBT-STAR STATUS SCHEME
By

Runali Jadhav
Precia Bhagyaraj
Himanshu Mishra

Of
TYBSc

PROJECT GUIDE
Mrs. Veena B. Kamat
1
INDEX

No. Contents Page No.

1 Introduction

2 History

Continued Fractions
3

Some Applications
4

Python Code for Convergents and Simple


5 Continued Fractions

6 Ramanujan’s Contribution

7 References

2
INTRODUCTION
Consider a simple fraction 9/7 expressed in the following way. The expression on the right are
called continued fractions. These provide much insight into many mathematical problems,
particularly into the nature of numbers
9 2 1 1 1
=1+ =1+ =1+ =1+
7 7 7 1 1
3+ 3+
2 2 1
1+
1
1
The quadratic equation x 2−3 x−1=0 can be written as x=3+
x
1 1
1 x=3+ =3+
Replace x again by 3+ on the right-hand side gives x 1
x 3+
x
Repeating this process, a several more times we get
1
x=3+
1
3+
1
3+
1
3+
1
3+
x
Since x appears on the right hand side of this fraction this process continues.
We now consider the following successive fractions,
1
1 1 , 3+
3 , 3+ ,3+ 1
x 1 3+ …….
3+ 1
x 3+
x
If we convert them to fractions we
10 33 109
3, =3.333 … , =3.3 , =3.30303 … … .
3 10 33
These numbers give better and better approximations to the positive root of the quadratic
equation which is
3+ √ 13
x= =3.302775 … …
2
Does the sequence of fractions actually converge to the root?

3
Here one sees how continued fractions can be used to give better and better rational
approximations to irrational numbers. We first discuss how rational functions can be expanded
into continued fractions (finite in nature). We then discuss expansion of irrational numbers into
infinite continued fractions and some applications

HISTORY
The origin of continued fractions is hard to pinpoint as examples of these fractions
can be found throughout mathematics in the last 2000 years. The foundations
however were not laid until the late 1600's, early 1700's.

Continued fractions come as a simple consequence of Euclid's Algorithm which is


used to find the greatest common denominator (gcd) of two integers. By
algebraically manipulating the algorithm, one can derive the simple continued
fraction of the rational p/q as opposed to the gcd of p and q.

Continued fractions became a field in its right through the work of John Wallis
(1616-1703). In his book Arithemetica Infinitorium (1655), he developed and
presented the identity

4 3 ×3 × 5× 5× 7 ×7 × 9 …
=
x 2 × 4 × 4 ×6 × 6 ×8 × 9 …
The first president of the Royal Society, Lord Brouncker (1620-1684) transformed
this identity into

2
4 1
=1+ 2
x 3
2+ 2
5
3+ 3
7
3+

4
This brief sketch into the past of continued fractions is intended to provide an
overview of the development of this field. Though its initial development seems to
have taken a long time, once started, the field and its analysis grew rapidly. Even
today, the fact that continued fractions are still being used signify that the field is
still far from being exhausted.

CONTINUED FRACTIONS

Expansion of Rational Fractions


We study what it means to say expansion of 1/3 is the non-terminating decimal expansion
0.3333……

Definition: By a finite continued fraction we mean a fraction of the form


1
a 0+
1
a 1+
1
a 2+
1
…+
an
where a 0 , a 1 , a2 , … .., a n are all positive real numbers except possibly a 0.
Further if all a 'i s are integers, the continued fraction is called simple finite continued fraction
(SCF).
It is customary to denote the continued fraction as [a0 , a1 , a 2 , a3 , … .. ,a n ]; a 1 , a2 , a3 , … .., a n are
known as partial denominators

1 1 7 25
[ 2,1,3,9 ] =2+ =2+ =2+ =
1 2 9 9
The continued fraction 1+ 1+
1 7
3+
2

25
represents the rational number
9

5
Conversely let’s start with a rational number 57/33
57 24
57=1× 33+24 ; =1+
33 33
33 9
33=1× 24+9 ; =1+
24 24
24 6
24=2 ×9+ 6 ; =2+
9 9
9 3
9=1× 6+3 ; =1+
6 6
6
6=2× 3+0 ; =2+0
3

Making the appropriate substitutions, it is seen that


57 24 1 1 1 1 1
=1+ =1+ =1+ =1+ =1+ =1+
33 33 33 9 1 1 1
1+ 1+ 1+ 1+
24 24 24 6 1
2+ 2+
9 9 9
6
1 1
¿ 1+ =1+ 1
1 1 ¿ 1+
1+ 1+ 1
1 1 1+
2+ 2+ 1
3 1 2+
1+ 1+ 1
6 6 1+
2
3

This is the continued fraction expansion for 57/33=[1; 1 , 2, 1 , 2]

The numbers 1, 1, 2, 1, 2 in the continued fraction are precisely the quotients that would arise if
we used the Euclidean Algorithm to compute gcd (57,33).

67 1
=2+
29 1
Let us look at some more rational expansions: 3+
1
4+
2
The process of finding the continued fractions is as follows:
First we divide 67 by 29 and to obtain quotient 2 and remainder 9. Continuing this process

6
67 9 1 1
=2+ =2+ =2+
29 29 29 2 ………
3+
9 9

We use Euclidean Algorithm and obtain the quotients as follows:


67 9
67=29 ×2+9 ; =2+
29 29
29 2
29=9 ×3+2 ; =3+
9 9
9 1
9=2× 4 +1; =4+
2 9
2=2×1+ 0;
67
Hence, =[2,3,4,2]
29

Continued fraction of the reciprocal;

29
We now find the continued fraction of
67
29 29
29=67 ×0+29 ; =0+
67 67
67 9
67=29 ×2+9 ; =2+
29 29
29 2
29=9 ×3+2 ; =3+
9 9
9 1
9=2× 4 +1; =4+
2 9
2=2×1+ 0;

We see except for the first step the remaining steps are the same and
29
=[0 , 2,3,4,2]
67
Notice that a 0 ,=0 in this example.

7
1 1 1 29
0+ = = = .
1 1 9 67
2+ 2+ 2+
1 2 29
3+ 3+
1 9
4+
2

67 a
A comparison with the expansion of =[2,3,4,2] suggests that if for any rational with a> b
29 b
a b
and =[ a0 , a1 , a2 , a3 , ….. , a n] then =[0 ,a 0 , a1 , a2 , ….. , an ]
b a

Algorithm for Simple Continued Fraction of a Rational Number

a
Let where b> 0 , be an arbitrary rational number
b
By Euclidean algorithm for finding the greatest common divisor of a and b we get
a=ba0 +r 1 ; 0<r 1< b
b=r 1 a1 +r 2 ;0<r 2 <r 1
r 1=r 2 a 2+ r 3 ; 0< r 3 <r 2

r n−2=r n−1 a n−1+ r n ; 0< r n <r n−1
r n−1=r n an +0
Since each remainder r k is a positive integer. a 1 , a2 , … , an are all positive.
We rewrite the equations of the algorithms in the following manner:
a r 1
=a 0+ 1 =a0 +
b b b
r1
b r 1
=a1 + 2 =a1 +
r1 r1 r1
r2
r1 r3 1
=a2 + =a2 +
r2 r2 r2
r3

8
r n−1
=an
rn
b
If we use the second of these equations to eliminate from the first equation, then
r1
a 1 1
=a 0+ =a0 +
b b 1
a1 +
r1 r1
r2
r1
In this result, substitute the value of as given in the third equation:
r2
a 1
=a 0+
b 1
a1 +
1
a 2+
r2
r3
Continuing in this way, we can go on to get
a 1
=a 0+
b 1
a1 +
1
a 2+ ⋱
a 3+ ¿¿
1
1
an−1+
an

51
We illustrate continued fraction of using Euclidean Algorithm
19
51 13
51=2 ×19+3 ; =2+
19 19
19 6
19=1×13+ 6 ; =1+
13 13
13 1
13=2× 6+1 ; =2+
6 6
6
6=6 ×1+0 ; =1
6
Making the appropriate substitutions, we see

9
19 1 1 1 1 1 1
=0+ = = = = =
51 51 13 1 1 1 1
2+ 2+ 2+ 2+ 2+
19 19 19 6 1 1
1+ 1+ 1+
13 13 13 1
2+
6 6
This is the continued fraction expansion for 19/51=[0 ; 2, 1 , 2, 6]
.
The initial integer in the symbol [a0 ; a1 , … , an ] is zero when the value of the fraction is positive
but less than one.

The representation of a rational number as a finite simple continued fraction is not unique; once
the representation has been obtained, we can always modify the last term. For; if a n> 1, then
1
a n=( a n−1 ) +1= ( an−1 )+
1
Where a n−1is a positive integer; hence,
[ a 0 ; a 1 , … , an ]=[ a0 ; a 1 , .. , an−1 , 1]
On the other hand, if a n=1 , then
1 1
a n−1+ =a + =a +1
a n n 1 n−1
So that
[ a 0 ; a 1 , … , an −1 , an ]=[a0 ; a1 , … , an−2 , an−1+ 1]
Every rational number has two representation as a simple continued fraction, one with an even
number of partial denominators and one with an odd number (it turns out that these are the only
19
two representations). In the case of 19/51, =[ 0 ; 2, 1 ,2 , 6 ]=[ 0 ; 2 ,1 , 2, 5 , 1]
51
The converse of the above theorem is also true. That is ‘every finite SCF represents a rational
number.

We now define what are known as convergents

Definition: For a finite SCF [a0 , a1 , a 2 , a3 , … .. ,a n ] the kth convergent C k is defined as


C k =[ a 0 , a1 , a2 , ….. , ak ] ; 1≤ k ≤ n

10
Much of the difficulty in calculating the convergents of a finite continued fraction [a0 ; a1 , … , an ]
can be avoided by establishing formulas for their numerators and denominators.
We define numbers pk and q k (k =0 , 1, … , n) as follows:
p0=a0 q0 =1
p1=a1 a0 +1 q1=a 1
pk =ak p k−1+ p k−2 q k =ak qk−1 +q k−2; for k =2 ,3 , … , n .
A direct computation shows that the first few convergents of [a0 ;a1 , … , an ] are
a0 p 0
C 0=a 0= =
1 q0
1 a1 a0 +1 p1
C 1=a0 + = =
a1 a1 q1

1 a2 ( a1 a0 +1 ) +a 0 p2
C 2=a0 + = =
1 a2 a1 + 1 q2
a1 +
a2

1
For k < n if a k is replaced by the value a k + , then the convergent C k becomes the convergent
a k+1
C k+1 ;

[ a0 ; a1 , … , ak−1 , ak +
1
ak +1]=[ a0 ; a1 , … , ak−1 , ak , ak+1 ]=Ck +1

Clearly the last convergent C n always equals the rational number represented by the original
a
continued fraction .
b

19
The successive convergents of =[ 0 ;2, 1 ,2 , 6 ] , are
51
C 0=0
1 1
C 1=[ 0 ; 2 ] =0+ =
2 2

11
1 1
C 2=[ 0 ; 2, 1 ] =0+ =
1 3
2+
1
1 3
C 3=[ 0 ; 2 ,1 , 2 ] =0+ =
1 8
2+
1
1+
2
19
C 4= [ 0 ; 2 , 1, 2 , 6 ] =
51
19
Except for the last convergent C 4 , these are alternately less than or greater than , each
51
19
convergent being closer in value to than the previous one.
51

Theorem: For numbers pk and q k (k =0 , 1, … , n) if p0=a0 q0 =1


p1=a1 a0 +1 q1=a 1
pk =ak p k−1+ p k−2 q k =ak qk−1 +q k−2; for k =2 ,3 , … , n .
Then the k th convergent of the simple continued fraction [a0 ; a1 , … , an ] has the value
pk
C k= 0≤k ≤n
qk

Simple Infinite Continued Fractions

Definition: An infinite simple continued fraction (SICF) is a continued fraction of the form

12
1
a 0+
1
a 1+
1
a 2+
a3. + …
where a 0 , a 1 , a2 , … is an infinite sequence of integers, all positive except possibly for a 0.

We denote the SICF as [a0 , a1 , a2 ,… ].


As in the case of SCF C n=[ a 0 , a1 , a2 , … , an ] , n≥ 0 is the n+1th convergent of the infinite
continued fraction.

It is reasonable to define the value of the infinite continued fraction [a0 , a1 , a2 ,… ] to be the limit
pn
of the sequence of rational numbers C n= , provided of course, that this limit exists. That is
qn
[ a 0 , a 1 , a2 , … ]=nlim
→∞
[a0 , a1 , a2 , … , a n]=lim C n
n→∞

Theorem: For an SICF [ a 0 , a 1 , a2 , … ] ; nlim


→∞
C n exists for alln ≥ 0 where

C n=[ a 0 , a1 , a2 , … , an ]

we make the following definition.

Definition: If a 0 , a 1 , a2 , … is an infinite sequence of integers all positive except possibly a 0 , then


the infinite simple continued fraction (SICF) [a0 , a1 , a2 ,… ] as the value
lim [a 0 , a 1 , a2 , … , an ]=lim C n
n→∞ n →∞

Note: “simple” indicates that the partial denominators a k are all integers.

Let us compute the continued fraction of the irrational 1+ √ 2


1 1 1
1+ √ 2=2+ √ 2−1=2+ =2+ =2+
1 √ 2+1 √2+1
√ 2−1 √ 2−1 √ 2+1
Hence 1+ √ 2=[2,2,2 … .] so, √ 2=[1 ; 2,2,2 … .]

13
We see after 1 the partial denominator 2 repeats infinitely

If an infinite continued fraction, such as [ 3 ,1 , 2 ,1 , 6 , 1 ,2 , 1, 6 , … ] , contains a block of partial


denominators b 1 , b2 , … , bn that repeats indefinitely, the fraction is called periodic.

Definition: If an infinite continued fraction contains a block of partial denominators b 1 , b2 , … , bn


that repeats indefinitely, the fraction is called periodic continued fraction and is denoted as
[ a 0 ; a 1 , … , am , b1 , … , bn , b1 ,… , b n … ]=[ a 0 ;, … , am , b1 , … , bn ] where the overbar indicates that this
block of integers repeats over and over.

Remark: If b 1 , b2 , … , bn is the smallest block of integers that constantly repeats, we say that
b 1 , b2 , … , bn is the period of the expansion and that the length of the period is n . Thus, for
example, [3; 1 , 2 ,1 , 6] would denote [ 3 ;1, 2 , 1, 6 , 1 ,2 , 1 ,6 ,… ] , a continued fraction whose
period 1 ,2 , 1 ,6 has length 4.

Let us compute the irrational number representing the periodic fraction


[ 2 ,1 ]= [ 2 ; 1 ,2 , 1 ,2 , 1, … ]
1 x 3 x +2
x=[ 2 ; 1, x ] =2+ =2+ =
Let x=[ 2 ,1 ], Then 1 x +1 x +1
1+
x
3 x +2
∴ x= ⟹ x 2−x−1=0 , whose only positive root is x=1+ √ 3 .
x +1
Hence 1+ √ 3= [ 2 , 1 ] =[ 2; 1 , 2, 1 , 2, 1 , … ]

Theorem: The value of any infinite continued fraction is an irrational number.

That is nlim
→∞
C n is an irrational number.

Unlike representation of a rational as a continued fraction it can be shown that the representation
of an infinite continued fraction of an irrational is unique.

Having shown that every infinite continued fraction represents a unique irrational number we
now show that an arbitrary irrational number can be expended into an infinite continued fraction.

14
Continued Fraction Algorithm

Let x be an irrational number. We define the sequence of integers a 0 , a 1 , a2 , … follows:


Using the integer valued function, we first let
1 1 1
x=x 0 x 1= x 2= x3 = ……
x0 −[ x 0 ] x1 −|x 1| x 2− [ x 2 ]
Take
a 0=[x ¿¿ 0]a1 =[ x¿ ¿ 0]a2=[x ¿¿ 2]a3 =[ x3 ] … . .¿ ¿ ¿
In general, x k and a k are given inductively by
1 1
a k =[ x k ] x k +1= ⇒ x k =a k + ; k≥0
x k −ak x k+1
Through successive substitutions, we obtain
1 1 1
x=x 0=a0 + =a 0+ =a 0 + … … …=[a0 , a1 , a2 , … …]
x1 1 1
a 1+ a2+
x2 x3

The successive irrational numbers x k (and therefore the integers a k =[x k ]¿ can be computed
rather easily, with the calculations as shown in the following examples:

We compute the infinite continued fraction of x=√ 2 ≈1.414

x 0=√ 2=1+ ( √2−1 ) a0=1


1 1 √2+1 √2+1
x 1= = = = √ 2+1 ; a1= [ x 1 ]=[ √ 2+1 ] ; a1=2
x0 −[ x 0 ] √ 2−1 √2+1 2−1
1 1 1 √ 2+1
x 2= = = = √ 2+1=x 1
x1−[ x1 ] √ 2−1 √ 2−1 √ 2+1
Hence x 2=x 1 , also x 3=x 2 , x 4 =x3 , ; and so on, which means that the block of integer 2 repeats
indefinitely. √ 2 is periodic with the form
√ 2=[ 1 ; 2,2,2,2… ] =[1; 2]

1
As in the case of SCF the continued fraction representation of =[0 ; 1, 2]
√2

15
SOME APPLICATIONS

DESIGN OF A CALENDAR
Let us see an application of continued fractions to the design of a calendar. How
many days are in a year? A good answer is 365. However, astronomers tell us that
the Earth completes its orbit around the Sun in approximately 365.2422 days. The
continued fraction of this figure is
365.2422=[365 , 4 , 7 ,1 , 3 , 4 , 1,1 ,1,2]
The second convergent is
1
365.25=365+
4
which means a calendar of 365 days per year but a leap year every 4 years. The
forth convergent gives the better approximation
8
365.2424 …=[ 365 , 4 , 7 , 1 ] =365+
33

The Gregorian calendar, named after Pope Gregorio XIII who introduced it in
1582, is based on a cycle of 400 years: there is one leap year every year which is a
multiple of 4 but not of 100 unless it is a multiple of 400. This means that in 400
years one omits 3 leap years, thus there are
400.365+ 100−3=146097
days. On the other hand, in 400 years the number of days counted with

( 8
) ( 8
)
a year of 400 365+ 33 days is 400 365+ 33 =146096.9696 …

a very good approximation!

16
DESIGN A PLANETARIUM

Christiaan Huygens (1629–1695) among being a mathematician, astronomer,


physicist and probabilist, was also a great horologist. He designed more accurate
clocks than the ones available at his time.

His invention of the pendulum clock was a breakthrough in timekeeping. Huygens


also built a mechanical model of the solar system.

He wanted to design the gear ratios in order to produce a proper scaled version of
the planetary orbits. He knew that the time required for the planet Saturn to orbit
around the Sun is about

77708431
=29.425448 …=[29,2,2,1,5,1,4 , …]
2640858

206
The forth convergent is [ 29 , 2, 2 ,1 ] = 7

Therefore, Huygens made the gear regulating the Saturn’s motion with 206 teeth,
and the gear regulating Earth’s motion with 7 teeth, as shown in figure below.

17
ELECTRIC NETWORKS
The electrical resistance of a series of two resistances R1 and R2 is R1 +¿ R2

If R1 and R2 are instead in a parallel network then the resulting resistance R satisfies
1 1 1
= +
R R1 R2

Therefore, it follows easily that the resistance U of the circuit

Is given by

A similar kind of reasoning shows that the resistance of the infinite

18
circuit is given by the following continued fraction expansion

[R 0 , S1 , R 1 , S2 , R 2 , . . .]

Electric networks and continued fractions have been used to solve the “Squaring
the square” problem, which states: Is it possible to decompose an integer square
into the disjoint union of integer squares, all of which are distinct? The answer to
this problem is positive. Indeed, in 1978 Duijvestijn found a decomposition of the
122 × 122 square into 21 distinct integer squares as shown in the figure below.

Furthermore, there are no solutions with less than 21 squares, and Duijvestijn’s
solution is the only with 21 squares (see [3]).

19
PAPER FOLDING
The number √ 2 appears in the A series paper sizes. Precisely, since √ 2is twice its
inverse, i.e., √ 2 = 2/ √ 2, folding a rectangular piece of paper with sides in
proportion √ 2 yields a new rectangular piece of paper with sides in proportion √ 2
again. The sizes of an A0 paper are defined to be in proportion √ 2 and so that the
area is 1 m2 . Thus, rounded to the nearest millimetre, an A0 paper is 841 by 1189
millimetres. Note that

841 29
= =[ 1, 2 , 2,2 ]
1189 49

is the fifth convergent of √ 2. The sizes of A1, A2, A3, and so forth are defined by
successively halving the A0 paper, as in Fig. 7. The Golden Ratio Φ has a similar
property. If we start with a rectangle with Golden Ratio proportion, then we can
fold it in order to get a square and a smaller rectangle which sizes are again in
Golden Ratio proportion, as shown in Fig. 8.

In fact, the Golden Ratio is the unique number with this property

20
THE IRRATIONALITY OF √ 2
We discuss some “geometric” proofs of the irrationality of √ 2
 Start with a rectangle having side lengths 1 and 1+ √ 2 (see Fig. 9).
 Decompose it into two squares of sides 1 and a rectangle of sides 1 and
1+ √ 2−2=√2−1
1
 The second rectangle has sides in proportion =1+ √ 2
√2−1

hence it can be decomposed in two squares and a rectangle whose sides are
again in 1+ √ 2 proportion.

This process does not end.

Therefore, 1+ √ 2 is irrational, and so is √ 2

If we start with a rectangle having integer side lengths, then it is clear that the
process stops after finitely many steps (the side lengths of the successive rectangles
produce a decreasing sequence 74 of positive integers).

The same conclusion holds for a rectangle with side lengths in rational proportion
(reduce to a common denominator and scale).
We give a proof in just one dimension:

21
 Start with an interval of length t=1+ √ 2 (see Fig. 10).

 Decompose it in two intervals of length 1 and one interval of length √ 2−1=¿


1/t.

 The smaller interval can now be split in two intervals of length 1/t 2 and one
of length 1/t 3

 This process does not stop.

 Thus, we get again that √ 2 is irrational

Reasoning in a way similar, it follows that if the interval length is a rational


number then the process must stop.

RAMANUJAN’S CONTRIBUTION
22
Ramanujan was a world expert on continued fractions. He found
exquisite expressions for the golden ratio, the number phi; which,
he found was nothing but one plus one divided by one plus one
divided by, and you go on forever.

Ramanujan’s publication, titled “Modular Equations and


Approximations to π”, which he wrote in 1914, contained seventeen
different elegant series that converged rapidly to π. According to him,
the the value of π can be expressed as continued fractions with
remarkable patterns.

PYTHON PROGRAM FOR FINDING CONVERGENT


sage: def confract(x,k):

23
... cf=[]
... q=x//k
... cf.append(q)
... r=x%k
... while r!=0:
... x=k
... k=r
... q=x//k
... cf.append(q)
... r=x%k
... print(cf)
sage: confract(45,29)
[1, 1]
[1, 1, 1]
[1, 1, 1, 4]
[1, 1, 1, 4, 3]

PYTHON PROGRAM FOR FINDING SIMPLE CONTINUED FRACTION

24
sage: def confract(x, k):
... cf=[]
... q=x//k
... cf.append(q)
... r=x%k
... while r!=0:
... x=k
... k=r
... q=x//k
... cf.append(q)
... r=x%k
... return cf
sage: confract(45,29)

[1, 1, 1, 4, 3]

REFERENCES

25
 Elementary Number Theory, David Burton, Tata MacGraw Hill

 Elementary Number Theory and its Application, Kenneth H Rosen

 https://www.math.ru.nl/~bosma/Students/CF.pdf

 http://archives.math.utk.edu/articles/atuyl/confrac/history.html

 file:///C:/Users/Spectrum/Downloads/5_6186088941716767782.pdf

 http://www.rnta.eu/SecondRNTA/Waldschmidt-Sanna.pdf

 https://thefederal.com/features/ramanujans-enchanting-journeys-in-the-
maze-of-continued-fraction/

26

You might also like