Pell s equation. Michel Waldschmidt

Similar documents
18-29 mai 2015: Oujda (Maroc) École de recherche CIMPA-Oujda Théorie des Nombres et ses Applications. Continued fractions. Michel Waldschmidt

Notes on Continued Fractions for Math 4400

CONTINUED FRACTIONS, PELL S EQUATION, AND TRANSCENDENTAL NUMBERS

Prime Numbers and Irrational Numbers

Factorization in Integral Domains II

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

NOTES ON FINITE FIELDS

Introduction to Number Theory

Math 118: Advanced Number Theory. Samit Dasgupta and Gary Kirby

Explicit Methods in Algebraic Number Theory

NORM OR EXCEPTION? KANNAPPAN SAMPATH & B.SURY

Course 2316 Sample Paper 1

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

Solving x 2 Dy 2 = N in integers, where D > 0 is not a perfect square. Keith Matthews

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

1. Factorization Divisibility in Z.

Moreover this binary operation satisfies the following properties

not to be republished NCERT REAL NUMBERS CHAPTER 1 (A) Main Concepts and Results

MA257: INTRODUCTION TO NUMBER THEORY LECTURE NOTES

NUMBER SYSTEMS. Number theory is the study of the integers. We denote the set of integers by Z:

Factorization in Polynomial Rings

THE UNIT GROUP OF A REAL QUADRATIC FIELD

2 Lecture 2: Logical statements and proof by contradiction Lecture 10: More on Permutations, Group Homomorphisms 31

Summary Slides for MATH 342 June 25, 2018

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

CONTINUED FRACTIONS. 1. Finite continued fractions A finite continued fraction is defined by [a 0,..., a n ] = a 0 +

arxiv:math/ v3 [math.nt] 23 May 2008

φ(xy) = (xy) n = x n y n = φ(x)φ(y)

ECEN 5022 Cryptography

Public-key Cryptography: Theory and Practice

Math 2070BC Term 2 Weeks 1 13 Lecture Notes

Winter Camp 2009 Number Theory Tips and Tricks

LEGENDRE S THEOREM, LEGRANGE S DESCENT

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

1 Continued Fractions

THUE S LEMMA AND IDONEAL QUADRATIC FORMS

Chapter 8. P-adic numbers. 8.1 Absolute values

MATH 4400 SOLUTIONS TO SOME EXERCISES. 1. Chapter 1

HASSE-MINKOWSKI THEOREM

MATH 3030, Abstract Algebra FALL 2012 Toby Kenney Midyear Examination Friday 7th December: 7:00-10:00 PM

Numbers, Groups and Cryptography. Gordan Savin

Continued fractions for complex numbers and values of binary quadratic forms

Part II. Number Theory. Year

= 1 2x. x 2 a ) 0 (mod p n ), (x 2 + 2a + a2. x a ) 2

Chapter 14: Divisibility and factorization

QUADRATIC RINGS PETE L. CLARK

SOLUTIONS TO PROBLEM SET 1. Section = 2 3, 1. n n + 1. k(k + 1) k=1 k(k + 1) + 1 (n + 1)(n + 2) n + 2,

PRIME NUMBERS YANKI LEKILI

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include

PELL S EQUATION, II KEITH CONRAD

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

Gaussian integers. 1 = a 2 + b 2 = c 2 + d 2.

Chapter 5. Number Theory. 5.1 Base b representations

6 Orthogonal groups. O 2m 1 q. q 2i 1 q 2i. 1 i 1. 1 q 2i 2. O 2m q. q m m 1. 1 q 2i 1 i 1. 1 q 2i. i 1. 2 q 1 q i 1 q i 1. m 1.

9. Integral Ring Extensions

Chapter 3. Rings. The basic commutative rings in mathematics are the integers Z, the. Examples

Table of Contents. 2013, Pearson Education, Inc.

Math 201C Homework. Edward Burkard. g 1 (u) v + f 2(u) g 2 (u) v2 + + f n(u) a 2,k u k v a 1,k u k v + k=0. k=0 d

Numbers. 2.1 Integers. P(n) = n(n 4 5n 2 + 4) = n(n 2 1)(n 2 4) = (n 2)(n 1)n(n + 1)(n + 2); 120 =

MODEL ANSWERS TO HWK #10

Solutions of exercise sheet 6

Definitions. Notations. Injective, Surjective and Bijective. Divides. Cartesian Product. Relations. Equivalence Relations

REAL NUMBERS. Any positive integer a can be divided by another positive integer b in such a way that it leaves a remainder r that is smaller than b.

Mathematics Course 111: Algebra I Part I: Algebraic Structures, Sets and Permutations

Rings and modular arithmetic

Introduction to Number Theory

Course 311: Michaelmas Term 2005 Part III: Topics in Commutative Algebra

MATH 361: NUMBER THEORY FOURTH LECTURE

Pell Equation x 2 Dy 2 = 2, II

TC10 / 3. Finite fields S. Xambó

Constructions with ruler and compass.

CHAPTER 1 REAL NUMBERS KEY POINTS

1. Let r, s, t, v be the homogeneous relations defined on the set M = {2, 3, 4, 5, 6} by

Complex Numbers: Definition: A complex number is a number of the form: z = a + bi where a, b are real numbers and i is a symbol with the property: i

CHAPTER 8: EXPLORING R

Computations/Applications

Definitions, Theorems and Exercises. Abstract Algebra Math 332. Ethan D. Bloch

Mathematics for Cryptography

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

THUE S LEMMA AND IDONEAL QUADRATIC FORMS

INDEFINITE QUADRATIC FORMS AND PELL EQUATIONS INVOLVING QUADRATIC IDEALS

Number Theory Marathon. Mario Ynocente Castro, National University of Engineering, Peru

Some Results Concerning Uniqueness of Triangle Sequences

1. multiplication is commutative and associative;

Finite Fields: An introduction through exercises Jonathan Buss Spring 2014

Arithmetic Progressions Over Quadratic Fields

1 Overview and revision

ABSTRACT ALGEBRA 2 SOLUTIONS TO THE PRACTICE EXAM AND HOMEWORK

Finite Fields and Error-Correcting Codes

Lecture Notes. Advanced Discrete Structures COT S

Math 200 University of Connecticut

Notes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr.

Elementary Number Theory Review. Franz Luef

Lagrange s polynomial

Selected Math 553 Homework Solutions

1 The Galois Group of a Quadratic

Rings. Chapter 1. Definition 1.2. A commutative ring R is a ring in which multiplication is commutative. That is, ab = ba for all a, b R.

Chapter 2. Divisibility. 2.1 Common Divisors

THE TRIANGULAR THEOREM OF THE PRIMES : BINARY QUADRATIC FORMS AND PRIMITIVE PYTHAGOREAN TRIPLES

Perspectives of Mathematics

Transcription:

Faculté des Sciences et Techniques (FAST), Bamako, Mali École de recherche CIMPA Théorie des Nombres et Algorithmique Updated: December 7, 200 Pell s equation Michel Waldschmidt This text is available on the internet at the address http://www.math.jussieu.fr/ miw/articles/pdf/bamakopell200.pdf Contents On the so called Pell Fermat equation 2. Examples of simple continued fractions............. 2.2 Existence of integer solutions.................. 5.3 All integer solutions....................... 6.4 On the group of units of Z[ D]................. 8.5 Connection with rational approximation............ 0 2 Continued fractions 3 2. Generalized continued fractions................. 3 2.2 Simple continued fractions.................... 9 2.2. Finite simple continued fraction of a rational number. 2 2.2.2 Infinite simple continued fraction of an irrational number 22 3 Continued fractions and Pell s Equation 24 3. The main lemma......................... 24 3.2 Simple Continued fraction of D................ 28 3.3 Connection between the two formulae for the n-th positive solution to Pell s equation.................... 3 3.4 Records.............................. 32 3.5 Periodic continued fractions................... 33 3.6 Diophantine approximation and simple continued fractions.. 39 3.7 A criterion for the existence of a solution to the negative Pell equation.............................. 43 3.8 Arithmetic varieties....................... 44 4 More on Diophantine Approximation 45 4. Irrationality Criterion...................... 45 4.2 Liouville s inequality....................... 48

