Lecture 2: Continued fractions, rational approximations

Similar documents
Mathematics 228(Q1), Assignment 2 Solutions

Notes on Continued Fractions for Math 4400

MATH10040: Numbers and Functions Homework 1: Solutions

CONTINUED FRACTIONS, PELL S EQUATION, AND TRANSCENDENTAL NUMBERS

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.

Math 109 HW 9 Solutions

Fall 2017 Test II review problems

1 Continued Fractions

Pigeonhole Principle and Ramsey Theory

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

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

means is a subset of. So we say A B for sets A and B if x A we have x B holds. BY CONTRAST, a S means that a is a member of S.

The following techniques for methods of proofs are discussed in our text: - Vacuous proof - Trivial proof

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

Lecture 6: Deterministic Primality Testing

IS 709/809: Computational Methods for IS Research. Math Review: Algorithm Analysis

HMMT February 2018 February 10, 2018

Solutions to Assignment 1

Solution Set 2. Problem 1. [a] + [b] = [a + b] = [b + a] = [b] + [a] ([a] + [b]) + [c] = [a + b] + [c] = [a + b + c] = [a] + [b + c] = [a] + ([b + c])

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.

Lecture 3.2: Induction, and Strong Induction

THE DIVISION THEOREM IN Z AND R[T ]

P-adic numbers. Rich Schwartz. October 24, 2014

8 Primes and Modular Arithmetic

6.1 Polynomial Functions

Math 110 HW 3 solutions

We have been going places in the car of calculus for years, but this analysis course is about how the car actually works.

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

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

Lecture 11 - Basic Number Theory.

DR.RUPNATHJI( DR.RUPAK NATH )

Sums of Squares. Bianca Homberg and Minna Liu

Inference and Proofs (1.6 & 1.7)

We are going to discuss what it means for a sequence to converge in three stages: First, we define what it means for a sequence to converge to zero

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

Math1a Set 1 Solutions

3 Finite continued fractions

PRACTICE PROBLEMS: SET 1

Seunghee Ye Ma 8: Week 2 Oct 6

MATH 55 - HOMEWORK 6 SOLUTIONS. 1. Section = 1 = (n + 1) 3 = 2. + (n + 1) 3. + (n + 1) 3 = n2 (n + 1) 2.

D-MATH Algebra I HS18 Prof. Rahul Pandharipande. Solution 1. Arithmetic, Zorn s Lemma.

Section Properties of Rational Expressions

Math 120 HW 9 Solutions

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

NORTHWESTERN UNIVERSITY Thrusday, Oct 6th, 2011 ANSWERS FALL 2011 NU PUTNAM SELECTION TEST

be any ring homomorphism and let s S be any element of S. Then there is a unique ring homomorphism

Beautiful Mathematics

PRIME NUMBERS YANKI LEKILI

CHAPTER 1 REAL NUMBERS KEY POINTS

Class IX Chapter 1 Number Sustems Maths

Math /Foundations of Algebra/Fall 2017 Foundations of the Foundations: Proofs

Contest Number Theory

Putnam Greedy Algorithms Cody Johnson. Greedy Algorithms. May 30, 2016 Cody Johnson.

Rational Functions. A rational function is a function that is a ratio of 2 polynomials (in reduced form), e.g.

Finite Fields: An introduction through exercises Jonathan Buss Spring 2014

Table of Contents. 2013, Pearson Education, Inc.

CHAPTER 3. Number Theory

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

Corollary 4.2 (Pepin s Test, 1877). Let F k = 2 2k + 1, the kth Fermat number, where k 1. Then F k is prime iff 3 F k 1

MATH3283W LECTURE NOTES: WEEK 6 = 5 13, = 2 5, 1 13

Lecture Overview. 2 Weak Induction

Proof Techniques (Review of Math 271)

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.

FACTORIZATION OF IDEALS

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1

MATH 2400 LECTURE NOTES: POLYNOMIAL AND RATIONAL FUNCTIONS. Contents 1. Polynomial Functions 1 2. Rational Functions 6

Quantitative Aptitude

Mathematical Induction

1. multiplication is commutative and associative;

Divisibility in the Fibonacci Numbers. Stefan Erickson Colorado College January 27, 2006

CSC 344 Algorithms and Complexity. Proof by Mathematical Induction

Instructor: Bobby Kleinberg Lecture Notes, 25 April The Miller-Rabin Randomized Primality Test

Number Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some. Notation: b Fact: for all, b, c Z:

Sect Introduction to Rational Expressions

( 3) ( ) ( ) ( ) ( ) ( )

