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

Similar documents
Summary Slides for MATH 342 June 25, 2018

NOTES ON SIMPLE NUMBER THEORY

1. multiplication is commutative and associative;

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

Math 314 Course Notes: Brief description

Part IA Numbers and Sets

Part II. Number Theory. Year

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

Introduction to Number Theory

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,

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

CONTINUED FRACTIONS, PELL S EQUATION, AND TRANSCENDENTAL NUMBERS

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

CHAPTER 8: EXPLORING R

Public-key Cryptography: Theory and Practice

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

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

Contribution of Problems

ECEN 5022 Cryptography

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

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

0 Sets and Induction. Sets

Selected Chapters from Number Theory and Algebra

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

Discrete mathematics I - Number theory

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

Introduction to Abstract Mathematics

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.

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

Chapter 1 : The language of mathematics.

Contest Number Theory

Elementary Properties of the Integers

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

NOTES ON FINITE FIELDS

Elementary Number Theory Review. Franz Luef

1 Overview and revision

Chapter 5. Number Theory. 5.1 Base b representations

Cool Results on Primes

LECTURE NOTES IN CRYPTOGRAPHY

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.

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

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald)

Beautiful Mathematics

Number Theory Proof Portfolio

Mathematics for Cryptography

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

MATH 152 Problem set 6 solutions

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

A SURVEY OF PRIMALITY TESTS

Part IA Numbers and Sets

I Foundations Of Divisibility And Congruence 1

Chapter 14: Divisibility and factorization

Chapter 5: The Integers

Course 2316 Sample Paper 1

Lecture 4: Number theory

Math 319 Problem Set #2 Solution 14 February 2002

MATH 215 Final. M4. For all a, b in Z, a b = b a.

PRACTICE PROBLEMS: SET 1

Number Theory in Problem Solving. Konrad Pilch

4 PRIMITIVE ROOTS Order and Primitive Roots The Index Existence of primitive roots for prime modulus...

198 VOLUME 46/47, NUMBER 3

Introduction to Information Security

Number Theory Solutions Packet

MATH 310 Course Objectives

Numbers and their divisors

Winter Camp 2009 Number Theory Tips and Tricks

A Few Primality Testing Algorithms

Chapter 3 Basic Number Theory

PRIME NUMBERS YANKI LEKILI

Math 2070BC Term 2 Weeks 1 13 Lecture Notes

MA257: INTRODUCTION TO NUMBER THEORY LECTURE NOTES

Solutions for Homework Assignment 2

INTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes.

MATH 3330 ABSTRACT ALGEBRA SPRING Definition. A statement is a declarative sentence that is either true or false.

The Chinese Remainder Theorem

Math 511, Algebraic Systems, Fall 2017 July 20, 2017 Edition. Todd Cochrane

Homework #2 solutions Due: June 15, 2012

. As the binomial coefficients are integers we have that. 2 n(n 1).

MATH 117 LECTURE NOTES

1. (a) q = 4, r = 1. (b) q = 0, r = 0. (c) q = 5, r = (a) q = 9, r = 3. (b) q = 15, r = 17. (c) q = 117, r = 11.

5: The Integers (An introduction to Number Theory)

Executive Assessment. Executive Assessment Math Review. Section 1.0, Arithmetic, includes the following topics:

MAT115A-21 COMPLETE LECTURE NOTES

WORKSHEET MATH 215, FALL 15, WHYTE. We begin our course with the natural numbers:

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

Basic elements of number theory

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

Basic elements of number theory

Solutions to Problem Set 4 - Fall 2008 Due Tuesday, Oct. 7 at 1:00

1 Lecture 1 (1/5/2009)

1 Lecture 1 (1/5/2009)

Covering Subsets of the Integers and a Result on Digits of Fibonacci Numbers

Numbers, Groups and Cryptography. Gordan Savin

A Readable Introduction to Real Mathematics

Notes on Continued Fractions for Math 4400

Number Theory Course notes for MA 341, Spring 2018

PELL S EQUATION, II KEITH CONRAD

Elementary Number Theory MARUCO. Summer, 2018

Transcription:

Math 8: Advanced Number Theory Samit Dasgupta and Gary Kirby April, 05

Contents Basics of Number Theory. The Fundamental Theorem of Arithmetic......................... The Euclidean Algorithm and Unique Factorization.................. 4.3 The Riemann Zeta Function................................. 6.4 Some Functions in Number Theory............................ 9.5 Congruences, Euler s φ-function, and Wilson s Theorem............... Continued Fractions 5. Farey Fractions......................................... 5. Continued Fractions..................................... 9.3 Infinite Continued Fractions.................................4 Irrational Numbers and Infinite Continued Fractions................. 4.5 Approximation by Continued Fractions.......................... 7.6 Periodic Continued Fractions................................ 30.7 Example of a purely periodic continued fraction.................... 35.8 Pell s Equation......................................... 37 3 Rings in Number Theory 4 3. Rings............................................... 4 3. Integral Domains....................................... 44 3.3 Quadratic rings of non-square discriminant....................... 49 3.4 The Chinese Remainder Theorem............................. 5 3.5 The group (/m)...................................... 5 4 Quadratic Reciprocity, Quadratic Forms, and Quadratic Rings 59 4. Quadratic Residues...................................... 59 4. Prime Factorization in the Gaussian integers...................... 60 4.3 The Legendre Symbol and Quadratic Reciprocity.................... 6

4.4 The Jacobi Symbol...................................... 69 4.5 Binary Quadratic Forms................................... 7 4.6 Equivalence classes of BQFs................................. 74 4.7 Quadratic Rings........................................ 79 4.8 Conjugation and norms in a quadratic ring....................... 8 4.9 Nondegenerate BQFs and Quadratic rings........................ 83 4.0 Units in Quadratic Rings................................... 84 4. The Ideal Class Group.................................... 85 4. Binary Quadratic Forms and the Ideal Class Group................... 87 4.3 The Bhargava cube...................................... 9

Chapter Basics of Number Theory. The Fundamental Theorem of Arithmetic We denote by the ring of integers. The following is one of the essential axioms satisfied by. This axiom forms the basis of the method of mathematical induction. Axiom.. (Well-Ordering Property of ). Let S be any non-empty subset of the positive integers. Then S has a least element, i.e., there exists an s S such that s x for all x S. By letting S = S +, it is clear that the same property holds if S is a subset of the nonnegative integers as well (or more generally, any subset of integers bounded from below). Theorem.. (Division Algorithm). Let a, b, a 0. Then there exists unique q, r such that b = aq + r and 0 r < a. Proof. Existence: Consider the set S = {b aq : q, b aq 0}. It is clear that S is nonempty, by taking q to have opposite sign from a and larger than b. By the well-ordering property of, the set S has a least element r. So we have b = aq + r, with r 0; we must show that r < a. If on the contrary r a, we note that r a = b aq a = b a(q ± ) 0, implying that r a S, contradicting the minimality of r. Therefore r < a as desired. Uniqueness: Suppose b = aq + r with 0 r < a and b = aq + r with 0 r < a. The inequalities for r and r imply that a < r r < a. Subtracting the two equations for b yields r r = a(q q). The only multiple of a between a and a is zero. Thus r r = 0 so r = r and hence q = b r a = b r a 3 = q.