On the so called Pell Fermat equation Let D be a positive integer which is not the square of an integer. It follows that D is an irrational number. The Diophantine equation x 2 Dy 2 ±, () where the unknowns x and y are in Z, is called Pell s equation. An introduction to the subject has been given in first lecture: http://www.math.jussieu.fr/ miw/articles/pdf/pellfermat200.pdf and http://www.math.jussieu.fr/ miw/articles/pdf/pellfermat200vi.pdf Here we supply complete proofs of the results introduced in that lecture.. Examples of simple continued fractions The three first examples below are special cases of results initiated by O. Perron [23] and related with real quadratic fields of Richaud-Degert type. Example. Take D a 2 b 2 + 2b where a and b are positive integers. A solution to x 2 (a 2 b 2 + 2b)y 2 is (x, y) (a 2 b +, a). As we shall see, this is related with the continued fraction expansion of D which is a 2 b 2 + 2b [ab, a, 2ab] since t a 2 b 2 + 2b t ab + a + t + ab This includes the examples D a 2 + 2 (take b ) and D b 2 + 2b (take a ). For a and b c, this includes the example D c 2. Example 2. Take D a 2 b 2 + b where a and b are positive integers. A solution to x 2 (a 2 b 2 + b)y 2 Les notes sont en anglais, mais les cours seront donnés en français. 2

is (x, y) (2a 2 b +, 2a). The continued fraction expansion of D is a 2 b 2 + b [ab, 2a, 2ab] since t a 2 b 2 + b t ab + 2a + t + ab This includes the example D b 2 + b (take a ). The case b, D a 2 + is special: there is an integer solution to x 2 (a 2 + )y 2, namely (x, y) (a, ). The continued fraction expansion of D is a 2 + [a, 2a] since t a 2 + t a + t + a Example 3. Let a and b be two positive integers such that b 2 + divides 2ab +. For instance b 2 and a (mod 5). Write 2ab + k(b 2 + ) and take D a 2 + k. The continued fraction expansion of D is since t D satisfies [a, b, b, 2a] t a + b + b + a + t [a, b, b, a + t]. A solution to x 2 Dy 2 is x ab 2 + a + b, y b 2 +. In the case a and b 2 (so k ), the continued fraction has period length only: 5 [, 2]. Example 4. Integers which are Polygonal numbers in two ways are given by the solutions to quadratic equations. Triangular numbers are numbers of the form + 2 + 3 + + n 3 n(n + ) 2 for n ;

their sequence starts with, 3, 6, 0, 5, 2, 28, 36, 45, 55, 66, 78, 9, 05, 20, 36, 53, 7,... http://www.research.att.com/ njas/sequences/a00027. Square numbers are numbers of the form their sequence starts with + 3 + 5 + + (2n + ) n 2 for n ;, 4, 9, 6, 25, 36, 49, 64, 8, 00, 2, 44, 69, 96, 225, 256, 289,... http://www.research.att.com/ njas/sequences/a000290. Pentagonal numbers are numbers of the form + 4 + 7 + + (3n + ) their sequence starts with n(3n ) 2 for n ;, 5, 2, 22, 35, 5, 70, 92, 7, 45, 76, 20, 247, 287, 330, 376, 425,... http://www.research.att.com/ njas/sequences/a000326. Hexagonal numbers are numbers of the form + 5 + 9 + + (4n + ) n(2n ) for n ; their sequence starts with, 6, 5, 28, 45, 66, 9, 20, 53, 90, 23, 276, 325, 378, 435, 496, 56,... http://www.research.att.com/ njas/sequences/a000384. For instance, numbers which are at the same time triangular and squares are the numbers y 2 where (x, y) is a solution to Pell s equation with D 8. Their list starts with 0,, 36, 225, 466, 4372, 48024900, 6343288, 55420693056,... See http://www.research.att.com/ njas/sequences/a000. Example 5. Integer rectangle triangles having sides of the right angle as consecutive integers a and a + have an hypothenuse c which satisfies a 2 + (a + ) 2 c 2. The admissible values for the hypothenuse is the set of positive integer solutions y to Pell s equation x 2 2y 2. The list of these hypothenuses starts with, 5, 29, 69, 985, 574, 3346, 95025, 36689, 662509, 3863965, See http://www.research.att.com/ njas/sequences/a00653. 4

.2 Existence of integer solutions Let D be a positive integer which is not a square. We show that Pell s equation () has a non trivial solution (x, y) Z Z, that is a solution (±, 0). Proposition 2. Given a positive integer D which is not a square, there exists (x, y) Z 2 with x > 0 and y > 0 such that x 2 Dy 2. Proof. The first step of the proof is to show that there exists a non zero integer k such that the Diophantine equation x 2 Dy 2 k has infinitely many solutions (x, y) Z Z. The main idea behind the proof, which will be made explicit in Lemmas 4, 5 and Corollary 6 below, is to relate the integer solutions of such a Diophantine equation with rational approximations x/y of D. Using the implication (i) (v) of the irrationality criterion 6 and the fact that D is irrational, we deduce that there are infinitely many (x, y) Z Z with y > 0 (and hence x > 0) satisfying x D y < y 2 For such a (x, y), we have 0 < x < y D + < y( D + ), hence 0 < x 2 Dy 2 x y D x + y D < 2 D +. Since there are only finitely integers k 0 in the range (2 D + ) < k < 2 D +, one at least of them is of the form x 2 Dy 2 for infinitely many (x, y). The second step is to notice that, since the subset of (x, y) (mod k) in (Z/kZ) 2 is finite, there is an infinite subset E Z Z of these solutions to x 2 Dy 2 k having the same (x (mod k), y (mod k)). Let (u, v ) and (u 2, v 2 ) be two distinct elements in E. Define (x, y) Q 2 by x + y D u + v D u 2 + v 2 D From u 2 2 Dv2 2 k, one deduces x + y D k (u + v D)(u2 v 2 D), 5

hence x u u 2 Dv v 2, y u v 2 + u 2 v k k From u u 2 (mod k), v v 2 (mod k) and we deduce and u 2 Dv 2 k, u 2 2 Dv 2 2 k, u u 2 Dv v 2 u 2 Dv 2 0 (mod k) u v 2 + u 2 v u v + u v 0 hence x and y are in Z. Further, x 2 Dy 2 (x + y D)(x y D) (mod k), (u + v D)(u v D) (u 2 + v 2 D)(u2 v 2 D) u2 Dv2 u 2 2 Dv2 2. It remains to check that y 0. If y 0 then x ±, u v 2 u 2 v, u u 2 Dv v 2 ±, and ku ±u (u u 2 Dv v 2 ) ±u 2 (u 2 Dv 2 ) ±ku 2, which implies (u, u 2 ) (v, v 2 ), a contradiction. Finally, if x < 0 (resp. y < 0) we replace x by x (resp. y by y). Once we have a non trivial integer solution (x, y) to Pell s equation, we have infinitely many of them, obtained by considering the powers of x+y D..3 All integer solutions There is a natural order for the positive integer solutions to Pell s equation which can be defined in several ways: we can order them by increasing values of x, or increasing values of y, or increasing values of x + y D - it is easily checked that the order is the same. It follows that there is a minimal positive integer solution 2 (x, y ), which is called the fundamental solution to Pell s equation x 2 Dy 2 ±. In the same way, there is a fundamental solution to Pell s equations x 2 Dy 2. 2 We use the letter x, which should not be confused with the first complete quotient in the section 2.2.2 on continued fractions 6