Chapter 11 - Sequences and Series

Mathematical Induction. Part Two

Proof worksheet solutions

Introduction to Basic Proof Techniques Mathew A. Johnson

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

1 Basic Combinatorics

Fermat's Little Theorem

Rational Functions. Elementary Functions. Algebra with mixed fractions. Algebra with mixed fractions

Solutions for Homework Assignment 2

Infinite Continued Fractions

Lecture 11: Cantor-Zassenhaus Algorithm

Solutions to Practice Final

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II


MATH 2112/CSCI 2112, Discrete Structures I Winter 2007 Toby Kenney Homework Sheet 5 Hints & Model Solutions

Cool Results on Primes

Complete Induction and the Well- Ordering Principle

Rational Approximation by Continued Fractions

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

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

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

Ramsey Theory. May 24, 2015

The standard form for a general polynomial of degree n is written. Examples of a polynomial in standard form

The Real Number System

Transcription:

Lecture 2: Continued fractions, rational approximations Algorithmic Number Theory (Fall 204) Rutgers University Swastik Kopparty Scribe: Cole Franks Continued Fractions We begin by calculating the continued fraction representation of a real number Let α be a real number Then α = α + α, α = α + α 2, α n = α n + α n where α i is greater than one for i {,, n} Let a 0 := α, and a i := α i At some point α N may be an integer, in which case this process terminates and α is rational In that case, we simply define a n = 0 for all n > N, and α n is undefined for n > N Note that a n for all n N If α is irrational, the process will never terminate, so we don t have to worry about the two previous lines Note that a i, α i 0 for all i By plugging each equation into the one above, we see that α = a 0 + a + a n + α n The n th convergent of α, provided n N (if N exists), is given by c n = a 0 + a + a n + a n

If n N, then the n th convergent of α is simply c n = a 0 + a + a N + a N = c N The list [a 0, ] is the continued fraction representation of α Lemma The convergents are given by c n = pn where [ ] [ ] [ pn+ p n pn p = n an+ 0 or + p n+ = p n a n+ + p n + = a n+ + ] with p 0 = a 0, q 0 =, p = a 0 a +, q = a Note that for all i 0, q i > 0 In particular, q i is strictly monotonically increasing until a i+ = 0, or when i = N Proof First we claim that for any n and a formal variable Z we have p n Z + p n Z + = a 0 + a + a n + Z, () which we prove by induction The base case n = is an exercise Let n From the inductive hypothesis with Z a n+ + Z, a 0 + a + a n+ + Z, = p ( n an+ + ) Z + pn ( an+ + Z ) + qn = p n (a n+ Z + ) + p n Z (a n+ Z + ) + Z = p na n+ Z + p n + p n Z a n+ Z + + Z = p n+z + p n + Z + If we substitute Z = a n+ in (??), we get that c n+ = p n+ /+ as desired 2

Observation 2 Equation (??) is valid even if n > N, for the proof did not use n N Note that so p p det 0 q q 0 an+ = det 0 =, pn p det n = ( ) n This implies that p n, are relatively prime (because the ideal they generate in Z contains ), and so the convergent pn is already in lowest terms 2 Approximation Now we move to the approximation of real numbers by rational numbers Our aim is to use the lowest denominator rational number possible and still get a nice approximation How good a rational approximation can one get to a given real number α? One trivial rational approximation to α is a number a q with α a q 2q, (for any q we can simply choose a Z at a distance at most /2 from qα) The following theorem shows that every α has a pretty good rational approximation: Theorem 3 (Dirichlet s Theorem) For every α R, either α is rational, or else there are infinitely many distinct rational numbers a q such that α a q < Observation 4 We prove Theorem?? by proving the following stronger theorem: Theorem 5 For all Q N, there is a rational number a q α a q < qq Lemma 6 Theorem?? implies Theorem?? such that q Q and Proof of Lemma?? Take some Q N; by Theorem?? we can find a q α a q < q Q q 2 3 with