Definition..3. If a, b, then we say a divides b and write a b if there exists d such that ad = b. Theorem..4. Let a, b, not both zero. There exists a unique integer d > 0 such that: d a and d b; for e, we have e a and e b = e d. The integer d is called the greatest common divisor of a and b, denoted d = (a, b). Proof. Consider the set of all linear combinations: a,b = {ax + b y : x, y }. Let d be the smallest positive integer of the set a,b. (Note that a,b contains a positive integer, since a and b are not both zero; for example, take x = a and y = b. A smallest positive integer in a,b exists by the Well-Ordering Property of.) Claim: d a. Using the division algorithm, write a = dq + r with 0 r < d. We ll show that r a,b. We know that d = ax + b y for some integers x and y since d a,b. Thus r = a dq = a (ax + b y)q = a axq + b yq = a( xq) + b( yq). So r a,b by definition. If r is nonzero, then r is a positive integer less than d contained in a,b, contradicting the definition of d. Thus r = 0, so a = dq, i.e. d a. By symmetry, d b as well. Now suppose that e is an integer such that e a and e b. So a = eu, b = ev for some integers u and v. Since d = ax + b y for some integers x and y, we have d = eux + ev y = e(ux + v y) and therefore e d. Corollary..5. Given integers a, b, not both zero, there exist x, y such that ax + b y = (a, b). Moreover, for z, there exist x, y such that ax + b y = z if and only if (a, b) z. 4

Proof. The first sentence was proved in the course of the proof of the previous theorem. For the second sentence, note that if z is a multiple of d = (a, b), say z = du, then ax + b y = d implies that axu + b yu = du = z. Conversely, if ax + b y = z then d a, d b implies that d (ax + b y) = z. Definition..6. We say that integers a and b are relatively prime or coprime if (a, b) =. Theorem..7 (Fundamental Theorem of Arithmetic). Let a, b, and c be integers. If a and b are relatively prime and a bc, then a c. Proof. Since (a, b) =, we can write = ax +b y for some integers x and y by Corollary..5. Then c = c(ax + b y) = cax +c b y. However, we clearly have a cax, and a bc implies a cb y, so a (cax + c b y) = c as desired.. The Euclidean Algorithm and Unique Factorization Suppose we want to find the greatest common divisor of two integers a and b. Suppose a b > 0. Using the division algorithm, write a = bq + r with 0 r < b. If r = 0 then b divides a, so (a, b) = b. If r 0, we claim that (a, b) = (b, r); hence we can replace the pair {a, b} with {b, r} and repeat the process until we eventually find the greatest common divisor. This is called the Euclidean Algorithm. To prove our claim, let d = (a, b) and d = (b, r). Then d a and d b, so d a bq = r. Therefore d d by the definition of d = (b, r). Similarly, d b, d r implies d bq + r = a, hence d d. Therefore we have d = d. Example. We show (05,87) = 3 using the Euclidean Algorithm: 05 = 87 + 8 87 = 8 4 + 5 8 = 5 + 3 5 = 3 5 + 0. Definition... An integer p > is prime if for all a, b, we have p ab = p a or p b. Definition... An integer p > is irreducible if p = ab with a, b positive integers = a = or b =. Theorem..3. A positive integer p is prime if and only if p is irreducible. 5

Proof. : Suppose p is prime. Say p = ab, where a, b are positive integers. By definition of prime, p ab implies p a or p b. Say p a, so pu = a for some integer u. So p = pub, which implies = ub, and thus u = b =. Similarly if p b, then we find a =. : Suppose p is irreducible. Say p ab. We need to show that p a or p b. Let (p, a) = d. Since d p and p is irreducible, we know that either d = or d = p. If d = p then p = d a, so we are done. Therefore suppose d =, i.e. (p, a) =. By the Fundamental Theorem of Arithmetic, p ab and (p, a) = implies that p b. Theorem..4 (Unique Factorization). Every nonzero integer can be factored uniquely as ± times a product of primes. More precisely, for all nonzero integers n, there is a unique expression n = ±p e pe pe r where < p r < p < < p r are prime numbers and e,..., e r are positive integers. (For n = ±, we take r = 0 and view the empty product to mean n = ±.) Proof. Existence. Let n be a positive integer. We need to show that n can be factored as a product of primes. Let = {positive integers n that can t be factored as a product of primes}. Assume is nonempty and let n be the minimal element of. Note that n >, since we view n = as the empty product of primes. Case : n is prime. Then n = n is already a factorization of n into primes, hence n. Case : n is not prime. Then n = ab for positive integers a, b both smaller than n. But a and b are not in since n is the least element of. So a, b can be factorized as a product of primes and n = ab. Thus n is a product of primes and n is not in. Uniqueness. Let n be a positive integer. Suppose n = p p p r and n = q q q s where p i, q i are positive primes. Then we need to prove that r = s and the p i s are the same as q i s up to ordering. (One easily checks that this is equivalent to the statement of the theorem.) We prove this by induction on r. If r = 0, then n = = q q q s which implies that s = 0, since is not divisible by any prime. Therefore assume that r and p p p r = q q q s. (..) Then p r q q q s, so by the definition of a prime, p r q j for some j =,..., s. But the q j s are all prime and hence irreducible, so p r q j implies p r = q j. Without loss of generality, after possibly reordering the q i, we suppose p r = q s and cancel from (..). We obtain p p p r = q q q s. By induction r = s and {p, p,..., p r } = {q, q,..., q s } as multisets (i.e. counting multiplicity). This implies that r = s and {p, p,..., p r } = {q, q,..., q s } as 6

multisets, as desired..3 The Riemann Zeta Function The following is Euclid s classical proof of the infinitude of the primes (c. 300 BC). Theorem.3. (Euclid). There are infinitely many prime numbers. Proof. Suppose there are only finitely many primes p,..., p n. Consider the integer N = p p n. By the Unique Factorization Theorem, the positive integer N + factors uniquely into primes, and in particular has at least one prime factor. Say this prime factor is p i. By the definition of N, it is clear that p i N. But p i (N + ) as well, and hence p i ((N + ) N) =. This is a contradiction since p i is a prime number. Therefore, there must be infinitely many primes. Remark.3.. If we define a sequence by p = and for n >, p n = the smallest prime divisor of p p p n, then it is unknown whether {p, p, p 3, } is the set of all primes in. We now give Euler s analytic proof of the infinitude of the primes (700s). Definition.3.3 (Riemann zeta-function). For real number s >, define ζ(s) := This definition of ζ(s) actually makes sense for all complex numbers s with Re(s) >. Lemma.3.4. For s >, we have ζ(s) = ( p prime p s ). This is called the Euler product representation of ζ(s). Proof. Before giving a rigorous proof, we give the intuitive idea, which boils down to the Unique Factorization Theorem. Not worrying about issues of convergence, we have p prime p s = p prime ( + p s + p s + ), using the formula for a geometric series. Multiplying out the terms on the right side, we get the sum of all terms of the form p α s pα n n as the pi range over all primes. By the Unique Factorization Theorem, every positive integer n has a unique such representation. In other words, we obtain the sum of n s for all n >0, giving the definition of ζ(s). Now let us make this argument rigorous. Fix a positive integer y, and define n= n s. N y := {n : n is divisible only by primes less than or equal to y}. 7