Proposition 3. Denote by (x, y ) the fundamental solution to Pell s equation x 2 Dy 2 ±. Then the set of all positive integer solutions to this equation is the sequence (x n, y n ) n, where x n and y n are given by x n + y n D (x + y D) n, (n Z, n ). In other terms, x n and y n are defined by the recurrence formulae x n+ x n x + Dy n y and y n+ x y n + x n y, (n ). More explicitly: If x 2 Dy2, then (x, y ) is the fundamental solution to Pell s equation x 2 Dy 2, and there is no integer solution to Pell s equation x 2 Dy 2. If x 2 Dy2, then (x, y ) is the fundamental solution to Pell s equation x 2 Dy 2, and the fundamental solution to Pell s equation x 2 Dy 2 is (x 2, y 2 ). The set of positive integer solutions to Pell s equation x 2 Dy 2 is {(x n, y n ) ; n 2 even}, while the set of positive integer solutions to Pell s equation x 2 Dy 2 is {(x n, y n ) ; n odd}. The set of all solutions (x, y) Z Z to Pell s equation x 2 Dy 2 ± is the set (±x n, y n ) n Z, where x n and y n are given by the same formula x n + y n D (x + y D) n, (n Z). The trivial solution (, 0) is (x 0, y 0 ), the solution (, 0) is a torsion element of order 2 in the group of units of the ring Z[ D]. Proof. Let (x, y) be a positive integer solution to Pell s equation x 2 Dy 2 ±. Denote by n 0 the largest integer such that (x + y D) n x + y D. Hence x + y D < (x + y D) n+. Define (u, v) Z Z by From u + v D (x + y D)(x y D) n. u 2 Dv 2 ± and u + v D < x + y D, we deduce u and v 0, hence x x n, y y n. 7

.4 On the group of units of Z[ D] Let D be a positive integer which is not a square. The ring Z[ D] is the subring of R generated by D. The map σ : z x + y D x y D is the Galois automorphism of this ring. The norm N : Z[ D] Z is defined by N(z) zσ(z). Hence N(x + y D) x 2 Dy 2. The restriction of N to the group of unit Z[ D] of the ring Z[ D] is a homomorphism from the multiplicative group Z[ D] to the group of units Z of Z. Since Z {±}, it follows that Z[ D] {z Z[ D] ; N(z) ±}, hence Z[ D] is nothing else than the set of x + y D when (x, y) runs over the set of integer solutions to Pell s equation x 2 Dy 2 ±. Proposition 2 means that Z[ D] is not reduced to the torsion subgroup ±, while Proposition 3 gives the more precise information that this group Z[ D] is a (multiplicative) abelian group of rank : there exists a so called fundamental unit u Z[ D] such that Z[ D] {±u n ; n Z}. The fundamental unit u > is x +y D, where (x, y ) is the fundamental solution to Pell s equation x 2 Dy 2 ±. Pell s equation x 2 Dy 2 ± has integer solutions if and only if the fundamental unit has norm. That the rank of Z[ D] is at most also follows from the fact that the image of the map Z[ D] R 2 z ( log z, log z ) is discrete in R 2 and contained in the line t + t 2 0 of R 2. This proof is not really different from the proof we gave of Proposition 3: the proof that the discrete subgroups of R have rank relies on Euclid s division. Remark. Let d be a non zero rational integer which is not the square of an integer. Then d is not the square of a rational number, and the field k Q( d) is a quadratic extension of Q (which means a Q vector space of dimension 2). An element α k is an algebraic integer if and only if it satisfies the following equivalent conditions: (i) α is root of a monic polynomial with coefficients in Z. 8

(ii) The irreductible (monic) polynomial of α over Q has coefficients in Z. (iii) The irreducible polynomial of α over Z is monic. (iv) The ring Z[α] is a finitely generated Z module. (v) The ring Z[α] is contained in a subring of k which is a finitely generated Z module. The set Z k of algebraic integers of k is the following ring: Z + Z d if d 2 or 3 (mod 4) Z k Z + Z + d if d (mod 4). 2 Hence Z k Z + Zα, where α is any of the two roots of X 2 d if d 2 or 3 (mod 4), and any of the two roots of the polynomial X 2 X (d )/4 4 (2X )2 d if d (mod 4). The discriminant D k of k is the discriminant of the ring of integers of k: 2 0 det 4d if d 2 or 3 (mod 4) 0 2d D k 2 det d if d (mod 4). ( + d)/2 Hence the discriminant is always congruent to 0 or modulo 4 and the quadratic field is k Q( D k ). The group of units 3 of k is by definition the group of units Z K of the ring Z k. For d < 0, it is easy to check that the group of units in k is the following finite group of roots of unity in k: {, i,, i} if k has discriminant 4, which means k Q(i) {, ϱ, ϱ 2,, ϱ, ϱ 2 } if k has discriminant 3, where ϱ is a root of X 2 +X +. The quadratic field with discriminant 3 is k Q( ϱ) Q( 3) and ϱ is a primitive cube root of unity. 3 This is an abuse of language of course, since the units of a field are the non zero elements of the field; the same applies for ideals of a number field, which means ideals of the ring of integers of the number field. 9

{±} otherwise. Assume d > 0. Then the roots of unity in k are only ± and the group Z k of units of Z k is a Z-module of rank. Hence it is isomorphic to {±} Z. For d 2 and for d 3 (mod 4), the units Z k of k are the elements x + y D k k such that (x, y) Z Z is a solution of Pell s equation x 2 D k y 2 ±. For d (mod 4), the group of units Z k of k is the set of elements x + y D k k such that (x, y) Z Z is a solution of Pell s equation x 2 D k y 2 ±4..5 Connection with rational approximation Lemma 4. Let D be a positive integer which is not a square. Let x and y be positive rational integers. The following conditions are equivalent: (i) x 2 Dy 2. (ii) 0 < x y D < 2y 2 D (iii) 0 < x y D < y 2 D + Proof. We have 2y 2 D < y 2, hence (ii) implies (iii). D + (i) implies x 2 > Dy 2, hence x > y D, and consequently (iii) implies and hence 0 < x y D y(x + y D) < 2y 2 D x < y D + y D < y D + 2 y, y(x + y D) < 2y 2 D + 2, ( x 0 < x 2 Dy 2 y y ) D (x + y D) < 2. Since x 2 Dy 2 is an integer, it is equal to. The next variant will also be useful. 0

Lemma 5. Let D be a positive integer which is not a square. Let x and y be positive rational integers. The following conditions are equivalent: (i) x 2 Dy 2. (ii) 0 < D x y < 2y 2 D (iii) 0 < D x y < y 2 D Proof. We have 2y 2 D < y 2, hence (ii) implies (iii). D The condition (i) implies y D > x. We use the trivial estimate and write 2 D > + /y 2 x 2 Dy 2 > Dy 2 2 D + /y 2 (y D /y) 2, hence xy > y 2 D. From (i) one deduces (iii) implies x < y D and hence Dy 2 x 2 (y D x)(y D + x) ( ) D x > (y 2 D + xy) y ( ) D x > (2y 2 D ). y 0 < Dy 2 x 2 y Since Dy 2 x 2 is an integer, it is. y(y D + x) < 2y 2 D, From these two lemmas one deduces: ( ) D x (y D + x) < 2. y Corollary 6. Let D be a positive integer which is not a square. Let x and y be positive rational integers. The following conditions are equivalent: (i) x 2 Dy 2 ±. (ii) x D y < 2y 2 D (iii) x D y < y 2 D +

Proof. If y > or D > 3 we have 2y 2 D > y 2 D +, which means that (ii) implies trivially (iii), and we may apply Lemmas 4 and 5. If D 2 and y, then each of the conditions (i), (ii) and (iii) is satisfied if and only if x. This follows from 2 2 > 2 2 > > 2. 2 + If D 3 and y, then each of the conditions (i), (ii) and (iii) is satisfied if and only if x 2. This follows from 3 3 > 3 > 2 3 > > 2 3. 3 + It is instructive to compare with Liouville s inequality. Lemma 7. Let D be a positive integer which is not a square. Let x and y be positive rational integers. Then x D y > 2y 2 D + Proof. If x/y < D, then x y D and from one deduces Dy 2 x 2 (y D + x)(y D x) 2y D(y D x), We claim that if x/y > D, then D x y > 2y 2 D x y D > 2y 2 D + Indeed, this estimate is true if x y D /y, so we may assume x y D < /y. Our claim then follows from x 2 Dy 2 (x + y D)(x y D) (2y D + /y)(x y D). This shows that a rational approximation x/y to D, which is only slightly weaker than the limit given by Liouville s inequality, will produce a solution to Pell s equation x 2 Dy 2 ±. The distance D x/y cannot be smaller than /(2y 2 D + ), but it can be as small as /(2y 2 D ), and for that it suffices that it is less than /(y 2 D + ) 2

