# CONTINUED FRACTIONS AND FACTORING by lff30040

VIEWS: 58 PAGES: 23

• pg 1
```									CONTINUED FRACTIONS AND FACTORING

Niels Lauritzen
ii

N IELS L AURITZEN
D EPARTMENT OF M ATHEMATICAL S CIENCES
U NIVERSITY OF A ARHUS , D ENMARK

E MAIL : niels@imf.au.dk
URL: http://home.imf.au.dk/niels/
Contents

1   Factoring using continued fractions                                                             1
1.0.1 The Fermat-Kraitchik method . . . . . . . . . . . . . .                              1

2   Continued fractions                                                                              5
2.1 The game that might never stop . . . . . . .        .   .   .   .   .   .   .   .   .   .    5
2.1.1 Rational numbers . . . . . . . . . . .        .   .   .   .   .   .   .   .   .   .    6
2.2 Basic theory of continued fractions . . . . .       .   .   .   .   .   .   .   .   .   .    7
2.3 Eulers rule and corollaries . . . . . . . . . .     .   .   .   .   .   .   .   .   .   .    8
2.4 Continued fraction for a real number . . . .        .   .   .   .   .   .   .   .   .   .   10
2.5 Quadratic irrationalities . . . . . . . . . . .     .   .   .   .   .   .   .   .   .   .   11
Ô
2.5.1 Purely periodic continued fractions           .   .   .   .   .   .   .   .   .   .   12
2.6 The continued fraction for Æ . . . . . . .          .   .   .   .   .   .   .   .   .   .   15
2.7 A few words on Pells equation . . . . . . .         .   .   .   .   .   .   .   .   .   .   16

3   Exercises                                                                                       17
3.1 In class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                      17
3.2 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                          17

iii
iv   CONTENTS
Chapter 1

Factoring using continued
fractions

The statement that every integer can be written as a product of prime num-
bers is a typical mathematical statement with a simple proof. Things be-
come much more complicated when you (inspired by Gauss) ask for a good
algorithm for factoring a given integer Æ . ÔIn a non-trivial factorization
Æ        one of the factors and must be          Æ . If Æ is even ¾ divides and
we have found a factor. If Æ is odd we may ﬁnd a Ô      factor of Æ , by starting
with ¿ and try dividing with odd numbers up to Æ . This procedure is
called trial division. The number of steps in trial division is proportional to
the smallest prime factor Ô. This is extremely slow. If you want to factor
a ½¼¼ digit number, which is the product of two ¼ digit prime numbers,
you must carry out approximately ½¼ ¼ steps of trial division. If every step
takes ½¼ ½¼ seconds, you will have to wait for ½¼ ¼ seconds (or approxi-
mately ½¼¿¾ years). There are better algorithms.

1.0.1 The Fermat-Kraitchik method
Currently the most effective algorithms for factoring “difﬁcult integers”
originates in the historic fact that if an integer Æ can be written as the dif-
ference Ü¾   Ý ¾ between two squares, we have the factorization
Æ    Ü¾   Ý¾    ´   Ü · Ýµ´Ü   Ýµ
On the other hand if an odd number Æ           ÙÚ is composite, then
Ù·Ú ¾                  ¾
Æ
¾
Ù Ú
¾

This method of factoring goes back to Fermat. Suppose we wish to factor
Æ . Fermat’s method would start with the function
Ë ´Üµ   Ü¾   Æ
1
2          CHAPTER 1. FACTORING USING CONTINUED FRACTIONS

and search for Ü, such that Ë ´Üµ Ý ¾Ô square. Usually one runs through
Ô          Ô                       is                                   Ô
Ü      Æ Ü        Æ · ½ , where Æ denotes the integral part of Æ .
Putting Æ     ¾ ½, one would ﬁnd Ë ´ µ             ¼ Ë ´ ¼µ            ¿ ¾ . This
means that ¾ ½ ´ ¼ · ¿µ´ ¼   ¿µ           ¿¡   . Of course using this method
on a composite number (like ¾   ½¼¼¼ ) works just as terribly as trial division.
There is a beautiful variation of Fermat’s method (due to M. Kraitchik
(1882–1957)) using congruences. The insight is that it usually sufﬁces that
Æ divides Ü¾   Ý¾ to ﬁnd a factor of Æ . This means that
Æ Ü¾   Ý¾            ´  Ü · Ýµ´Ü   Ýµ
Now if Æ does not divide any of Ü · Ý and Ü   Ý , then we may conclude that
´Ü · Ý Æ µ     ½ and use the Euclidean algorithm to ﬁnd         ´Æ Ü · Ý µ,
which is a non-trivial factor of Æ . So one should look for solutions Ü, Ý such
that

Ü¾         Ý¾ ´ÑÓ Æ µ
Ü         ¦Ý ´ÑÓ Æ µ
Suppose we have collected Ü ½         ÜÒ , such that Ü¾ ½              ½ ´ÑÓ Æ µ             Ü¾
Ò

Ò ´ÑÓ Æ µ for some integers ½             Ò . If a subset         ½            Ö of   ½ ¾        Ò

satisifes that ½ ¡ ¡ ¡ Ö is a square, then

´Ü ½ ¡ ¡ ¡ Ü Ö µ¾        ½   ¡¡¡   Ö ´ÑÓ   Æµ
and we have our congruence Ü¾   Ý¾ ´ÑÓ Æ µ. This congruence may or
may not satisfy Ü ¦Ý ´ÑÓ Æ µ. To tell if a number Ò is square we factor
it
Ò        ÔÒ½
½       ÔÒÖ
Ö

using some predeﬁned factor basis È         Ô½     ÔÖ of (small) prime num-
bers. Now Ò is a square if and only if all the exponents Ò ½     ÒÖ are even.

Exercise 1.0.1 Suppose that the prime factorizations of ½        Ò over the

factor basis È (assume all a’s factor completely using primes from È ) are

½       ÔÑ½½ ¡ ¡ ¡ ÔÑ½Ö
½          Ö

¾       Ô½ ¡ ¡ ¡ ÔÑ¾Ö
Ñ¾½
Ö

.
.
.
Ò       ÔÑÒ½ ¡ ¡ ¡ ÔÑÒÖ
½          Ö

Use linear algebra over         ¾       to ﬁnd a subset       ½        Ö   of   ½ ¾     Ò such
that ½ ¡ ¡ ¡ Ö is a square.
3

Let us apply this to the numbers we get from the function Ë ´Üµ Ü ¾  Æ .
Notice that Ü¾ Ë ´Üµ ´ÑÓ Æ µ. We wish to ﬁnd values Ü½           ÜÒ , such that
the product of a suitable subset of the numbers Ë ´Ü ½ µ   Ë ´ÜÒ µ is a square.
For Æ ¾¼ ½ (this example is from [1]) we illustrate this in the table below

Ü Ü¾   Æ        Factorization
¢        ¾     Ô
Marked
46
47
75
168        ¾
¿
¿¢¿¢             Ô
48
49
263
360       ¾¿ ¢ ¿¾ ¢
¾ ¿
Ô
¿¿ ¢ ½
50
51
459
560        ¾   ¢ ¢           Ô

The above table shows that Ë ´ µË ´ µË ´ µË ´ ½µ            ¡½ ¡¿ ¼¡ ¼
´¾ ¡ ¿ ¾ ¡ ¾ ¡ µ¾ is a square. Putting Ù       ¾ ¡ ¿ ¾ ¡ ¾ ¡ , we get Ù¾
¼ ¼¼¾    ½ ½ ¾ ´ÑÓ ¾¼ ½µ. Now we know that Ù ¾        Ú¾ ´ÑÓ ¾¼ ½µ where
Ú       ¡ ¡ ¡ ½ ¼¾ ¿ ¿½½ ´ÑÓ ¾¼ ½µ. Using the Euclidean algo-
rithm one ﬁnds the greatest common divisor of Ù   Ú ½ ½   ¿½½ ½½¼
and ¾¼ ½, which is ½¿. We have found the factorization ¾¼ ½          ½¿ ¡ ½ .
Using the original method of Fermat we would have to wait until Ü           ¼
before having a subset whose product is a square. The heavy part of the
algorithm is factoring Ë ´Üµ     Ü¾   Æ . Around 1982 Pommerance discov-
ered a nice trick to avoid this. The observation is that a prime power Ô Ö
divides Ë ´Üµ if and only if it divides Ë ´Ü · ÔÖ µ, where ¾ . So if one
can locate a number Ü such that ÔÖ Ë ´Üµ, then we know in advance that
ÔÖ Ë ´Ü · ÔÖ µ Ë ´Ü · ¾ÔÖ µ . This is a socalled sieving procedure (like the
sieve of Eratosthenes eliminating multiples of prime numbers). It leads to
the factorization algorithm called the quadratic sieve. In [1] you can ﬁnd a
nice description of this and other sieving methods for factoring. These are
currently the most effective factoring the challenges issued by RSA. In fact
the RSA challenge with ½ digits was factored using sieving.
We will however describe the champion of factoring preceeding the
quadratic sieve, the continued fraction algorithm. This is in order to get
involved in some fantastic 19th century mathematics and show how an
idea from the heart of mathematics can be applied in easing factoring.
The problem with Fermats method is that Ë ´Üµ         Ü ¾   Æ grows too
rapidly. It takes longer and longer to factor Ë ´Üµ. One can instead use
Ô       Ô
“convergents” ×Ò ØÒ in the continued fraction expansion of Æ (or           Æ,
where ¾ Æ ). Then one tries the above method for factoring successively
using the numbers

ÜÒ     ×Ò
ÝÒ     ×¾   ÆØ¾
Ò     Ò
4         CHAPTER 1. FACTORING USING CONTINUED FRACTIONS

Clearly Ü¾
Ò    ÝÒ ´ÑÓ   Æ µ. From the theory of continued fractions one gets
the inequality                         Ô
ÝÒ    ¾    Æ
Exercise 1.0.2 Prove this inequality after having read about continued frac-
tions in the next chapter.
Chapter 2

Continued fractions

2.1 The game that might never stop

Let Ü denote the largest integer Ü, where Ü ¾ Ê is a real number. For a
given real number we wish to decide if is rational. Clearly this is true if
. If not, we may write

½
·                   ·
½

½
Now put     ½          . If   ½       ½ , was a rational number. If not we put
½
¾
½  ½
and write

½
·
½
½   ·
¾
We continue this and cook up new real numbers ¿            and stop if Ò
Ò  for some Ò. This game is called the continued fraction algorithm for a
real number. The game never stops if is an irrational number.

Exercise 2.1.1 Prove this!

Example 2.1.2 The ﬁrst steps of the continued fraction algorithm for leads

5
6                                 CHAPTER 2. CONTINUED FRACTIONS

to the following “continued fraction”

½
¿·
½
·
½
½ ·
½
½·
½
¾ ¾·

where is an irrational number.
Ô
Example 2.1.3 The continued fraction algorithm for ¾ can be carried out
by algebraic computations. Here is how. First we rewrite a bit
Ô
¾    ½·
½
½·   Ô½
Ô½                             ¾·½
¾ ½
Ô
Now we have an expression for          ¾   that “bites its own tail”. Let us insert it
into itself:
Ô                   ½                                   ½
¾    ½·                                 ½·
½·   Ô½        ·½                    ¾·   Ô½
¾·½                                     ¾·½

We can repeat this to get the “continued fraction”

½
½·
½
¾·
½
¾·
½
¾·
½
¾·
¡¡¡
Ô
In this way we have proved that        ¾   is irrational or have we?

2.1.1 Rational numbers
The continued fraction algorithm for rational numbers turns out to be the
classical Euclidean algorithm. This is quite easy to see. Consider a fraction
, where     ¼. Then     Õ · Ö and          Õ. Therefore
Ö                ½
Õ·            Õ·
Ö
2.2. BASIC THEORY OF CONTINUED FRACTIONS                                                                     7

and the continued fraction algorithm continues with the fraction                                 Ö. Ulti-
mately this process will stop.

Example 2.1.4 Consider the fraction ½¼¿ ¿ ¿¿½¼¾. Division with remain-
der gives ½¼¿ ¿ ¿ ¡ ¿¿½¼¾ ·       . This implies that

½¼¿       ¿                                      ½
¿·                   ¿·
¿¿½¼¾                   ¿¿½¼¾                ¿¿½¼¾

Again ¿¿½¼¾         ¡        · ¾ ¿,     Therefore

½                        ½
¿·                   ¿·
¿¿½¼¾                       ¾ ¿
·

Continue with             ½    ¡¾      ¿ · ¾ ¾:

½                    ½                           ½                                 ½
¿·                  ¿·                       ¿·                               ¿·
¾ ¿                      ½                           ½                                 ½
·                   ·                           ·                                ·
¾ ¾                               ½
½ ·                              ½ ·
¾ ¿                                 ¾ ¿                                   ½
½·
¾ ¾

2.2 Basic theory of continued fractions
A continued fraction is formally a sequence of integers ¼ ½        Ò    ,
where    ¾ and          ¼ for    ¼. There is a one to one correspondence
between continued fractions and real numbers. This is displayed in the
notation
½
¼·                                                                    ( £)
½
½·
½
¾·                  ½
¿ · ¡¡¡
to be understood as the following sequence of numbers

½                   ½                            ½
¼   ¼·             ¼·                     ¼·
½                       ½                           ½
½·                       ½·
¾                               ½
¾·
¿
Does this make sense? Does this sequence converge (to a real number)? We
need to compute a bit more to answer this question.
8                                       CHAPTER 2. CONTINUED FRACTIONS

2.3 Eulers rule and corollaries
The above sequence of (honest) fractions are called convergents for the con-
tinued fraction in (£). What are the fractions? Before we compute them
let us make a subtle observation.Denote the numerator of the Ò-th conver-
gent of a continued fraction Ü½ Ü¾ Ü¿     by Ü½ Ü¾       ÜÒ . Then the Ò-th
convergent is
Ü½ Ü¾       ÜÒ               Ü             ÜÒ
Ü½ · ¿
Ü¾        ÜÒ                Ü¾            ÜÒ
Therefore
Ü½ Ü¾      ÜÒ        Ü½ Ü¾       ÜÒ    ·   Ü¿        ÜÒ
Using this we get

½
Ü½    Ü½
Ü½   Ü¾    Ü½ Ü¾ · ½
Ü½   Ü¾   Ü¿    Ü½ Ü¾ Ü¿ · Ü½ · Ü¿
Ü½   Ü¾   Ü¿   Ü     Ü½ Ü¾ Ü¿ Ü · Ü¿ Ü · Ü¾ Ü¿ · Ü½ Ü¾ · ½
Ü½ Ü¾   Ü¿   Ü    Ü     Ü½ Ü¾ Ü¿ Ü Ü · Ü¿ Ü Ü · Ü½ Ü Ü · Ü½ Ü¾ Ü              ·   Ü½ Ü¾ Ü¿ · Ü½ · Ü
Notice that Ü½ Ü¾ Ü¿ Ü Ü          Ü Ü Ü¿ Ü¾ Ü½ . This is a very pleasant
surprise and it holds in general! In fact we have the following result.

Proposition 2.3.1 (Eulers rule) Ü½ Ü¾        ÜÒ is a sum of terms constructed
from Ü½ Ü¾ ¡ ¡ ¡ ÜÒ by ﬁrst deleting ¼ consecutive variables, then deleting ¾
consecutive variables, then and so on.
Proof. Follows by induction using

Ü½ Ü¾      ÜÒ        Ü½ Ü¾       ÜÒ    ·   Ü¿        ÜÒ
£
Corollary 2.3.2

Ü½ Ü¾       ÜÒ          ÜÒ ÜÒ ½            Ü½
Corollary 2.3.3

¼ ½        Ò      Ò    ¼         Ò ½    ·    ¼        Ò ¾
Exercise 2.3.4 Write the continued fraction for a fraction Ù Ú , where Ù
Ú ¼ as ¼ ½            Ò ½      ½ ¾       Ò ½   , where          ´Ù Ú µ. Con-
clude that if the Euclidean algorithm requires precisely Ò steps for Ù and
2.3. EULERS RULE AND COROLLARIES                                                                                      9

Ú, then Ù         Ò   ·¾ and Ú                   denotes the Ò-th Fibonacci
Ò   ·½ , where           Ò

number. Here is the list of the ﬁrst few Fibonacci numbers

½ ½ ¾ ¿                  ½¿ ¾½ ¿

How many steps of the Euclidean algorithm do                                       Ù          Ò   ·¾ and Ú        ·½
Ò

take?
If we denote the numerator and denominator of the Ò-th convergent × Ò
and ØÒ respectively, then we have the inductive formula

×Ò              ×  ½ · ×Ò ¾
Ò Ò

ØÒ            Ò ØÒ ½ · ØÒ ¾

where we put ×  ¾           ¼   × ½         ½   Ø ¾         ½   Ø ½           ¼.

Remark 2.3.5 The sequence of denominators ´Ø Ò µ is a strictly increasing se-
quence of natural numbers.
Ô
Example 2.3.6 Here is the beginning of the continued fraction for                                            ¾.

-2         -1    0      1       2         3         4     5
1      2       2         2         2     2
×        0         1     1      3       7        17        41    99
Ø        1         0     1      2       5        12        29    70

Example 2.3.7 Here are the ﬁrst convergents in the continued fraction for
(cf. Example 2.1.2).

-2        -1    0          1         2         3
3          7        15         1
×         0         1     3         22       333       355
Ø         1         0     1          7       106       113

We recognize in particular ¾¾ as the archimedian approximation to . Less
known is ¿ , which is a much better approximation. In fact
½¿¿
¿
¿½ ½            ¾
½½¿

whereas      ¿½ ½           ¾   ¿           .

Proposition 2.3.8
×ÒØÒ·½   ×Ò·½ ØÒ ´ ½µÒ·½
The numerator ×Ò and denominator ØÒ in a convergent ×Ò ØÒ are relatively
prime integers.
10                                  CHAPTER 2. CONTINUED FRACTIONS

Proof. Write ×Ò·½      ×
Ò Ò   ·×Ò ½ and ØÒ·½ Ò ØÒ · ØÒ ½ . Then
×Ò ØÒ·½   ×Ò·½ ØÒ ×Ò´ Ò ØÒ · ØÒ ½µ   ´ Ò ×Ò · ×Ò ½ µØÒ
´×Ò ½ØÒ   ×ÒØÒ ½µ
and the result follows by induction. Notice that ×  ¾ Ø ½   × ½ Ø ¾       ½. £
Corollary 2.3.9 We have the following inequalities
×¼   ×½    ×¾
Ø¼   Ø½    Ø¾
¡¡¡
×¼   ×¾    ×
Ø¼   Ø¾    Ø
¡¡¡
×½   ×¿    ×
Ø½   Ø¿    Ø
¡¡¡
The even convergents form an increasing sequence bounded above by × ½ Ø½
and the odd convergents form a decreasing sequence bounded below by
×¼ Ø¼ .
By elementary real analysis both sequences ´× ¾Ò Ø¾Ò µ and ´×¾Ò·½ Ø¾Ò·½ µ
have a limit. In fact they converge to the same number. This is a result of
the following computation.

Lemma 2.3.10
×Ò ×Ò·½

ØÒ ØÒ·½
½
Ø¾
Ò

Proof.
×Ò ×Ò·½          ×Ò ØÒ·½   ØÒ ×Ò·½

ØÒ ØÒ·½               ØÒØÒ·½
½
Ø¾
Ò

by Proposition 2.3.8 and since ØÒ is an increasing sequence of natural num-
bers. £

2.4 Continued fraction for a real number
We pose a very relevant question. When we do the continued fraction al-
gorithm for a real number , we get a continued fraction. What does this
continued fraction have to do with ? The answer is that the convergents
(surprise!) converge to . Here is how to prove this. Consider the continued
fraction algorithm for after Ò steps
½
¼·
½
½·                  ½
¾·
½
¡¡¡      Ò   ·
Ò
2.5. QUADRATIC IRRATIONALITIES                                                    11

This means that         ¼ ½      Ò   Ò   ½      Ò   Ò . Similarly to Lemma

2.3.10, we get the following result showing that the convergents really do
converge to .

Proposition 2.4.1
×
Ø
Ò           ½
Ø¾
Ò           Ò

Proof. We may write
× · ×Ò ½
Ò Ò

Ò ØÒ · ØÒ ½

where         Ò   ¼.   Using this, a small computation shows what we want. £

A quadratic irrationality « is a non rational real root in a quadratic equation

Ü¾ · Ü ·                 ¼                  ( £)

where                  ¾   .

Deﬁnition 2.5.1 If « is a quadratic irrationality, which is a root of (£), then
we let «¼ denote the other root of (£). The other root is called the (algebraic)
conjugate of «.

Proposition 2.5.2 Let          « be a quadratic irrationality and Õ   ¾   an integer.
Then

i)    ½    « is a quadratic irrationality.
ii)    « · Õ is a quadratic irrationality.
iii)    ´   « · Õµ¼    «¼ · Õ and ´½ «µ¼    ½      «¼ .
Proof. Exercise. £
The above proposition shows that if « is a quadratic irrationality and

½
«       Õ·
«½
where Õ      « , then «½ is also a quadratic irrationality. In other words: all
the steps in the continued fraction algorithm produce quadratic irrational-
ities when starting out with one. If « is a quadratic irrationality, then
Ô
È¦
«
É
12                                   CHAPTER 2. CONTINUED FRACTIONS

for È É     ¾ , where         ¼. To carry out the ﬁrst step in the continued
fraction algorithm, ﬁrst observe that
Ô
«
È·   ¦
É
Exercise 2.5.3 Prove this!

So if we have a good algorithm (we do) for ﬁnding “the ﬂoor” of the
square root of an integer we are all set. Let us analyze the “inversion” step
in the continued fraction algorithm. Here
Ô
È
Ô
½

È·            È¾
É             É
Notice that É   È¾       , since È             ¾        and É ¾ , where
« ¾· «·            ¼ and         ¾ . These observations give a very ex-
plicit integer algorithm for computing the continued fraction of a quadratic
irrationality. But we are not satisﬁed! We will dive into the mind blowing
theory of continued fractions in the 19th century proving a beautiful result
of Galois.

2.5.1 Purely periodic continued fractions
Deﬁnition 2.5.4 A quadratic irrationality « is called reduced if

i)   «   ½

ii)    ½ «¼    ¼

Ô                               Ô                  Ô                  Ô
Example 2.5.5 ¾ is not reduced since ´ ¾µ¼
Ô         Ô                                      Ô¾     ½.  But ½ · ¾
is reduced as ´½ · ¾µ¼
Ô                  ½   ¾. In general                    Õ¼ · Æ    is reduced where
Õ¼      Æ.
A continued fraction of the form       ¼ ½                 Ò   ¼ ½     is called purely
periodic.

Example 2.5.6 Consider the real number ³ given by the “simplest” purely
periodic continued fraction ½ ½ ½ ½

½
³       ½·
½
½·
½
½·
¡¡¡
2.5. QUADRATIC IRRATIONALITIES                                                       13

Therefore ³¾   ³   ½
½
Then ³     ½·                                        ¼   and
³
Ô
³
½   ¦
¾

Some will recognize the · part as the golden ratio. The golden ratio is a

Lemma 2.5.7 If « is a reduced quadratic irrationality and

½
«      Õ¼ ·
«½
where Õ¼    « . Then «½ is a reduced quadratic irrationality.
Proof. Exercise. £

Theorem 2.5.8 (Galois) ¾ Ê has a purely periodic continued fraction if
and only if is a reduced quadratic irrational.

Proof. Suppose that       ¾ Ê has a purely periodic continued fraction.             This
means that
½
¼·
½
½·                        ½
¾·
½
¡¡¡        Ò   ·

for some Ò. Then
×Ò · ×Ò ½
ØÒ · ØÒ ½
and must be a quadratic irrationality, since

ØÒ ¾ · ´ØÒ ½   ×Òµ          ×     Ò    ½          ¼

But why is it reduced? This is tricky. In fact one has to pull out a genuine
trick to solve this. Consider the number ½ given by reversing the period of
:
½
½      Ò   ·
½
Ò    ½ ·                           ½
Ò    ¾ ·
½
¡¡¡         ¼·
½
14                                               CHAPTER 2. CONTINUED FRACTIONS

Then

¼          Ò       ¼ ½                 Ò       ¼ ½·         Ò         ½
Ò ½          ¼ ½            Ò ½         ¼ ½·          ½
Ò             ½
×Ò ½ · ØÒ
×Ò ½ ½ · ØÒ ½
and
¾
×Ò ½ ½ · ´ØÒ ½   ×Ò µ ½   ØÒ             ¼

This shows that ¼      ½ ½ , so that  ½ ¼ ¼. We have proved that a
purely periodic continued fraction describes a reduced quadratic irrational.
Let us prove the other way.
Suppose that is a reduced quadratic irrational. Then
Ô                                 Ô
È·                      ¼   È
Ò
É                           É
We may conclude ﬁrst that É    ¼ (consider                                 ¼ ), then È           ¼   and the
important boundedness conditions
Ô
i)   È
Ô
ii)   É       ¾

on È and É by using that is reduced. Let us run through one step of the
continued fraction algorithm. First let Õ  . Then
Ô
È   ÕÉ ·
Õ             É
Next step is to compute the reduced (recall Lemma 2.5.7) quadratic irra-
tionality
Ô
É                       É´ ´È   ÕÉµ ·
½
½
Ô               Ô                         ´È   ÕÉµ¾
µ
È   ÕÉ ·          È   ÕÉ ·
É
So putting È½              ÕÉ   È     and É½      ´         È½¾µ É we get
Ô
È½ ·
½       É½
Now we continue the algorithm with ½ . Since there are only ﬁnitely many
possibilities for È and É (there are only ﬁnitely many pairs ´È Éµ of natural
Ô           Ô
numbers satisfying È           É ¾ ), we will eventually run into a rep-
etition Ñ      Ò for Ñ   Ò. We will prove that this implies Ñ ½ Ò ½ . This
Ô
2.6. THE CONTINUED FRACTION FOR                               Æ                                   15

leads to the purely periodic continued fraction ¼ ½         Ò Ñ                           ¼ ½       .
In the Ò-th step of the continued fraction algorithm we have

½
Ò       Ò   ·
Ò·½

½
¼
½ Ò·½
This implies that     Ò             ¼      , since Ò                                 Ò   · ½.   So if
Ò   ·½
Ñ      Ò , we get  Ñ ½                 Ò ½ and therefore that Ò ½ . This
Ñ ½

ﬁnally shows that a reduced quadratic irrationality has a purely periodic
continued fraction. £

Ô
2.6 The continued fraction for                                    Æ
Example 2.6.1 With enough patience one can compute that
Ô
½       ¿ ½ ¾ ½          ½ ¾ ½
Ô
½          ¾ ½ ¿ ½ ¾             ¾ ½ ¿ ½ ¾

The example shows a pattern in the continued fraction for the square
root. It seems that it repeats itself after encountering ¾ ¼ . It also seems to
be symmetric around a “middle”. This is no coincidence:

Theorem 2.6.2 Let Æ be a natural number, which is not a square. Then

Ô                                        ½
Æ       Õ¼ ·
½
Õ½ ·
½
¡¡¡ ·                      ½
ÕÒ ·
½
¾Õ¼ ·
½
Õ½ ·
¡¡¡
where Õ½    ÕÒ Õ¾       ÕÒ ½
Ô                                             Ô
Proof. Let Õ¼     Æ . Then we know that Õ¼ · Æ has a purely periodic con-
Ô
tinued fraction by Theorem 2.5.8. Thus Æ ·Õ¼ ¾Õ¼ Õ½        ÕÒ ÔÕ¼ Õ½ .
¾
This proves the ﬁrst statement. Consider now the conjugate   Æ · Õ¼ of
Ô
Æ · Õ¼ . Then

Ô½      Õ Õ                       ½        Õ½ ¾Õ¼ ÕÒ
Æ · Õ¼                  Ò   Ò
16                                           CHAPTER 2. CONTINUED FRACTIONS

This implies that
Ô
Æ        Õ¼ ÕÒ ÕÒ ½                    Õ½ ¾Õ¼ ÕÒ
Ô
By uniqueness of the continued fraction for                              Æ   we get   Õ½         ÕÒ , Õ¾
ÕÒ ½ . £

2.7 A few words on Pells equation
This is the diophantine equation

Ü¾   ÆÝ¾               ½                                          (£)

where Æ is a natural number, which is not a square. It would be a shame
not to mention the elegant way of giving integer solutions to (£) using the
Ô
continued fraction expansion of Æ . Using the notation of Theorem 2.6.2,
we get (in the usual way)
Ô                    Ô
Õ¼ · Æ µ×Ò · ×Ò ½
Æ
´
Ô
´Õ¼ · Æ µØÒ · ØÒ ½

Multiplying this out leads to

×Ò ½        ÆØÒ   Õ¼ ×Ò
ØÒ ½        ×Ò   Õ¼ ØÒ
Now

×Ò ½ ØÒ   ×ÒØÒ ½       ´   ÆØÒ   Õ¼ ×ÒµØÒ   ×Ò ´×Ò   Õ¼ ØÒ µ                    ÆØ¾   ×¾
Ò    Ò

We conclude that

×¾   ÆØ¾
Ò     Ò                   ½ µ  ´ ½µÒ ´ ½µÒ·½
´×  ½Ø   × Ø
Ò       Ò       Ò Ò

Example 2.7.1 Consider the equation Ü¾   ½ Ý ¾      Ô
½. To ﬁnd an integer
solution we consider the continued fraction expansion for                                ½   :
Ô
½               ¾ ½ ¿ ½ ¾             ¾ ½ ¿ ½ ¾

and compute the convergents

-2      -1       0       1    2         3        4        5      6
4       2    1         3        1        2      8
×      0      1        4       9   13        48       61      170   1421
Ø      1      0        1       2    3        11       14       39    326
One checks that
½ ¼
¾ ½          ¡¿   ¾        ½
Chapter 3

Exercises

3.1 In class
1. Compute the continued fraction expansion of      ¿ .
2. Write down the exact steps in an Ô
integer algorithm for computing the
continued fraction expansion of Æ .
Ô               Ô
3. Compute the continued fraction expansions of           ¿   and       .

4. Find an integer solution to the equation Ü ¾   ½½Ý ¾        ½.

3.2 Homework
1. Solve all exercises in chapters ½ and ¾ (don’t forget the proofs).

Ô
2. Invent an integer algorithm to compute the continued fraction expan-
sion for ¿ ¾. Compute the ﬁrst ½¼¼ q’s in the continued fraction. The
sad state of affairs in mathematics is that it is unknown even if the q’s
are bounded. 1

1
Do this exercise if you have time to spare.

17
18   CHAPTER 3. EXERCISES
Bibliography

[1] C. Pomerance, A tale of two sieves, Notices of the American Mathemati-
cal Society 43 (1996), 1473–1485.

19

```
To top