Then we claim that for any s > 0, we have p y p prime p s = n N y n s. (.3.) (There are lots if ways to see that the right side converges for s > 0. For instance, note that there are at most (n + ) y elements of N y less than or equal to n. In particular, there are at most (n + ) y elements of N y between n and n. So the sum n N y n s is majorized by n= (n + )y / (n )s. This latter sum converges for all s > 0 by the standard tests from calculus, such as the ratio test.) To prove (.3.), fix an ε > 0. Note that since for each prime p y, = lim s p ( + k p s + p s + + p ks ). Since there are only finitely many primes p y, we can choose k large enough so that p s p y p prime p y p prime ( + p s + p s + + p ks ) < ε (.3.) for each prime p y. Expanding out the second product, we obtain the sum of n s for all n in the set N y,k = {n : n = p α pα pα r r with each p i y and each α i k}. Since the N y,k for increasing k are nested sets of integers (i.e. N N N 3 ) whose union is N y, we can take k large enough so that n s n N y n s n N y,k Using the triangle inequality with (.3.) and (.3.3), we obtain p s p y p prime < ε. (.3.3) n s n N y Since this is true for all ε > 0 we obtain (.3.) as desired. < ε. 8

Now we assume s >, and explore what happens as we take the limit as y. Since {,, y} N y >0, we have using (.3.): n y n s p y p prime p s n= n s = ζ(s). Taking the limit as y, the left hand side approaches ζ(s), so by the squeeze theorem, we have as desired. ζ(s) = p prime p s We can now give Euler s proof of the infinitude of the primes: Euler s proof of Theorem.3.. Using Riemann sums, one finds that for s >, we have Therefore, n= n > s lim s + n= From Lemma.3.4, we therefore conclude that lim s + p prime x s d x = s. n s =. p s =. If there were only finitely many primes, then this limit would not be infinity, it would be the positive rational number p prime p Therefore, there must be an infinite number of primes. Now that we know that there infinitely many primes, we can ask questions about how dense the primes are within all the integers. There are many ways to make this question precise. Here is one result in this realm of questions.. Proposition.3.5. We have p y p prime p > log(log y). 9

In particular, p prime p diverges. Proof. Recall that by estimating the sum by an integral, we have using Riemann sums we have for y > : y n= n > y+ y n= d x = log(y + ) > log(y). x log(y). More precisely, n Therefore by (.3.). Hence log(y) < y n= log log(y) < n < n = p n N y p y p prime p y p prime log. p It is easy to show that for 0 x, we have x ex+x and hence log( ) x + x. x Thus log log y <. Note Thus as desired. p y p prime p < p y p prime n= log log y < + n < p + p p y p prime d x x =. p.4 Some Functions in Number Theory Definition.4.. Let a, b be two nonzero integers. The least common multiple (lcm) of a and b, denoted [a, b] = lcm(a, b), is the unique positive integer m such that a m, b m, and such that for all n a n, b n = m n. 0

Notice the duality of the greatest common divisor and the least common multiple; the definition of least common multiple is the same as greatest common divisor with the divisibilities reversed. Unique factorization in the integers tells us that any nonzero integers m and n can be written uniquely as n = ± p prime p α p(n), m = ± p prime p α p(m), (.4.) where α p (n) 0 and α p (n) = 0 for all but finitely many p. Note that n m iff α p (n) α p (m) for all p. Therefore (m, n) = p prime p min(α p(n),α p (m)), [m, n] = p prime p max(α p(n),α p (m)). Lemma.4.. Let m and n be nonzero integers. We have mn = [m, n](m, n), i.e. [m, n] = mn (m,n). Proof. In general, min(a, b)+max(a, b) = a+ b. The result therefore follows from (.4.). Define d(n) := = number of positive divisors of n d n and σ(n) := d = sum of positive divisors of n. d n As implied by our descriptions, when d n is written as the subscript in a sum, one typically assumes that the sum is over positive divisors d of n. Definition.4.3. A function f : is called multiplicative if for any m, n with (m, n) = we have f (m, n) = f (m) f (n). Lemma.4.4. If f is multiplicative and F(n) = f (d), then F is multiplicative. d n Proof. Let m and n be relatively prime integers. First we show that there is a bijection: {d mn, d > 0} {ordered pairs (d, d ), where d m, d n, and d, d > 0} (.4.) d (gcd(d, m), gcd(d, n)) d d (d, d ). Let us prove this by showing that the given maps are mutually inverse. In one direction, we need to show that if d mn, then d = (d, m)(d, n). So let d = (d, m) and d = (d, n), and write d = d d, m = d m, and d = d d, n = d n with (d, m ) = and (d, n ) =. The

equation d = d d = d d together with (d, d ) = (which holds since d m and d n and (m, n) = ) implies that d d, by the fundamental theorem of arithmetic. Conversely, d = d d mn = d m n implies d m n, which implies d n, again by the fundamental theorem of arithmetic. But d n, d d implies d d by the definition of gcd. Therefore d d and d d, so d = d, and we obtain d = d d as desired. To prove that the maps are inverse in the other direction, we need to show that if d m and d n, then (d d, m) = d and (d d, n) = d. Now d m and d d d. Furthermore, if e is an integer such that e d d and e m, then note that (e, n) = since (m, n) =. Therefore (e, d ) = since d n, and hence e d by the fundamental theorem of arithmetic. Thus d satisfies the definition of the gcd of d d and m. Similarly we have (d d, n) = d. We have therefore established that (.4.) is a bijection. Using this bijection, the proof of the lemma is now a simple computation: F(mn) = d mn f (d) = f (d d ) d m d n = f (d )f (d ) d m d n = f (d ) f (d ) d m =F(m)F(n) d n as desired. Corollary.4.5. The functions d and σ are multiplicative. Proof. This follows as a direct consequence of the previous lemma, since the functions f (d) = and f (d) = d are clearly multiplicative. The divisors of a prime power p α are {, p, p,..., p α }. Therefore, we have d(p α ) = α + and σ(p α ) = + p + p + + p α = pα+ p.