2 Continued fractions We first consider generalized continued fractions of the form a 0 + a + b b 2 a 2 + b 3..., which we denote by 4 a 0 + b a + b 2 a 2 + b 3... Next we restrict to the special case where b b 2, which yields the simple continued fractions a 0 + a + a 2 + [a 0, a, a 2,... ]. 2. Generalized continued fractions To start with, a 0,..., a n,... and b,..., b n,... will be independent variables. Later, we shall specialize to positive integers (apart from a 0 which may be negative). Consider the three rational fractions a 0, a 0 + b a and a 0 + b a + b 2 a 2 We write them as with A 0 B 0, A B and A 2 B 2 A 0 a 0, A a 0 a + b, A 2 a 0 a a 2 + a 0 b 2 + a 2 b, B 0, B a, B 2 a a 2 + b 2. 4 Another notation for a 0 + b a + b 2 a 2 + + bn a n introduced by Th. Muir and used by Perron in [23] Chap. is ( ) b,..., b n K a 0, a,..., a n 3

Observe that Write these relations as A 2 a 2 A + b 2 A 0, B 2 a 2 B + b 2 B 0. ( A2 B 2 ) ( ) ( ) A A 0 a2. B B 0 b 2 In order to iterate the process, it is convenient to work with 2 2 matrices and to write ( ) ( ) ( ) A2 A A A 0 a2. B 2 B B B 0 b 2 0 Define inductively two sequences of polynomials with positive rational coefficients A n and B n for n 3 by ( ) ( ) ( ) An A n An A n 2 an. (8) b n 0 This means B n B n B n B n 2 A n a n A n + b n A n 2, B n a n B n + b n B n 2. This recurrence relation holds for n 2. It will also hold for n if we set A and B 0: ( ) ( ) ( ) A A 0 a0 a B B 0 0 b 0 and it will hold also for n 0 if we set b 0, A 2 0 and B 2 : ( ) ( ) ( ) A0 A 0 a0. 0 b 0 0 B n B n B 0 B Obviously, an equivalent definition is ( ) ( ) ( ) ( ) ( ) An A n a0 a an an. (9) b 0 0 b 0 b n 0 b n 0 These relations (9) hold for n, with the empty product (for n ) being the identity matrix, as always. Hence A n Z[a 0,..., a n, b,..., b n ] is a polynomial in 2n + variables, while B n Z[a..., a n, b 2,..., b n ] is a polynomial in 2n variables. 4

Exercise. Check, for n, B n (a,..., a n, b 2,..., b n ) A n (a,..., a n, b 2,..., b n ). Lemma 0. For n 0, a 0 + b a + + b n a n A n B n Proof. By induction. We have checked the result for n 0, n and n 2. Assume the formula holds with n where n 3. We write with a 0 + b + + b n + b n a 0 + b + + b n a a n a n a x x a n + b n a n We have, by induction hypothesis and by the definition (8), a 0 + b a + + b n a n A n B n a n A n 2 + b n A n 3 a n B n 2 + b n B n 3 Since A n 2, A n 3, B n 2 and B n 3 do not depend on the variable a n, we deduce a 0 + b + + b n xa n 2 + b n A n 3 a x xb n 2 + b n B n 3 The product of the numerator by a n is (a n a n + b n )A n 2 + a n b n A n 3 a n (a n A n 2 + b n A n 3 ) + b n A n 2 a n A n + b n A n 2 A n and similarly, the product of the denominator by a n is (a n a n + b n )B n 2 + a n b n B n 3 a n (a n B n 2 + b n B n 3 ) + b n B n 2 a n B n + b n B n 2 B n. From (9), taking the determinant, we deduce, for n, A n B n A n B n ( ) n+ b 0 b n. () 5

which can be written, for n, A n B n A n B n ( )n+ b 0 b n B n B n (2) Adding the telescoping sum, we get, for n 0, A n B n A 0 + n k ( ) k+ b 0 b k B k B k (3) We now substitute for a 0, a,... and b, b 2,... rational integers, all of which are, apart from a 0 which may be 0. We denote by p n (resp. q n ) the value of A n (resp. B n ) for these special values. Hence p n and q n are rational integers, with q n > 0 for n 0. A consequence of Lemma 0 is We deduce from (8), p n a 0 + b + + b n for n 0. q n a a n p n a n p n + b n p n 2, q n a n q n + b n q n 2 for n 0, and from (), p n q n p n q n ( ) n+ b 0 b n for n, which can be written, for n, p n q n p n q n ( )n+ b 0 b n q n q n (4) Adding the telescoping sum (or using (3)), we get the alternating sum p n q n a 0 + n k ( ) k+ b 0 b k q k q k (5) Recall that for real numbers a, b, c, d, with b and d positive, we have a b < c d a b < a + c b + d < d c (6) Since a n and b n are positive for n 0, we deduce that for n 2, the rational number p n a np n + b n p n 2 q n a n q n + b n q n 2 6

lies between p n /q n and p n 2 /q n 2. Therefore we have p 2 q 2 < p 4 q 4 < < p 2n q 2n < < p 2m+ q 2m+ < < p 3 q 3 < p q (7) From (4), we deduce, for n 3, q n > q n 2, hence q n > (a n + b n )q n 2. The previous discussion was valid without any restriction, now we assume a n b n for all sufficiently large n, say n n 0. Then for n > n 0, using q n > 2b n q n 2, we get p n p n q n b 0 b n b n b 0 b n0 b 0 < q n q n 2 n n 0 bn b n b n0 +q n0 q n0 2 n n 0 qn0 q n0 q n and the right hand side tends to 0 as n tends to infinity. Hence the sequence (p n /q n ) n 0 has a limit, which we denote by x a 0 + b a + + b n a n + b n a n + From (5), it follows that x is also given by an alternating series x a 0 + k ( ) k+ b 0 b k q k q k We now prove that x is irrational. Define, for n 0, so that x x 0 and, for all n 0, x n a n + b n+ a n+ + x n a n + b n+ x n+, x n+ b n+ x n a n and a n < x n < a n +. Hence for n 0, x n is rational if and only if x n+ is rational, and therefore, if x is rational, then all x n for n 0 are also rational. Assume x is rational. Consider the rational numbers x n with n n 0 and select a value of n for which the denominator v of x n is minimal, say x n u/v. From x n+ b n+ x n a n b n+v u a n v with 0 < u a n v < v, it follows that x n+ has a denominator strictly less than v, which is a contradiction. Hence x is irrational. 7

Conversely, given an irrational number x and a sequence b, b 2,... of positive integers, there is a unique integer a 0 and a unique sequence a,..., a n,... of positive integers satisfying a n b n for all n, such that x a 0 + b a + + b n a n + b n a n + Indeed, the unique solution is given inductively as follows: a 0 x, x b /{x}, and once a 0,..., a n and x,..., x n are known, then a n and x n+ are given by a n x n, x n+ b n+ /{x n }, so that for n we have 0 < x n a n < and Here is what we have proved. x a 0 + b a + + b n a n + b n x n Proposition 8. Given a rational integer a 0 and two sequences a 0, a,... and b, b 2,... of positive rational integers with a n b n for all sufficiently large n, the infinite continued fraction a 0 + b a + + b n a n + b n a n + exists and is an irrational number. Conversely, given an irrational number x and a sequence b, b 2,... of positive integers, there is a unique a 0 Z and a unique sequence a,..., a n,... of positive integers satisfying a n b n for all n such that x a 0 + b a + + b n a n + b n a n + These results are useful for proving the irrationality of π and e r when r is a non zero rational number, following the proof by Lambert. See for instance Chapter 7 (Lambert s Irrationality Proofs) of David Angell s course on Irrationality and Transcendence( 5 ) at the University of New South Wales: http://www.maths.unsw.edu.au/ angell/5535/ The following example is related with Lambert s proof [6]: tanh z z + z2 3 + z2 5 + + z2 2n + + 5 I found this reference from the website of John Cosgrave http://staff.spd.dcu.ie/johnbcos/transcendental numbers.htm. 8