If a q = α, then α is rational, and so we are done with Theorem?? in this case If not, ie α a q > 0, then we can take a new Q2 so large that α a q > Q 2 Let a 2 be the pair guaranteed by Theorem?? for Q 2 Then α a 2 < α a q < Q 2 α a, so a 2 is distinct from a q Furthermore, α a 2 < Q 2 q2 2 q Continuing this process, we either find that α is rational, or else we find infinitely many a q required in Theorem?? as This proof, due to Dirichlet, was possibly the first appearance of the Dirichlet Pigeon Hole Principle Proof of Theorem?? If we show that there is some q with qα closer than Q to some integer, then we can use that integer as our a and be done Consider {0 mod, α mod, Qα mod } This is [ an Q ) + element set lying in the interval [0, ) There must be two in one of the Q intervals i Q, i Q, i {,, Q} Hence there exist r, s such that 0 sα mod rα mod = (s r)α mod < Q, viewed as an element of [0, ) Then there is an integer, namely that integer directly below (s r)α, such that (s r)α a < Q Our q is s r Let us now give an algorithm to construct these good approximations Concretely, the problem we want to solve is this: Problem Given a rational number α = r s and an integer Q, find a q possible subject to q Q with α a q as small as The input size for this problem is O(log r + log s + log Q) bits, and we will be interested in getting an algorithm which runs in time polynomial in this Our algorithm will be based on continued fractions (and we will use the notation we used in that section) It is not true that the solution to our rational approximation problem will be a convergent, but convergents will help us compute the solution easily We begin with a lemma on the sign of c n α Lemma 7 If n is even, c n α, else c n α Proof If n > N, this is trivial because c n = α, so we assume that n N We proceed by induction on n (showing the result for all α at the same time) 4

The lemma is clearly true for n = 0 (since c 0 = a 0 = α ) Now let n N, and assume the lemma holds for n for every α Then c n+ = a 0 + a + a n + a n+ = a 0 + c, n where c n is the n th convergent of α, the number such that α = a 0 + α c n is either at least (if n is odd) or at most α (if n is even) by our inductive assumption By similar reasoning to that showing α n > 0 for n > 0, c n > 0 Then a 0 + c is either at least α (if n + is even) or at most α n (if n + is odd) Now we characterize the best rational approximation with denominator Q Theorem 8 Let n be largest number such that Q, and let t be the greatest integer such that t + Q Then either pn is a solution to the rational approximation problem or tpn+p n t+ Proof Let L = tpn+p n t+ We will assume n is even The proof when n is odd will be very similar Because n is even, pn α and p n+ + α Note that if s = a n+, then spn+p n s+ = p n+ + ; if s = 0, then spn+p n s+ p n+ + This is because = p n As s ranges from 0 to a n+, spn+p n s+ d ds ( ) spn + p n = s + pn p det n ranges monotonically from p n (s + ) 2 ; does not change sign Hence, L must be between p n+ + and p n, both of which are at least α Hence L is at least α If r s is strictly closer to α than both c n and L, then r s I = (c n, L) For contradiction, suppose 0 < s Q Then r s p n, s because r s pn, and similarly Observe that I = I = pn tpn+p n r s L s(t + ) t+ = (t+ ) Then (t + ) s(t + ) + = ( + ) s s t + So s (t + ) + > Q, a contradiction = s ( ) tqn + + (t + ) Observation 9 We saw in the proof that if n is even, α (c n, L), and if n is odd, α (L, c n ) Further, the interval has length exactly (t+ ) Then c n α (t+ ) 5 to

As we noted before, increases monotonically until n = N As a b is the best approximation with denominator at most Q for any Q b, we cannot have > b for any n If so, then + > b as well By Theorem??, either L or p n+ + would at least as good an approximation as a b with denominator at most + For any t > 0, t+ + > +, so t = 0 Then L = pn This is impossible, because p n qn and p n+ + are reduced and therefore neither are equal to a b This also applies that N exists for α if and only if α is rational, ie the continued fraction representation of α terminates iff α is rational 3 Running Time It will be of use to bound p n and We already know that b From Remark??, we know that a p n b Hence p n qn b a + = O(a) We know that the n from Theorem?? is O(log(Q)) because the grow at least as fast as the n th entry of the Fibonacci sequence provided n N At each step in the computation of the continued fraction, we compute the floor of a rational number α i = r i s i, which is simply the number of times the denominator of α i goes into the numerator This is division with remainder, which we know to take O(log(r i ) log(s i )) operations We know α i = α i α i, which has denominator the remainder of r i under division by s i (which is strictly smaller than s i ) and numerator s i As α 0 = α = a b, we can conclude by induction that r i, s i max(a, b) and so the number of operations per step is certainly at most O((log(a) + log(b)) 2 ) Finding t can take at most O(log(Q) 2 ) steps, as we find it by division with remainder of Q by t is at most a n+, which is at most + b p n, p n = O(a) Taken together, finding L must take O(poly(log(a), log(b), log(q))) Finding whether L or c n is closer to α can also certainly take at most O(poly(log(a), log(b), log(q))), and finding the continued fraction is also O(poly(log(a), log(b), log(q))) Hence the entire running time must be O(poly(log(a), log(b), log(q))) 6