Corollary.4.5 therefore implies that if the prime factorization of n is n = p prime pαp(n), then d(n) = (α p (n) + ) p prime and p α p (n)+ σ(n) =. p p prime.5 Congruences, Euler s φ-function, and Wilson s Theorem Definition.5.. Let a, b, m be integers. We say that a b (mod m) if m (a b), i.e. if there exists x such that mx = a b. With m fixed, congruence modulo m is an equivalence relation on. We denote the set of equivalence classes by /m. When m is a positive integer, the equivalence classes have standard representatives given by 0,,,..., m. The set of equivalence classes /m is equipped with the usual operations of addition and multiplication modulo m. Theorem.5.. (mod m (a,m) ).. Let a and m be nonzero. Then ax a y (mod m) if and only if x y. Let m and n be nonzero. Then we have x y (mod m) and x y (mod n) if and only if x y (mod [m, n]). Proof.. ax a y mod m if and only if m (ax a y) if and only if m a(x y). Let d = (m, a), then m = dm and a = da, with (m, a ) =. Thus m a(x y) dm da (x y) m a (x y). By the Fundamental Theorem of Arithmetic, this holds if and only if m (x y), i.e. if and only if x y (mod m ).. m (x y) and n (x y) if and only if [m, n] x y, by the definition of lcm. Definition.5.3. Let φ(n) := #{ d n : (d, n) = }. This is the Euler-totient function. Example. φ() =, φ() =, φ(3) =, φ(4) =, φ(5) = 4, φ(6) =. For any prime p, we have φ(p) = p. More generally for a prime power, we have φ(p α ) = p α p α = p α (p ), (.5.) 3

since the numbers relatively prime to p α are exactly those not divisible by p. Define (/n) (/n) to be the set of classes x such that there exists another class y with x y (mod m). This subset contains and is closed under multiplication and inverses; in other words, it forms a group under multiplication. Proposition.5.4. φ(n) = #(/n). Proof. There exists a bijection {k : k n} /n k Equivalence class of k (mod n). Under this bijection, k and n are coprime if and only if the equivalence class of k is a unit. Indeed, if k and n are coprime, then there exist a, b such that ak + bn =. Reducing modulo n, we find ak mod n. Conversely, if k represents an element of (/n), then by definition there exists an a such that ak mod n. Therefore, there exists a b such that bn = ak, which implies that bn + ak = and thus k and n are coprime. The result now follows from the definition of φ(n). Theorem.5.5. If (a, n) =, then a φ(n) (mod n). Proof. This follows from the previous proposition combined with Lagrange s theorem in group theory: in the group (/n), any element raised to the power of the size of the group is the identity. However, we ll give an explicit proof that works for our special case (and can easily be seen to work for arbitrary finite abelian groups). Let a, a,, a φ(n) be the positive integers less than or equal to n that are relatively prime to n. Note that these elements form a complete set of representatives for (/n). Since (a, n) =, it follows that aa, aa,..., aa φ(n) are all relatively prime to n as well. Furthermore aa i aa j (mod n) implies that a i a j (mod n) since (a, n) =, by Theorem.5.. Therefore, the elements aa, aa,..., aa φ(n) form a complete set of representatives of (/m) as well. Therefore, we have two complete sets of representatives, so the elements aa, aa,..., aa φ(n) must be congruent to the elements a, a,..., a φ(n), but in some possibly different order. In particular, the products of all the elements in these complete sets of representatives must be congruent, i.e. aa aa aa φ(n) a a a φ(n) (mod n), so a φ(n) (a a a φ(n) ) a a a φ(n) mod n. 4

Since (a i, n) = for all i, we have (a a a φ(n), n) =. Therefore, by Theorem.5. we may divide both sides of the previous congruence by the common factor a a a φ(n), and obtain a φ(n) (mod n) as desired. Corollary.5.6 (Fermat s Little Theorem). If p is prime, and (a, p) =, then a p (mod p). For any a, we have a p a (mod p). Theorem.5.7 (Wilson). If p is prime then (p )! mod p. Proof. If p is equal to or 3 this is easily computed, so we will assume p 5. Suppose a p. Then a is coprime to p, so there exists a unique integer a, such that aa (mod p) and a p. Because p is prime, a = a p (a ) = (a + )(a ) p (a ) or p a +. This occurs if and only if a = or a = p. We can therefore group the integers, 3,..., p into pairs a, a where a a and aa mod p. When these p 3 congruences are multiplied together and rearranged we obtain 3 4 (p ) = (p )! (mod p). Multiply this congruence by p to obtain (p )! p (mod p) as desired. 5

Chapter Continued Fractions. Farey Fractions For each positive integer n, the Farey sequence at stage n is a certain list of fractions. As we will eventually prove, the list contains all reduced fractions between 0 and with denominator less than or equal to n, in increasing order. The rule for defining the Farey sequence at stage n is recursive, as follows. At the first stage we start with 0 = 0/ and = /. The recursive rule is that at the nth stage, we include a+a if a b+b b b + b n. For example, we have: st stage: nd stage: 3rd stage: 4th stage: 0 0 0 and a b 0,,,, 3,, 3,, 4, 3,, 3, 3 4,. are consecutive in the (n )st stage and Proposition... If a b and a b are consecutive in the nth stage, then a b b a =. Proof. We use induction on n. At the st stage, we have 0 =. Now suppose the result holds at the (n )st stage. If a b following three things happens. and a b are consecutive in the nth stage, then one of the 6

. a b, a b are consecutive in the (n )st stage. In this case the result holds by induction.. a = a + x and b = b + y where a and x b y induction we have x b a y =. Hence are consecutive at the (n )st stage. Then by a b ab = (x + a)b a(y + b) = x b + ab a y ab = x b a y =. 3. a = x + a and b = y + b where x a and are consecutive at the (n )st stage. The y b result can be proven in this case similarly to (). Corollary... The fractions in the Farey sequence are reduced. Proof. Since a b b a =, it follows that (a, b) =. Corollary..3. The fractions in the Farey sequence are in increasing order. Proof. We have a /b a/b = (a b b a)/(bb ) = /(bb ) > 0. Theorem..4. If a a and are consecutive in the nth stage, then the rational number between b b them with smallest denominator is a+a. b+b Proof. Note that a+a does indeed lie between a a and (prove this to yourself). Now suppose b+b b b a < x < a, where a a = by Proposition... We therefore have: b y b b b bb bb = a b a b a = b x x + y y a b = a y b x b y + bx a y b y b y + b y = b + b bb y. Multiplying by bb y, we find that y b + b. If y = b + b then we must have equality in the inequalities above. Hence a y b x = and bx a y = ; solving these two linear equations in two variables gives x = a + a and y = b + b as desired. 7