Here, z is a complex number and the right hand side is a complex valued function. Here are other examples (see Sloane s Encyclopaedia of Integer Sequences( 6 )) e + 2 e 3 + 4 5 + 6 7 + 8 + 9.54 494 082... (A30) + 2 2 + 3 3 + 4 + 4 0.58 976 706... (A073333) Remark. A variant of the algorithm of simple continued fractions is the following. Given two sequences (a n ) n 0 and (b n ) n 0 of elements in a field K and an element x in K, one defines a sequence (possibly finite) (x n ) n of elements in K as follows. If x a 0, the sequence is empty. Otherwise x is defined by x a 0 + (b /x ). Inductively, once x,..., x n are defined, there are two cases: If x n a n, the algorithm stops. Otherwise, x n+ is defined by x n+ b n+ x n a n, so that x n a n + b n+ x n+ If the algorithm does not stop, then for any n, one has x a 0 + b a + + b n a n + b n x n In the special case where a 0 a b b 2, the set of x such that the algorithm stops after finitely many steps is the set (F n+ /F n ) n of quotients of consecutive Fibonacci numbers. In this special case, the limit of a 0 + b a + + b n a n + b n a n is the Golden ratio, which is independent of x, of course! 2.2 Simple continued fractions We restrict now the discussion of 2. to the case where b b 2 b n. We keep the notations A n and B n which are now polynomials in Z[a 0, a,..., a n ] and Z[a,..., a n ] respectively, and when we specialize to 6 http://www.research.att.com/ njas/sequences/ 9

integers a 0, a,..., a n... with a n for n we use the notations p n and q n for the values of A n and B n. The recurrence relations (8) are now, for n 0, ( ) ( ) ( ) An A n An A n 2 an, (9) 0 B n B n B n B n B n B n 2 while (9) becomes, for n, ( ) ( ) ( ) ( ) ( ) An A n a0 a an an. (20) 0 0 0 0 From Lemma 0 one deduces, for n 0, [a 0,..., a n ] A n B n Taking the determinant in (20), we deduce the following special case of () A n B n A n B n ( ) n+. The specialization of these relations to integral values of a 0, a, a 2... yields ( ) ( ) ( ) pn p n pn p n 2 an for n 0, (2) q n q n q n q n 2 0 ( ) ( ) ( ) ( ) ( ) pn p n a0 a an an for n, q n q n 0 0 0 0 (22) [a 0,..., a n ] p n for n 0 q n and p n q n p n q n ( ) n+ for n. (23) From (23), it follows that for n 0, the fraction p n /q n is in lowest terms: gcd(p n, q n ). Transposing (22) yields, for n, ( pn q n p n q n ) ( an 0 from which we deduce, for n, ) ( ) an 0 ( a 0 [a n,..., a 0 ] p n p n and [a n,..., a ] q n q n ) ( ) a0 0 20

Lemma 24. For n 0, p n q n 2 p n 2 q n ( ) n a n. Proof. We multiply both sides of (2) on the left by the inverse of the matrix ( ) ( ) pn p n 2 which is ( ) n qn 2 p n 2. q n p n q n q n 2 We get ( ) ( ) n pn q n 2 p n 2 q n p n q n 2 p n 2 q n p n q n + p n q n 0 ( ) an 0 2.2. Finite simple continued fraction of a rational number Let u 0 and u be two integers with u positive. The first step in Euclid s algorithm to find the gcd of u 0 and u consists in dividing u 0 by u : u 0 a 0 u + u 2 with a 0 Z and 0 u 2 < u. This means u 0 u a 0 + u 2 u, which amonts to dividing the rational number x 0 u 0 /u by with quotient a 0 and remainder u 2 /u <. This algorithms continues with u m a m u m+ + u m+2, where a m is the integral part of x m u m /u m+ and 0 u m+2 < u m+, until some u l+2 is 0, in which case the algorithms stops with u l a l u l+. Since the gcd of u m and u m+ is the same as the gcd of u m+ and u m+2, it follows that the gcd of u 0 and u is u l+. This is how one gets the regular continued fraction expansion x 0 [a 0, a,..., a l ], where l 0 in case x 0 is a rational integer, while a l 2 if x 0 is a rational number which is not an integer. 2

Exercise 2. Compare with the geometrical construction of the continued fraction given in the beamer presentation. Give a variant of this geometrical construction where rectangles are replaced by segments. Proposition 25. Any finite regular continued fraction [a 0, a,..., a n ], where a 0, a,..., a n are rational numbers with a i 2 for i n and n 0, represents a rational number. Conversely, any rational number x has two representations as a continued fraction, the first one, given by Euclid s algorithm, is x [a 0, a,..., a n ] and the second one is x [a 0, a,..., a n, a n, ]. If x Z, then n 0 and the two simple continued fractions representations of x are [x] and [x, ], while if x is not an integer, then n and a n 2. For instance the two continued fractions of are [] and [0, ], they both end with. The two continued fractions of 0 are [0] and [, ], the first of which is the unique continued fraction which ends with 0. We shall use later (in the proof of Lemma 30 in 3.2) the fact that any rational number has one simple continued fraction expansion with an odd number of terms and one with an even number of terms. 2.2.2 Infinite simple continued fraction of an irrational number Given a rational integer a 0 and an infinite sequence of positive integers a, a 2,..., the continued fraction [a 0, a,..., a n,... ] represents an irrational number. Conversely, given an irrational number x, there is a unique representation of x as an infinite simple continued fraction x [a 0, a,..., a n,... ] Definitions The numbers a n are the partial quotients, the rational numbers p n q n [a 0, a,..., a n ] 22

are the convergents (in French réduites), and the numbers are the complete quotients. x n [a n, a n+,...] From these definitions we deduce, for n 0, Lemma 27. For n 0, x [a 0, a,..., a n, x n+ ] x n+p n + p n x n+ q n + q n. (26) q n x p n Proof. From (26) one deduces ( ) n x n+ q n + q n x p n q n x n+p n + p n x n+ q n + q n p n q n ( ) n (x n+ q n + q n )q n Corollary 28. For n 0, < q n x p n < q n+ + q n q n+ Proof. Since a n+ is the integral part of x n+, we have a n+ < x n+ < a n+ +. Using the recurrence relation q n+ a n+ q n + q n, we deduce q n+ < x n+ q n + q n < a n+ q n + q n + q n q n+ + q n. In particular, since x n+ > a n+ and q n > 0, one deduces from Lemma 27 (a n+ + 2)qn 2 < x p n q n < a n+ qn 2 (29) Therefore any convergent p/q of x satisfies x p/q < /q 2 (compare with (i) (v) in Proposition 6). Moreover, if a n+ is large, then the approximation p n /q n is sharp. Hence, large partial quotients yield good rational approximations by truncating the continued fraction expansion just before the given partial quotient. 23

3 Continued fractions and Pell s Equation 3. The main lemma The theory which follows is well known (a classical reference is the book [23] by O. Perron), but the point of view which we develop here is slightly different from most classical texts on the subject. We follow [3, 4, 32]. An important role in our presentation of the subject is the following result (Lemma 4. in [26]). Lemma 30. Let ɛ ± and let a, b, c, d be rational integers satisfying ad bc ɛ and d. Then there is a unique finite sequence of rational integers a 0,..., a s with s and a,..., a s positive, such that ( ) ( ) ( ) ( ) a b a0 a as (3) c d 0 0 0 These integers are also characterized by b d [a 0, a,..., a s ], c d [a s,..., a ], ( ) s+ ɛ. (32) For instance, when d, for b and c rational integers, ( ) ( ) ( ) bc + b b c c 0 0 and ( ) bc b c ( b 0 ) ( ) ( ) c. 0 0 Proof. We start with unicity. If a 0,..., a s satisfy the conclusion of Lemma 30, then by using (3), we find b/d [a 0, a,..., a s ]. Taking the transpose, we also find c/d [a s,..., a ]. Next, taking the determinant, we obtain ( ) s+ ɛ. The last equality fixes the parity of s, and each of the rational numbers b/d, c/d has a unique continued fraction expansion whose length has a given parity (cf. Proposition 25). This proves the unicity of the factorisation when it exists. For the existence, we consider the simple continued fraction expansion of c/d with length of parity given by the last condition in (32), say c/d 24

[a s,..., a ]. Let a 0 be a rational integer such that the distance between b/d and [a 0, a,..., a s ] is /2. Define a, b, c, d by We have and ( a b ) c d ( a0 0 d > 0, a d b c ɛ, b d [a 0, a,..., a s ], ) ( ) a 0 ( ) as. 0 c d [a s,..., a ] c d b d b d 2 From gcd(c, d) gcd(c, d ), c/d c /d and d > 0, d > 0 we deduce c c, d d. From the equality between the determinants we deduce a a + kc, b b + kd for some k Z, and from b d b d k we conclude k 0, (a, b, c, d ) (a, b, c, d). Hence (3) follows. Corollary 33. Assume the hypotheses of Lemma 30 are satisfied. a) If c > d, then a s and b) If b > d, then a 0 and a c [a 0, a,..., a s ]. a b [a s,..., a, a 0 ]. The following examples show that the hypotheses of the corollary are not superfluous: ( ) ( ) ( ) b b 0, 0 0 0 ( ) ( ) ( ) ( ) b b b 0 0 0 0 and ( ) c c ( 0 0 ) ( ) ( ) c. 0 0 25

Proof of Corollary 33. Any rational number u/v > has two continued fractions. One of them starts with 0 only if u/v and the continued fraction is [0, ]. Hence the assumption c > d implies a s > 0. This proves part a), and part b) follows by transposition (or repeating the proof). Another consequence of Lemma 30 is the following classical result (Satz 3 p. 47 of [23]). Corollary 34. Let a, b, c, d be rational integers with ad bc ± and c > d > 0. Let x and y be two irrational numbers satisfying y > and x ay + b cy + d Let x [a 0, a,...] be the simple continued fraction expansion of x. Then there exists s such that a p s, b p s, c q s, r q s, y x s+. Proof. Using lemma 30, we write ( ) ( ) ( ) ( ) a b a 0 a a s c d 0 0 0 with a,..., a s positive and b d [a 0, a,..., a s ], c d [a s,..., a ]. From c > d and corollary 33, we deduce a s > 0 and a c [a 0, a,..., a s] p s q s, x p sy + p s q sy + q s [a 0, a,..., a s, y]. Since y >, it follows that a i a i, p i q i for 0 i s and y x s+. Remark. In [2], 4, there is a variant of the matrix formula (2) for the simple continued fraction of a real number. 26

Given integers a 0, a,... with a i > 0 for i and writing, for n 0, as usual, p n /q n [a 0, a,..., a n ], one checks, by induction on n, the two formulae ( ) ( ) ( ) ( ) a0 0 an pn p n ( 0 a0 0 a ). ) ( 0 a ( 0 0 a n ) ( q n q n ) pn p n q n q n if n is even if n is odd Define two matrices U (up) and L (low) in GL 2 (R) of determinant + by U ( ) 0 and L ( ) 0. (35) For p and q in Z, we have ( ) U p p 0 and L q ( ) 0, q so that these formulae (35) are ( ) U a 0 pn p L a U an n q n q n if n is even and ( ) U a 0 pn p L a L an n q n q n if n is odd. The connexion with Euclid s algorithm is ( ) ( ) ( ) ( ) U p a b a pc b pd and L q a b a b. c d c d c d c qa d qb The corresponding variant of Lemma 30 is also given in [2], 4: If a, b, c, d are rational integers satisfying b > a > 0, d > c 0 and ad bc, then there exist rational integers a 0,..., a n with n even and a,..., a n positive, such that ( ) a b c d ( a0 0 ) ( 0 a ) ( ) an 0 These integers are uniquely determined by b/d [a 0,..., a n ] with n even. 27

3.2 Simple Continued fraction of D An infinite sequence (a n ) n is periodic if there exists a positive integer s such that a n+s a n for all n. (36) In this case, the finite sequence (a,..., a s ) is called a period of the original sequence. For the sake of notation, we write (a, a 2,... ) (a,..., a s ). If s 0 is the smallest positive integer satisfying (36), then the set of s satisfying (36) is the set of positive multiples of s 0. In this case (a,..., a s0 ) is called the fundamental period of the original sequence. Theorem 37. Let D be a positive integer which is not a square. Write the simple continued fraction of D as [a 0, a,...] with a 0 D. a) The sequence (a, a 2,...) is periodic. b) Let (x, y) be a positive integer solution to Pell s equation x 2 Dy 2 ±. Then there exists s such that x/y [a 0,..., a s ] and (a, a 2,..., a s, 2a 0 ) is a period of the sequence (a, a 2,...). Further, a s i a i for i s 7 ). c) Let (a, a 2,..., a s, 2a 0 ) be a period of the sequence (a, a 2,...). Set x/y [a 0,..., a s ]. Then x 2 Dy 2 ( ) s. d) Let s 0 be the length of the fundamental period. Then for i 0 not multiple of s 0, we have a i a 0. If (a, a 2,..., a s, 2a 0 ) is a period of the sequence (a, a 2,...), then D [a0, a,..., a s, 2a 0 ] [a 0, a,..., a s, a 0 + D]. Consider the fundamental period (a, a 2,..., a s0, a s0 ) of the sequence (a, a 2,...). By part b) of Theorem 37 we have a s0 2a 0, and by part d), it follows that s 0 is the smallest index i such that a i > a 0. From b) and c) in Theorem 37, it follows that the fundamental solution (x, y ) to Pell s equation x 2 Dy 2 ± is given by x /y [a 0,..., a s0 ], 7 One says that the word a,..., a s is a palindrome. This result is proved in the first paper published by Evariste Galois at the age of 7: Démonstration d un théorème sur les fractions continues périodiques. Annales de Mathématiques Pures et Appliquées, 9 (828-829), p. 294-30. http://archive.numdam.org/article/ampa 828-829 9 294 0.pdf. 28

and that x 2 Dy2 ( )s 0. Therefore, if s 0 is even, then there is no solution to the Pell s equation x 2 Dy 2. If s 0 is odd, then (x, y ) is the fundamental solution to Pell s equation x 2 Dy 2, while the fundamental solution (x 2, y 2 ) to Pell s equation x 2 Dy 2 is given by x 2 /y 2 [a 0,..., a 2s ]. It follows also from Theorem 37 that the (ns 0 )-th convergent satisfies x n /y n [a 0,..., a ns0 ] x n + y n D (x + y D) n. (38) We shall check this relation directly (Lemma 42). Proof. Start with a positive solution (x, y) to Pell s equation x 2 Dy 2 ±, which exists according to Proposition 2. Since Dy x and x > y, we may use lemma 30 and corollary 33 with a Dy, b c x, d y and write ( ) Dy x x y ( a 0 0 ) ( ) a 0 ( ) a s 0 (39) with positive integers a 0,..., a s and with a 0 D. Then the continued fraction expansion of Dy/x is [a 0,..., a s] and the continued fraction expansion of x/y is [a 0,..., a s ]. Since the matrix on the left hand side of (39) is symmetric, the word a 0,..., a s is a palindrome. In particular a s a 0. Consider the periodic continued fraction This number δ satisfies δ [a 0, a,..., a s, 2a 0 ]. δ [a 0, a,..., a s, a 0 + δ]. Using the inverse of the matrix ( ) a 0 0 which is ( 0 a 0 ), we write ( ) a 0 + δ 0 ( a 0 0 29 ) ( ) 0 δ