Corollary..5. At the nth stage, the Farey sequence contains all rational numbers in [0, ] with denominator less than or equal to n in increasing order. Proof. We use induction on n. The statement clearly holds when n =. Suppose that the statement holds for the (n )st stage and suppose that it is not true at the nth stage. Then there exists x [0, ] such that x is not in the nth stage. Let a a and be consecutive in the n n b b (n )st stage such that a < x < a. By our previous theorem, n b + b. But if n = b + b, b n b then x = a + a by the theorem. However if x = a + a and n = b + b, then x/n is in the nth stage by the definition of the Farey sequence. Thus n > b + b, which implies b + b n. But then by induction, a+a must be in the (n )st stage, contradicting the fact that a/b and b+b a /b are consecutive in the (n )st stage. Definition..6. The Infinite Farey sequence at the nth stage is the (doubly infinite) list of all reduced fractions with denominator less than or equal to n, in increasing order. Theorem..7. Let n be a positive integer and x a real number. There exists a rational number a such that x a < with 0 < b n. b b b(n+) Proof. Consider the Farey sequence at the nth stage; let p/q and r/s be consecutive fractions in the sequence such that p q x < r s. Case : Suppose p q x < p + r q + s. Let a = p. Then b n by definition, and we calculate b q since q + s n +. Case : Suppose x a p + r < b q + s p q = q(q + s) q(n + ) p + r q + s x < r s. Let a = r. The proof in this case is similar to Case and left to the reader. b s Theorem..8 (Hurwitz). If x is an irrational number, then there exist infinitely many rational numbers h k such that x h k < 5k. Proof. Let a/b and c/d be consecutive fractions in the Farey sequence at the nth stage such that a b < x < c d. Then a b < x < a+c b+d or a+c b+d < x < c d. 8

Case : a b < x < a+c b+d. We claim that a b, a+c b+d, or c d has the desired property. If not, then x a b 5b, a + c b + d x, 5(b + d) c d x. (..) 5d Adding the first and third inequalities, Multiplying by 5(bd) we obtain bd = c d a b 5 b + d 5bd b + d. (..) Similarly adding the first and second inequalities of (..) we obtain b(b + d) 5 b +, (b + d) and hence 5b(b + d) (b + d) + b. (..3) Let y = b d. Dividing (..) and (..3) by d, we obtain 5y(y + ) (y + ) + y and 5 y y +. (..4) The first of these inequalities simplifies to 5(y + y) y + y+, which yields ( 5)y + ( 5)y + 0. Dividing by 5, which is negative, we obtain y + y ( + 5) 0. Solving for the roots, we obtain y 3 5 or y + 5. On the other hand, the second inequality in (..4) can be written y 5 y + 0, which yields 5 y 5+. Therefore the only possibility is y = + 5, which is a contradiction since y is rational. Case : Similar to Case and left to the reader. Theorem..9. 5 is the best (i.e. largest) constant possible in Hurwitz Theorem. In other words, for every c > 5 there exists an irrational number x such that there exist only finitely many rational numbers h x such that k h <. In fact x = + 5 satisfies this property for all k ck such c. Proof. Suppose there exists infinitely many rational h k with x = + 5 such that h k x < ck. (..5) 9

We will show that c 5. By the triangle inequality, h k 5 = h k + 5 + 5 h k + 5 + 5 < ck + 5. (..6) If we multiply (..5) and (..6), then the left hand side is: h k + 5 h k 5 = h k h k = h hk k k k. Therefore we obtain < + 5. Multiplying by ck we obtain c < + 5. As k k ck ck ck goes to infinity, the right side approaches 5. Therefore c 5 as desired.. Continued Fractions Let a 0, a,... be real numbers. Assume that a i > 0 for i > 0. Define a 0, a,..., a n = a 0 +. a + a +... + an + a n Example 3., 3, 4 = + = + 4 3 = 30 3. 3 + 4 Definition... A simple continued fraction is a continued fraction a 0, a,..., a n where each a i is an integer. Clearly, a simple continued fraction is a rational number. The converse is also true: Proposition... Any rational number can be written as a simple continued fraction. Proof. We are given a rational number p in reduced form. If q = ±, then p/q = ±p = ±p, q and we are done. Therefore suppose that q. We assume without loss of generality that 0

p > 0. We let u 0 = p and u = q. By the Euclidean Algorithm u 0 = u a 0 + u with 0 u < u u = u a + u 3 with 0 u 3 < u. u j = u j+ a j. Claim: a 0, a,..., a j = p q. Define r i = u i u i+. Dividing the equation u = u i+ a i + u i+ by u i+, we see that r i = a i + r i+. Starting from r 0 = a 0 + /r, and applying this equation recursively for r, r,..., until r j = a j, we see that So r 0 = a 0, a, a,..., a j. Since r 0 = p/q, this proves the desired result. Note that there is a simple way to alter a given simple continued fraction representation of a given rational number. Namely, suppose we have x = a 0, a,..., a j with a j >. Then we also have x = a 0, a,..., a j,, since (a j ) + / = a j. To eliminate this ambiguity, we impose the condition on our simple continued fractions that they do not end with except for the case =. We formalize this with the following definition: Definition..3. We say that a simple continued fraction x = a 0, a,..., a j is in simplest form if j = 0 or if j > 0 and a j >. Theorem..5 below states that the simple continued fraction representation in simplest form of a given rational number is unique. First we prove the following lemma. Lemma..4. Suppose that the simple continued fraction x = a 0, a,..., a j is in simplest form. Then a 0 = x, the greatest integer less than or equal to x. Proof. If j = 0, then x = a 0 = a 0, so we are done. Therefore suppose j > 0. We have x = a 0 + a + a +... Consider the expression y = a, a,..., a j, so x = a 0 + / y. We will prove that y >, which will imply that 0 < / y < and hence a 0 < x < a 0 + as desired. If j =, then y = a j = a j > by the assumption that our continued fraction is in simplest form, so we are done in this case. If j >, then y = a + / a, a 3,..., a j ; furthermore we.

have a and a, a 3,..., a j > 0 by the definition of continued fractions, so we have y > as desired. This completes the proof. Theorem..5. The representation of a rational number as a simple continued fraction in simplest form is unique. In other words, if x = a 0, a,..., a j = b 0, b, b,..., b n, with both representations in simplest form, then j = n and a i = b i for 0 i n. Proof. By Lemma..4, we have a 0 = x and b 0 = x as well. Therefore a 0 = b 0. Subtracting this equation from a 0, a,..., a j = b 0, b, b,..., b n and taking the reciprocal, we obtain a, a,..., a j = b, b,..., b n. Since these continued fraction representations have shorter length by one, we see by induction that j = n and a i = b i, for i n..3 Infinite Continued Fractions Let {a i } be a sequence of integers, all but possibly a 0 positive. We will make sense of the infinite continued fraction a 0, a, a,... by showing that that lim n a 0, a,..., a n exists. Each of the finite continued fractions h n /k n = a 0, a,..., a n is called a convergent to the infinite continued fraction. The convergents may be computed recursively as follows. Let h = 0, h =, k =, k = 0. Inductively, define h n = a n h n + h n and k n = a n k n + k n. In practice, it is nice to organize in a table as follows: a 0 a a a 3 0 h 0 = a 0 h = a h 0 + h = a h + h 0 h 3 = a 3 h + h... 0 k 0 = k = a k = a k + k 0 k 3 = a 3 k + k... Note that the k n are all positive, since the a i for i > 0 are positive. Proposition.3.. We have a 0, a,..., a n = h n /k n. In fact, more generally we have a 0, a,..., a n, x = xh n + h n xk n + k n. (.3.) Proof. First note that the more general claim implies the first sentence by plugging in x = a n, since in this case the right hand side is h n k n by definition.