Hence the product of matrices associated with the continued fraction of δ ( ) ( ) ( ) ( ) a 0 a a s a 0 + δ 0 0 0 0 is ( ) ( ) Dy x 0 x y δ It follows that δ ( Dy + δx x x + δy y Dy + δx x + δy, hence δ 2 D. As a consequence, a i a i for 0 i s while a s a 0, a s 2a 0. This proves that if (x, y) is a non trivial solution to Pell s equation x 2 Dy 2 ±, then the continued fraction expansion of D is of the form D [a0, a,..., a s, 2a 0 ] (40) ). with a,..., a s a palindrome, and x/y is given by the convergent x/y [a 0, a,..., a s ]. (4) Consider a convergent p n /q n [a 0, a,..., a n ]. If a n+ 2a 0, then (29) with x D implies the upper bound p n D q n 2a 0 qn 2, and it follows from Corollary 6 that (p n, q n ) is a solution to Pell s equation p 2 n Dqn 2 ±. This already shows that a i < 2a 0 when i + is not the length of a period. We refine this estimate to a i a 0. Assume a n+ a 0 +. Since the sequence (a m ) m is periodic of period length s 0, for any m congruent to n modulo s 0, we have a m+ > a 0. For these m we have p m D q m (a 0 + )qm 2 For sufficiently large m congruent to n modulo s we have (a 0 + )q 2 m > q 2 m D +. Corollary 6 implies that (p m, q m ) is a solution to Pell s equation p 2 m Dq 2 m ±. Finally, Theorem 37 implies that m + is a multiple of s 0, hence n + also. 30

3.3 Connection between the two formulae for the n-th positive solution to Pell s equation Lemma 42. Let D be a positive integer which is not a square. Consider the simple continued fraction expansion D [a 0, a,..., a s0, 2a 0 ] where s 0 is the length of the fundamental period. Then the fundamental solution (x, y ) to Pell s equation x 2 Dy 2 ± is given by the continued fraction expansion x /y [a 0, a,..., a s0 ]. Let n be a positive integer. Define (x n, y n ) by x n /y n [a 0, a,..., a ns0 ]. Then x n + y n D (x + y D) n. This result is a consequence of the two formulae we gave for the n-th solution (x n, y n ) to Pell s equation x 2 Dy 2 ±. We check this result directly. Proof. From Lemma 30 and relation (39), one deduces ( ) ( ) ( ) ( ) ( ) Dyn x n a0 a ans0 a0. 0 0 0 0 x n y n Since ( ) ( ) ( ) Dyn x n 0 xn Dy n a 0 x n, a 0 y n x n a 0 y n x n y n we obtain ( ) ( ) ( ) a0 a ans0 0 0 0 ( xn Dy n a 0 x n y n x n a 0 y n ). (43) Notice that the determinant is ( ) ns 0 x 2 n Dyn. 2 Formula (43) for n + and the periodicity of the sequence (a,..., a n,... ) with a s0 2a 0 give : ( ) ( ) ( ) ( ) ( ) xn+ Dy n+ a 0 x n+ xn Dy n a 0 x n 2a0 a as0. y n+ x n+ a 0 y n+ y n x n a 0 y n 0 0 0 Take first n in (43) and multiply on the left by ( ) ( ) 2a0 0 0 a 0 ( ) a0. 0 Since ( a0 0 ) ( ) ( x Dy a 0 x x + a 0 y (D a 2 0 )y y x a 0 y y x a 0 y ). 3

we deduce ( ) ( ) ( ) 2a0 a as0 0 0 0 ( x + a 0 y (D a 2 0 )y y x a 0 y Therefore ( ) ( ) ( xn+ Dy n+ a 0 x n+ xn Dy n a 0 x n x + a 0 y (D a 2 0 )y ). y n+ x n+ a 0 y n+ y n x n a 0 y n y x a 0 y The first column gives x n+ x n x + Dy n y and y n+ x y n + x n y, which was to be proved. ). 3.4 Records For large D, Pell s equation may obviously have small integer solutions. Examples are for D m 2 with m 2, the numbers x m, y satisfy x 2 Dy 2, for D m 2 + with m, the numbers x m, y satisfy x 2 Dy 2, for D m 2 ± m with m 2, the numbers x 2m ±, y 2 satisfy x 2 Dy 2, for D t 2 m 2 + 2m with m and t, the numbers x t 2 m +, y t satisfy x 2 Dy 2. On the other hand, relatively small values of D may lead to large fundamental solutions. Tables are available on the internet 8. For D a positive integer which is not a square, denote by S(D) the base 0 logarithm of x, when (x, y ) is the fundamental solution to x 2 Dy 2. The number of decimal digits of the fundamental solution x is the integral part of S(D) plus. For instance, when D 6, the fundamental solution (x, y ) is x 766 39 049, y 226 53 980 and S(6) log 0 x 9.247 069... 8 For instance: Tomás Oliveira e Silva: Record-Holder Solutions of Pell s Equation http://www.ieeta.pt/ tos/pell.html. 32

An integer D is a record holder for S if S(D ) < S(D) for all D < D. Here are the record holders up to 02: D 2 5 0 3 29 46 53 6 09 S(D) 0.477 0.954.278 2.82 3.99 4.386 4.82 9.247 4.98 D 8 277 397 409 42 54 66 02 S(D) 8.392 20.20 20.923 22.398 33.588 36.569 37.25 47.298 Some further records with number of digits successive powers of 0: D 306 69789 2765349 0294898 8548930734 S(D) 04.05 00.282 09.729 0068.340 003270.5 3.5 Periodic continued fractions An infinite sequence (a n ) n 0 is said to be ultimately periodic if there exists n 0 0 and s such that a n+s a n for all n n 0. (44) The set of s satisfying this property (3.5) is the set of positive multiples of an integer s 0, and (a n0, a n0 +,..., a n0 +s 0 ) is called the fundamental period. A continued fraction with a sequence of partial quotients satisfying (44) will be written [a 0, a,..., a n0, a n0,..., a n0 +s ]. Example. For D a positive integer which is not a square, setting a 0 D, we have by Theorem 37 a 0 + D [2a 0, a,..., a s ] and D a0 [a,..., a s, 2a 0 ]. Lemma 45 (Euler 737). If an infinite continued fraction x [a 0, a,..., a n,...] is ultimately periodic, then x is a quadratic irrational number. Proof. Since the continued fraction of x is infinite, x is irrational. Assume first that the continued fraction is periodic, namely that (44) holds with n 0 0: x [a 0,..., a s ]. 33

This can be written Hence It follows that x [a 0,..., a s, x]. x p s x + p s 2 q s x + q s 2 q s X 2 + (q s 2 p s )X p s 2 is a non zero quadratic polynomial with integer coefficients having x as a root. Since x is irrational, this polynomial is irreducible and x is quadratic. In the general case where (44) holds with n 0 > 0, we write x [a 0, a,..., a n0, a n0,..., a n0 +s ] [a 0, a,..., a n0, y], where y [a n0,..., a n0 +s ] is a periodic continued fraction, hence is quadratic. But x p n 0 y + p n0 2, q n0 y + q n0 2 hence x Q(y) is also quadratic irrational. Lemma 46 (Lagrange, 770). If x is a quadratic irrational number, then its continued fraction x [a 0, a,..., a n,...] is ultimately periodic. Proof. For n 0, define d n q n x p n. According to Corollary 28, we have d n < /q n+. Let AX 2 + BX + C with A > 0 be an irreducible quadratic polynomial having x as a root. For each n 2, we deduce from (26) that the convergent x n is a root of a quadratic polynomial A n X 2 + B n X + C n, with A n Ap 2 n + Bp n q n + Cq 2 n, B n 2Ap n p n 2 + B(p n q n 2 + p n 2 q n ) + 2Cq n q n 2, C n A n. Using Ax 2 + Bx + C 0, we deduce A n (2Ax + B)d n q n + Ad 2 n, B n (2Ax + B)(d n q n 2 + d n 2 q n ) + 2Ad n d n 2. 34

There are similar formulae expressing A, B, C as homogeneous linear combinations of A n, B n, C n, and since (A, B, C) (0, 0, 0), it follows that (A n, B n, C n ) (0, 0, 0). Since x n is irrational, one deduces A n 0. From the inequalities q n d n 2 <, q n 2 d n <, q n < q n, d n d n 2 <, one deduces max{ A n, B n /2, C n } < A + 2Ax + B. This shows that A n, B n and C n are bounded independently of n. Therefore there exists n 0 0 and s > 0 such that x n0 x n0 +s. From this we deduce that the continued fraction of x n0 is purely periodic, hence the continued fraction of x is ultimately periodic. A reduced quadratic irrational number is an irrational number x > which is a root of a degree 2 polynomial ax 2 + bx + c with rational integer coefficients, such that the other root x of this polynomial, which is the Galois conjugate of x, satisfies < x < 0. If x is reduced, then so is /x. Lemma 47. A continued fraction x [a 0, a,..., a n...] is purely periodic if and only if x is a reduced quadratic irrational number. In this case, if x [a 0, a,..., a s ] and if x is the Galois conjugate of x, then /x [a s,..., a, a 0 ] Proof. Assume first that the continued fraction of x is purely periodic: x [a 0, a,..., a s ]. From a s a 0 we deduce a 0 > 0, hence x >. From x [a 0, a,..., a s, x] and the unicity of the continued fraction expansion, we deduce x p s x + p s 2 q s x + q s 2 and x x s. Therefore x is a root of the quadratic polynomial P s (X) q s X 2 + (q s 2 p s )X p s 2. 35

This polynomial P s has a positive root, namely x >, and a negative root x, with the product xx p s 2 /q s. We transpose the relation ( ) ( ) ( ) ( ) ps p s 2 a0 a as 0 0 0 q s and obtain (ps Define so that y >, p s 2 q s 2 q s q s 2 ) ( ) as 0 ( a 0 y [a s,..., a, a 0 ], ) ( ) a0. 0 y [a s,..., a, a 0, y] p s y + q s p s 2 y + q s 2 and y is the positive root of the polynomial Q s (X) p s 2 X 2 + (q s 2 p s )X q s. The polynomials P s and Q s are related by Q s (X) X 2 P s ( /X). Hence y /x. For the converse, assume x > and < x < 0. Let (x n ) n be the sequence of complete quotients of x. For n, define x n as the Galois conjugate of x n. One deduces by induction that x n a n + /x n+, that < x n < 0 (hence x n is reduced), and that a n is the integral part of /x n+. If the continued fraction expansion of x were not purely periodic, we would have x [a 0,..., a h, a h,..., a h+s ] with a h a h+s. By periodicity we have x h [a h,..., a h+s, x h ], hence x h x h+s, x h x h+s. From x h x h+s, taking integral parts, we deduce a h a h+s, a contradiction. Corollary 48. If r > is a rational number which is not a square, then the continued fraction expansion of r is of the form r [a0, a,..., a s, 2a 0 ] with a,..., a s a palindrome and a 0 r. Conversely, if the continued fraction expansion of an irrational number t > is of the form t [a 0, a,..., a s, 2a 0 ] with a,..., a s a palindrome, then t 2 is a rational number. 36

Proof. If t 2 r is rational >, then for and a 0 t the number x t+a 0 is reduced. Since t + t 0, we have x x 2a 0 Hence x [2a 0, a,..., a s ], x [a s,..., a, 2a 0 ] and a,..., a s a palindrome. Conversely, if t [a 0, a,..., a s, 2a 0 ] with a,..., a s a palindrome, then x t + a 0 is periodic, hence reduced, and its Galois conjugate x satisfies x [a,..., a s, 2a 0 ], x 2a 0 which means t + t 0, hence t 2 Q. Lemma 49 (Serret, 878). Let x and y be two irrational numbers with continued fractions x [a 0, a,..., a n...] and y [b 0, b,..., b m...] respectively. Then the two( following ) properties are equivalent. a b (i) There exists a matrix with rational integer coefficients and determinant ± such that c d y ax + b cx + d (ii) There exists n 0 0 and m 0 0 such that a n0 +k b m0 +k for all k 0. Condition (i) means that x and y are equivalent modulo the action of GL 2 (Z) by homographies. Condition (ii) means that there exists integers n 0, m 0 and a real number t > such that x [a 0, a,..., a n0, t] and y [b 0, b,..., b m0, t]. Example. If x [a 0, a, x 2 ], then x { [ a 0,, a, x 2 ] if a 2, [ a 0, + x 2 ] if a. (50) 37

Proof. We already know by (26) that if x n is a complete quotient of x, then x and x n are equivalent modulo GL 2 (Z). Condition (ii) means that there is a partial quotient of x and a partial quotient of y which are equal. By transitivity of the GL 2 (Z) equivalence, (ii) implies (i). Conversely, assume (i): y ax + b cx + d Let n be a sufficiently large number. From ( ) ( ) ( ) a b pn p n un u n c d with we deduce q n q n v n v n u n ap n + bq n, u n ap n + bq n, v n cp n + dq n, v n cp n + dq n, y u nx n+ + u n v n x n+ + v n We have v n (cx + d)q n + cδ n with δ n p n q n x. We have q n, q n q n + and δ n 0 as n. Hence, for sufficiently large n, we have v n > v n > 0. From part of Corollary 33, we deduce ( ) un u n v n v n ( a0 0 ) ( ) a 0 with a 0,..., a s in Z and a,..., a s positive. Hence y [a 0, a,..., a s, x n+ ]. ( as 0 ) A computational proof of (i) (ii). Another proof is given by Bombieri [3] (Theorem A. p. 209). He uses the fact that GL 2 (Z) is generated by the two matrices ( ) 0 and ( ) 0. 0 The associated fractional linear transformations are K and J defined by We have J 2 and K(x) x + and J(x) /x. K([a 0, t]) [a 0 +, t], K ([a 0, t]) [a 0, t]. 38

Also J([a 0, t]) [0, a 0, t]) if a 0 > 0 and J([0, t]) t ). According to (50), the continued fractions of x and x differ only by the first terms. This completes the proof. 9 3.6 Diophantine approximation and simple continued fractions Lemma 5 (Lagrange, 770). The sequence ( q n x p n ) n 0 is strictly decreasing: for n we have q n x p n < q n x p n. Proof. We use Lemma 27 twice: on the one hand q n x p n because x n+ >, on the other hand q n x p n because x n < a n +. x n q n + q n 2 > x n+ q n + q n < q n + q n (a n + )q n + q n 2 q n + q n Corollary 52. The sequence ( x p n /q n ) n 0 is strictly decreasing: for n we have x p n < x p n. q n q n Proof. For n, since q n < q n, we have x p n q n x p n < q n x p n q n q n q n x p n < x p n. q n q n q n q n Here is the law of best approximation of the simple continued fraction. 9 Bombieri in [3] gives formulae for J([a 0, t]) when a 0. He distinguishes eight cases, namely four cases when a 0 (a > 2, a 2, a and a 3 >, a a 3 ), two cases when a 0 2 (a >, a ) and two cases when a 0 3 (a >, a ). Here, (50) enables us to simplify his proof by reducing to the case a 0 0. 39

Lemma 53. Let n 0 and (p, q) Z Z with q > 0 satisfy Then q q n+. qx p < q n x p n. Proof. The system of two linear equations in two unknowns u, v { pn u + p n+ v p q n u + q n+ v q (54) has determinant ±, hence there is a solution (u, v) Z Z. Since p/q p n /q n, we have v 0. If u 0, then v q/q n+ > 0, hence v and q n q n+. We now assume uv 0. Since q, q n and q n+ are > 0, it is not possible for u and v to be both negative. In case u and v are positive, the desired result follows from the second relation of (54). Hence one may suppose u and v of opposite signs. Since q n x p n and q n+ x p n+ also have opposite signs, the numbers u(q n x p n ) and v(q n+ x p n+ ) have same sign, and therefore q n x p n u(q n x p n ) + v(q n+ x p n+ ) qx p < q n x p n, which is a contradiction. A consequence of Lemma 53 is that the sequence of p n /q n produces the best rational approximations to x in the following sense: any rational number p/q with denominator q < q n has qx p > q n x p n. This is sometimes referred to as best rational approximations of type 0. Corollary 55. The sequence (q n ) n 0 of denominators of the convergents of a real irrational number x is the increasing sequence of positive integers for which q n x < qx for q < q n. As a consequence, q n x min qx. q q n The theory of continued fractions is developed starting from Corollary 55 as a definition of the sequence (q n ) n 0 in Cassels s book [7]. 40