We now prove the more general claim by induction on n. In the base case n = 0, we want to show that x = xh +h = x = x, which is true. In the case n =, we have a xk +k 0, x = a 0 +. x On the other hand xh 0+h = xa 0+ = a xk 0 +k x 0 + as desired. x Now we carry out the inductive step, and suppose n. By definition, we have a 0, a,..., a n, x = a 0, a,..., a n, a n + x. The right hand side is a continued fraction of shorter length, so we can apply the inductive hypothesis to find: by definition. Example 4., 3,, 4, 5 = + with associated table: a 0, a,..., a n + x = (a n + x )h n + h n 3 (a n + x )k n + k n 3 3 + = xa n h n + h n + xh n 3 xa n k n + k n + xk n 3 = xh n + h n xk n + k n + 4 + 5, - 3 4 5 0 - -5-7 -33-7 0 3 4 9 99 Proposition.3.. The convergents h n /k n satisfy h n k n h n k n = ( ) n, and hence h n k n h n k n = ( )n k n k n. Proof. We use induction on n. The base cases n =, 0 are easily checked. For the inductive step, we use the defining equations for h n and k n and multiply by k n and h n, respectively. h n = a n h n + h n (k n ) (.3.) k n = a n k n + k n (h n ) (.3.3) 3

Subtracting.3.3 from.3., we obtain h n k n h n k n = h n k n h n k n = ( ) n = ( ) n. Proposition.3.3. We have h n k n k n h n = ( ) n a n, so h n k n h n k n = ( )n a n k n k n. Proof. Using the defining equation of h n and k n, we have h n k n k n h n = (a n h n + h n )k n (a n k n + k n )h n = a n (h n k n k n h n ) = a n ( ) n = a n ( ) n. Recall that we write r n = h n /k n = a 0, a,..., a n for the convergents of the continued fraction. Corollary.3.4. The sequence of even-numbered convergents r 0, r, r 4,... is increasing, while the sequence of odd-numbered convergents r, r 3, r 5,... is decreasing. Furthermore, every even convergent is less than every odd convergent, i.e. r n < r m+ for all n and m. Proof. The first sentence follows directly from Proposition.3.. For the second sentence, suppose for the sake of a contradiction that r n r m+ for some n, m. Then: If n m, note that r m r n r m+. But r m+ r m = k m k m+ > 0. If m n, note that r n r m+ r n+, which again is a contradiction as in the previous case. Therefore r n < r m+ as desired. Theorem.3.5. lim n r n exists. Proof. The sequence {r 0, r, r 4,... } is a monotonically increasing sequence of real numbers, bounded above by r. Therefore lim n r n exists; call this limit L 0. Similarly {r, r 3, r 5,... } is monotonically decreasing and bounded below by r 0. Therefore lim n r n+ exists; call this L. 4

Since r n < r n+ for all n it is clear that L 0 L. Now suppose for the sake of a contradiction that L > L 0. Since each r n < L 0 and each r n+ > L, we have = r k n k n+ r n > L L 0. n+ Since /k n k n+ 0 as n, this is a contradicion if L L 0 > 0. Therefore L L 0 = 0, so L = L 0, and therefore lim n r n = L 0 = L. Definition.3.6. We define a 0, a,..., a n,... := lim n r n, where r n = h n /k n = a 0, a,..., a n are the convergents of the continued fraction..4 Irrational Numbers and Infinite Continued Fractions Theorem.4.. An infinite continued fraction is irrational. Proof. Let θ = a 0, a,.... By the proof of Theorem.3.5, we see that θ lies between any two consecutive convergents r n and r n+, since the odd-numbered convergent is greater than θ and the even-numbered convergent is less than θ. Hence θ r n < r n r n+ = k n k n+, where the equality is given by Proposition.3.. Multiplying by k n, we obtain k n θ h n < /k n+. Assume that θ is rational, say θ = a/b where b is nonzero and (a, b) =. Multiplying the previous inequality by b, we obtain k n a h n b < b/k n+. Since the denominators k n are unbounded, for n large enough we have b/k n+ and b/k n are less that. We claim that k n a h n b is nonzero. Otherwise h n /k n = a/b; since the reduced fraction representation of a rational number is unique, and (h n, k n ) = (a, b) =, with k n and b positive, we have b = k n. This contradicts b/k n <. Therefore k n a h n b 0 as claimed. But then 0 < k n a h n b <. Therefore θ is not rational. }{{} integer We next show that a given irrational number can have at most one infinite continued fraction representation. Theorem.4.. Suppose θ = a 0, a, = b 0, b, then a i = b i for all i 0. Proof. The idea of the proof is the same as the rational case, as follows. We know that a 0 and 5

b 0 are uniquely determined by θ, namely a 0 = b 0 = θ. Then from a 0 + a +... = b 0 +, b +... we can subtract a 0 = b 0 and invert, obtaining a + a +... = b +. b +... Hence a = b by the same logic as above we can continue this process to see a i = b i for all i 0. To make this rigorous, suppose θ = a 0, a,... = b 0, b,... with a n b n for some n. Fix the smallest such index, i.e. suppose a i = b i for i n and a n b n. So θ = a 0 + a + a +... = b 0 + b + b +.... By cancelling and inverting n times as above we obtain a n + a n+ +... = b n + b n+ +... = x. Then a n = b n = x. Theorem.4.3. Given an irrational real number θ, there exist integers a i for i 0 with a i positive for i > 0, such that θ = a 0, a,.... Proof. We define the a i recursively. Let a 0 = θ and define θ 0 = θ. For n, define θ n = θ n a n and a n = θ n. Claim: θ n is irrational for all n and a n for n > 0. This is proved by induction. For the base case, we are given that θ 0 = θ is irrational. For the inductive step, since θ n is irrational and a n is an integer, it follows that θ n a n is irrational and hence that θ n = 6

/(θ n a n ) is irrational. Next, to show that a n, we need to show θ n since a n = θ n. By definition of θ n, this is equivalent to /(θ n a n ), that is, 0 < θ n a n. This is true since a n = θ n, and since a n θ n by the inductive hypothesis (since θ n is irrational and a n is an integer). The claim implies that θ = a 0, a,... is a well-defined infinite continued fraction, and it remains to show that θ = a 0, a,.... By our definition θ = θ 0 = a 0 + = a 0, θ θ = a 0 + = a a + 0, a, θ. θ Thus in general θ = a 0, a,..., a n, θ n+ Here the second equality follows from equation (.3.). Now = θ n+h n + h n θ n+ k n + k n (.4.) θ θ rn n+ h n + h n = h n θ n+ k n + k n k n k = n h n+ h n k n k n (θ n+ k n + k n ) = k n (θ n+ k n + k n ), (.4.) by Proposition.3.. The denominator of the last expression is at least k n k n (since θ n+ and k n > 0). Hence we obtain θ rn < /(kn k n ), which approaches 0 as n approaches infinity. This concludes the proof. 7

Example 5. Let θ = 7. a 0 = 7 = 7 + 7 = = + a = 7 3 3 3 = 3 7 + 3 7 + 7 = = + a = 7 6 6 = 7 + 7 + 7 = = + a 3 = 7 6 3 3 3 = 3 7 + 6 = 7 + = 4 + ( 7 ) a 4 = 4 7 3 Inverting again we obtain /( 7 ) as in the second line, implying that the process will repeat. Therefore 7 =,,,, 4,,,, 4,... =,,,, 4..5 Approximation by Continued Fractions In this section we study how well the convergents of the continued fraction of an irrational number approximate the number. In a certain sense, we will show that the convergents are the best possible" rational approximations to the number. Theorem.5.. Let θ be an irrational real number and let h n /k n be the convergents of the continued fraction of θ. Then θ h n < <. k n k n k n+ kn Proof. θ lies between h n k n and h n+ k n+. So θ h n k < h n+ h n n k n+ k n h = n+ k n h n k n+ k n k n+ =. k n k n+ The second inequality of the theorem follows since k n+ > k n. Theorem.5.. We have θ k n h n < θ k n h n. Proof. Let θ n = a n, a n+,... as in Theorem.4.3. The equality a n = θ n implies a n + > θ n. 8

So θ n k n + k n+ < (a n + )k n + k n = (a n k n + k n ) + k n = k n + k n k n+. (.5.) We therefore obtain θ h n = k n (θ n k n + k n ) >. k n k n+ k n Here the equality was proven in (.4.), and the inequality follows from (.5.). Multiplying by k n yields θ k n h n > k n+ > θ k n h n, where the second inequality follows from Theorem.5.. one. As a corollary, we see that each convergent to θ is a better approximation than the previous Corollary.5.3. We have θ h n k n < θ h n k n. Proof. θ h n k n = k n k n θ h n < k n k n θ h n = k n θ h n < θ h n. k n k n k n We now move on to proving that the convergents h n /k n are in some sense the best rational approximations to θ. Theorem.5.4. Let θ be an irrational number and a rational with b > 0. If θ b a < θ k b n h n for some n 0 then b k n+. Proof. Suppose θ b a < θ k n h n for some n 0 and b < k n+. Consider the system of 9

linear equations xk n + yk n+ = b, xh n + yh n+ = a. This can be written in the following way: k n k n+ x b =. h n h n+ y a }{{} determinant=± Since the determinant of the matrix on the left is ±, there is a unique integer solution (x, y). Furthermore x and y are not both zero since (a, b) (0, 0). Claim: x, y 0. If x = 0 then b = yk n+, which implies b k n+. If y = 0 then b = xk n and a = xh n, so θ b a = x θ kn h n θ kn h n. Claim: x and y have opposite signs. If y < 0 then xk n = b yk n+, which implies x > 0. If y > 0 then xk n = b yk n+ < 0 since b < k n+. Thus x < 0. This proves the claim. Next note that θ k n h n and θ k n+ h n+ have opposite signs since θ h n and θ h n+ k n k n+ opposite signs. Therefore, x(θ k n h n ) and y(θ k n+ h n+ ) have the same sign. Putting this all together, we obtain have θ b a = θ(xk n + yk n+ ) (xh n + yh n+ ) = x(θ k n h n ) + y(θ k n+ h n+ ) = x(θ k n h n ) + y(θ k n+ h n+ ) > θ k n h n. This concludes the proof. As a corollary, we find that a convergent h n /k n is the best rational approximation to θ with denominator at most k n. Corollary.5.5. If a rational number a b with b > 0 satisfies θ a b < θ h n k n, then b > k n. Proof. Suppose that θ a b < θ h n k n and b k n. We obtain θ b a < b θ h n k n θ h n = θ k n h n, contradicting the previous theorem since b k n < k n+. k n k n 30

Finally, we prove that any sufficiently good rational approximation to an irrational number must be a convergent of the continued fraction. Theorem.5.6. Let θ be an irrational real number. If a rational number a with b > 0 satisfies b θ a <, then a = h n for some convergent h n of the continued fraction of θ. b b b k n k n Proof. Since the k n are increasing and tend to infinity, we have k n b < k n+ for a unique n. By Theorem.5.4, we have θ k n h n θ b a < b. This implies θ h n k n < bk n. Hence h n a θ k n b a + b θ h n k n < b +. bk n (triangle inequality) Multiplying by bk n, we obtain bh n ak n < k n +, where the second inequlity follows b since b k n. This implies bh n ak n = 0, since it is an integer with absolute value less than. Therefore bh n = ak n, and hence a b = h n k n..6 Periodic Continued Fractions We start with an example. Example 6. Let θ = + 5. At the next step will invert to obtain Therefore a 0 = [θ] =, θ a 0 = + 5 + 5 = ( + 5) = + + 5 a =. 4 + 5 θ = + 5 once again, and hence the process will repeat. =,,,... =. Recall that in an earlier example we found 7 =,,,, 4. These two examples lead to the following definition. Definition.6.. A continued fraction θ = a 0, a, a,..., is called periodic if there exists an N 0 and an r such that a n = a n+r for all n N. The integer r is called the period of the continued fraction, and we write θ = a 0, a,..., a N, a N, a N+,..., a N+r. A continued fraction is called purely periodic if we may take N = 0, i.e. if it has the form θ = a 0, a,..., a r. 3

Example 7. Let θ = 3, 4. Then θ = 3, 4, θ = 3 +. 4 + θ The right side simplifies to 3θ+3 4+θ, and hence we obtain 4θ + θ = 3θ + 3. This yields the quadratic equation 4θ θ 3 = 0 with solutions θ = ± 9 8 have θ = + 9. 8. Since θ > 3 > 0 we must Theorem.6.. The continued fraction of real number θ is periodic if and only if θ is quadratic irrational, i.e. θ = a + b d where a and b are rational numbers and d is a positive non-square integer. Proof. Suppose θ = a 0, a,..., a N, a N, a N+,..., a N+r and let α = a N, a N+,..., a N+r = a N, a N+,..., a N+r, α. If the convergents to α are h n k n then by equation (.3.), we have α = αh r + h r αk r + k r. This implies α k r + α(k r + h r ) h r = 0. By the quadratic formula, α may be written a + b d with a, b and d a postive non-square integer as stated in the theorem. (Note that the discriminant d must be non-square because α is not rational, since α has an infinite continued fraction represntation.) Now, the set {a + b d : a, b } is a field, denoted ( d). We will study these fields in greater detail in the next section, but for now it is easy to check that indeed this set is closed under addition, subtraction, multiplication, and division. Therefore, the fact that α ( d) implies that θ ( d) as well, since θ can be obtained from α using these field operations. Finally, we note that as with α, we have θ since it has an infinite continued fraction. : Write θ = r+ s. We will first show that θ can be written in the form θ = m 0+ d t q 0 where q 0 divides m d. If t > 0 then we multiply by t and obtain 0 t θ = r t + t s = r t + t s = m 0 + d t t q 0 3

where q 0 = t, m 0 = r t, and d = t s, so q 0 (m t d) as desired. If t < 0 then multiply by 0 t and obtain θ = r t t s = r t + t s = m 0 + d t t where q 0 = t, m 0 = r t, and d = t s. Then q 0 (m d) is again satisfied. 0 We now define sequences of real numbers m i, q i, a i, and θ i recursively as follows. Let θ i = m i + d q i, a i = [θ i ], m i+ = a i q i m i, and q i+ = d m i+ q i. Claim: m i, q i, q i 0, and q i (m i d). We prove the claim by induction on i. When i = 0 the results hold by construction. For the inductive step there are four things we need to prove. First, it is clear from the formula that m i+ is an integer, since a i, m i and q i are. Next we show q i+ 0: if q i+ = 0, then d = m ; this is a contradiction since d is not a square. i+ Next, we note that q 0 q i+ = d m i+ q i = d (a i q i a i q i m i + m i ) q i = d m i q i }{{} + ( a i q i + a i m i ). }{{} Therefore, q i+. Lastly we have m i+ d = q q i which is an integer, so q i+ divides m d. i+ i+ This completes the inductive proof of our claim. Claim: These θ i s and a i s are the same as those given by the continued fraction of θ, i.e. we have θ = a 0, a,... and θ i = a i, a i+,... for all i. Recall that the latter θ i s and a i s are defined recursively by a i = [θ i ] and θ i+ = θ i a i. So we need to show the θ i s from previous claim satisfy these formulae. Now a i = [θ i ] by definition, so we only need to show 33

that θ i+ = θ i a i. We compute θ i+ = m i+ + d q i+ = m i+ + d (d m i+ )/q i q i (m i+ + d) = ( d + m i+ )( d m i+ ) q i =, d mi+ so d mi+ = θ i+ q i d aqi + m i = q i = m i + d q i a i = θ i a i as desired. Hence θ i and a i are indeed those given by the continued fraction of θ. Claim: q n > 0 for n large enough. For an element x = a + b d, we define the conjugate by x := a b d. Then we have θ n θ n = m i+ d mi d = d. So θ q n q n q n θ n > 0 if and only n if q n > 0. We ll show θ n < 0 for n large enough. This will imply the claim, since θ n > 0, so we will have θ n θ n > 0. Now from (.4.) we have that θ = θ nh n + h n θ n k n + k n, which implies θ n = θ k n h n θ k n + h n. Conjugating this last equation, we have θ n = θ k n h n = k n θ k n + h n k n θ h n k n θ h n k n }{{} Now as n, we have h n /k n θ and h n /k n θ, hence θ θ =. Therefore, θ θ for n sufficiently large, we see that θ n < 0, so θ n θ n > 0 and q n > 0 as claimed. We can finally complete the proof of the theorem. Recall that q n+ = d m n+, so q q n q n+ = n d m. This implies that 0 < q n+ n d and d < m n < d since m < d. Therefore, there n. 34

are only finitely many possibilities for m n and q n ; eventually we have a repetition of a pair (m n, q n ), yielding a repetition of θ n. Therefore the continued fraction of θ eventually repeats, which is what we wanted to show. Theorem.6.3. Let θ be a quadratic irrational. periodic if and only if θ > and < θ < 0. The continued fraction of θ is purely Proof. : We are given θ > and < θ < 0, and we want to prove that the continued fraction of θ is purely periodic. continued fraction is periodic since θ is quadratic irrational. Here is the idea of the proof: we already know that the To prove that the continued fraction is purely periodic, we want to show that we can always move the start of the repeating part of the continued fraction back one step. To do this, we will show that θ i+ determines a i for each i. Let us now carry this out rigorously. Claim: < θ i < 0 for all i 0. Proof by induction. The base case i = 0 is given, since θ 0 = θ. For the inductive step, note that θ i+ = θ i a i, so θ i = θ i a i. By induction, < θ i < 0. We also know that a i for all i 0; this is always true for i for any continued fraction, and it is true for i = 0 since θ >, so a 0 = θ. So θ i a i < a i and hence < < 0. This completes the inductive proof of our claim. θ i a i Now θ i+ = implies θ θ i a i = + a i θ i, thus θ i = + a i+ θ i. We know that < θ i < 0, so i+ plugging in the previous equality for θ i, we find: < θ i+ + a i < 0, a i < < a i, θ i+ (subtract a i ) a i < < a i +. θ i+ (multiply by ) This implies that a i = θ i+. This tells us that θ i+ determines a i, as claimed above. Since the continued fraction of θ repeats at some point, we know that there exists r > and N 0 such that θ n = θ n+r for all n N. Suppose that N is minimal. We want to show that N = 0. If N > 0, then the equations θ N = θ N+r, a N = imply that a N = a N+r. Therefore θ N, and a N+r = θ N+r θ N = a N + θ N = a N+r + θ N+r = θ N+r, 35

contradicting the minimality of N. Therefore N = 0 and the continued fraction of θ is purely periodic. : We want to show that if θ has purely periodic continued fraction then θ > and < θ < 0. Since a 0 = a r where r > is the period of the continued fraction, and a r, we must have a 0. Since a 0 = θ, we have θ > as desired. Next note that θ = a 0, a,..., a r, θ = θh r + h r θ k r + k r, so θ k r +θ(k r h r ) h r = 0. Taking the conjugate, we see that θ is a root of the same quadratic polynomial, i.e. θ and θ are the two roots of the polynomial f (x) = k r x + (k r h r )x h r. (Note that θ θ since θ is not rational.) Therefore it suffices to show that f (x) has some root between and 0. Note that f (0) = h r < 0 and f ( ) = k r k r +h r h r > 0, since the h i s and k i s are increasing. Therefore, f has a root between 0 and by the Intermediate value theorem..7 Example of a purely periodic continued fraction Let d bs a non-square integer greater than, and let θ = d + [ d]. Then θ is a quadratic irrationality satisfying θ >. Furthermore we have θ = [ d] d and we calculate: d < d < d + 0 < d d < < [ d] < θ < 0. (subtract d ) d < 0 (multiply by ) Therefore by Theorem.6.3, θ has purely periodic continued fraction, say θ = a 0, a,..., a r. We have: a 0 = d + d = d, θ = =, θ a 0 d d a = θ 36