Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES

Similar documents
SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Advanced Counting Techniques. Chapter 8

Advanced Counting Techniques

Learning Objectives

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

6.042/18.062J Mathematics for Computer Science March 17, 2005 Srini Devadas and Eric Lehman. Recurrences

AROUND (1 + 2) n. (1 + x) 5 = 1 + 5x + 10x x 3 + 5x 4 + x 5.

Chapter 8: Recursion. March 10, 2008

5. Sequences & Recursion

SOLVING LINEAR RECURRENCE RELATIONS

Handout 7: Recurrences (Cont d)

1 Examples of Weak Induction

Ex. Here's another one. We want to prove that the sum of the cubes of the first n natural numbers is. n = n 2 (n+1) 2 /4.

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

1 Recursive Algorithms

Why do we need math in a data structures course?

Recursion: Introduction and Correctness

Cpt S 223. School of EECS, WSU

Jong C. Park Computer Science Division, KAIST

Divide and Conquer. Recurrence Relations

Recurrence Relations

Linear Recurrence Relations

Notes on Continued Fractions for Math 4400

Logic and Discrete Mathematics. Section 6.7 Recurrence Relations and Their Solution

Binomial Coefficient Identities/Complements

CS 2210 Discrete Structures Advanced Counting. Fall 2017 Sukumar Ghosh

Recursion and Induction

Advanced Counting Techniques. 7.1 Recurrence Relations

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu

Recurrences COMP 215

The Principle of Linearity applications in the areas of algebra and analysis

CSI2101-W08- Recurrence Relations

Practical Session #3 - Recursions

15 DIFFERENCE EQUATIONS 2

CSC2100B Data Structures Analysis

Recursion and Induction

Discrete Mathematics. Kishore Kothapalli

CDM. Recurrences and Fibonacci

Legendre s Equation. PHYS Southern Illinois University. October 18, 2016

Lecture 12 : Recurrences DRAFT

A SUMMARY OF RECURSION SOLVING TECHNIQUES

CDM. Recurrences and Fibonacci. 20-fibonacci 2017/12/15 23:16. Terminology 4. Recurrence Equations 3. Solution and Asymptotics 6.

CS 5321: Advanced Algorithms - Recurrence. Acknowledgement. Outline. Ali Ebnenasir Department of Computer Science Michigan Technological University

CS 5321: Advanced Algorithms Analysis Using Recurrence. Acknowledgement. Outline

Recurrent Problems. ITT9131 Konkreetne Matemaatika. Chapter One The Tower of Hanoi Lines in the Plane The Josephus Problem

Discrete Mathematics -- Chapter 10: Recurrence Relations

Math.3336: Discrete Mathematics. Advanced Counting Techniques

Introduction to Algorithms 6.046J/18.401J/SMA5503

Solving Recurrence Relations 1. Guess and Math Induction Example: Find the solution for a n = 2a n 1 + 1, a 0 = 0 We can try finding each a n : a 0 =

Reductions, Recursion and Divide and Conquer

CHAPTER 8 Advanced Counting Techniques

1 Sequences and Summation

CS Analysis of Recursive Algorithms and Brute Force

CHAPTER 4 SOME METHODS OF PROOF

4 Linear Recurrence Relations & the Fibonacci Sequence

MI 4 Mathematical Induction Name. Mathematical Induction

Recursion and Induction

Quiz 3 Reminder and Midterm Results

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University

Algorithms CMSC The Method of Reverse Inequalities: Evaluation of Recurrent Inequalities

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

A matrix over a field F is a rectangular array of elements from F. The symbol

ELEMENTARY LINEAR ALGEBRA

Math 2142 Homework 5 Part 1 Solutions

Introduction to Techniques for Counting

Discrete Structures Lecture Sequences and Summations

On Linear Recursive Sequences with Coefficients in Arithmetic-Geometric Progressions

A System of Difference Equations with Solutions Associated to Fibonacci Numbers

3 Finite continued fractions

Factoring Polynomials. Review and extend factoring skills. LEARN ABOUT the Math. Mai claims that, for any natural number n, the function

Recurrence Relations

COMP 555 Bioalgorithms. Fall Lecture 3: Algorithms and Complexity

Mathematical Structures Combinations and Permutations

Section 11.1 Sequences

Recurrence Relations

CS483 Design and Analysis of Algorithms

n F(n) 2n F(2n) Here are some values of the series in comparison to Fibonacci number:

CS361 Homework #3 Solutions

The Trees of Hanoi. Joost Engelfriet

Discrete Mathematics

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

Appendix G: Mathematical Induction

CS Non-recursive and Recursive Algorithm Analysis

Generalizations of Fibonacci and Lucas sequences

ASSIGNMENT 12 PROBLEM 4

Divide and Conquer. Maximum/minimum. Median finding. CS125 Lecture 4 Fall 2016

Notes for Recitation 14

Section Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence

Introduction to Lucas Sequences

Some Review Problems for Exam 2: Solutions

CS 4104 Data and Algorithm Analysis. Recurrence Relations. Modeling Recursive Function Cost. Solving Recurrences. Clifford A. Shaffer.

Intermediate Math Circles March 11, 2009 Sequences and Series

MEETING 9 - INDUCTION AND RECURSION

Applications. More Counting Problems. Complexity of Algorithms

arxiv:math/ v1 [math.co] 8 Oct 2003

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence.

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence.

Computational Complexity. This lecture. Notes. Lecture 02 - Basic Complexity Analysis. Tom Kelsey & Susmit Sarkar. Notes

Transcription:

CS131 Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES A recurrence is a rule which defines each term of a sequence using the preceding terms. The Fibonacci Sequence. The Fibonacci sequence F n ) is defined by the following recurrence: together with the initial conditions: F n = F n 1 + F n n ) F 0 = 0, F 1 = 1. Since the first two terms are known, we can use the recurrence to compute later terms of the sequence, giving 0, 1, 1,, 3,, 8, 13, 1, 34,,.... The Towers of Hanoi. This puzzle was invented by the French mathematician Edouard Lucas in 1883. It consists of eight disks, initially stacked in decreasing size on one of three pegs. The objective is to move the tower to one of the other pegs by moving one disk at a time and never moving a larger one onto a smaller. This leads to the recurrence T n = T n 1 + 1. With T 0 = 0 this gives the sequence 0, 1, 3, 7, 1, 31, 63,.... It is easy to guess that T n = n 1 for each n 0 and this formula can then be proved by induction. This is known as a closed form for T n and allows us to compute terms of the sequence immediately in terms of n. Linear recurrences. In this note we look at methods for solving linear recurrences with constant coefficients. These have the form x n + a 1 x n 1 + + a k x n k = fn) where a 1,..., a k are constants and f is some given function. If the values of the first k terms are given, then this recurrence defines a unique sequence x n ). We begin by looking at homogeneous recurrences, which are those with fn) = 0 for all n, and we will also assume k = the generalisation to higher order recurrences is fairly straightforward). 16 1

We wish to find the general solution of the recurrence x n + ax n 1 + bx n = 0. When b = 0 it is easy to see that the solution is given by x n = a) n x 0. This suggests that in the general case we should look for solutions of the form x n = λ n A, where λ and A are constants. Now x n = λ n is a solution of x n + ax n 1 + bx n = 0 λ n + aλ n 1 + bλ n = 0 λ n λ + aλ + b) = 0 λ = 0 or λ + aλ + b = 0. Auxiliary equation. The equation λ + aλ + b = 0 is called the auxiliary equation of the recurrence x n + ax n 1 + bx n = 0. If the auxiliary equation has two distinct solutions λ 1 and λ, then it is easy to verify that x n = Aλ n 1 + Bλ n is a solution of the recurrence for any constants A and B. If the first two terms of the sequence x n ) are given, then they can be used to find the values of A and B. If the auxiliary equation has only a single solution for λ then a 4b = 0, so b = a /4 and λ = a/. In this case x n = Aλ n is a solution of the recurrence for any A, but is not the general solution. However x n = nλ n is also a solution since this gives, on substitution, x n + ax n 1 + bx n = nλ n + an 1)λ n 1 + bn )λ n = nλ n λ + aλ + b) λ n aλ + b) = nλ n 0 λ n 0 = 0. The second term is 0 since aλ = a / and b = a /.) Hence the general solution is x n = Aλ n + Bnλ n where A and B are constants. Solution of the recurrence x n + ax n 1 + bx n = 0. Let λ 1, λ be the roots of the auxiliary polynomial λ + aλ + b, then if λ 1 λ, x n = Aλ n 1 + Bλ n, if λ 1 = λ, x n = Aλ n 1 + Bnλ n. If the first two terms of the sequence x n ) are known, then they can be used to find the constants A and B. Problem. Find a closed form for the terms of the Fibonacci sequence. 16

Solution. Here we have F n F n 1 F n = 0, so the auxiliary equation is λ λ 1 = 0, which has roots Hence we have λ 1 = 1 + F n = A and λ = 1. 1 + ) n 1 ) n + B. Finding A and B is easy since we have F 0 = 0 and F 1 = 1. Thence F n = 1 1 + ) n 1 1 ) n. The number 1 + )/ or 1.61803... is called the golden ratio and is often denoted by φ. Note that F n is an integer expression, despite appearances. Since 1 )/ < 1, the second term in the above closed form for F n becomes smaller as n increases. In fact we have 1 1 ) n < 1 for all n, which gives the formula: ) φ n F n = rounded to the nearest integer. We now look at the case of a non- Non-homogeneous recurrences. homogeneous recurrence of the form x n + ax n 1 + bx n = fn) where a and b are constants. Suppose that x n = h n is the general solution of the corresponding homogeneous recurrence so that h n + ah n 1 + bh n = 0, and that x n = p n is any particular solution of the original recurrence so that p n + ap n 1 + bp n = fn). 16 3

Then x n = h n +p n is a solution of the recurrence since, on adding the above, h n + p n ) + ah n 1 + p n 1 ) + bh n + p n ) = h n + ah n 1 + bh n ) + p n + ap n 1 + bp n ) = 0 + fn) = fn). It follows that x n = h n +p n is the general solution of the original recurrence. Solution of the recurrence x n + ax n 1 + bx n = fn). 1) Find the general solution x n = h n of the homogeneous recurrence: x n + ax n 1 + bx n = 0 solution will contain two arbitrary constants). ) Find any particular solution x n = p n of the original recurrence: x n + ax n 1 + bx n = fn). 3) The general solution of the original recurrence is then given by x n = h n + p n. In general finding a particular solution of the recurrence will not be easy! x n + ax n 1 + bx n = fn) Some useful techniques are: If f is constant, say fn) = k for all n, then it is easy to find a constant particular solution provided 1 + a + b 0). For if x n = c for all n, then substituting into the recurrence x n +ax n 1 +bx n = k gives c + ac + bc = k or c = k/1 + a + b). For a more complicated polynomial) fn), try to find a particular solution which is also a polynomial in n, e.g., try x n = k or x n = k 1 n + k or x n = k 1 n + k n + k 3,.... Example. Find the general solution of the recurrence x n 10.1x n 1 + x n =.7n. Solution. The homogeneous recurrence x n 10.1x n 1 + x n = 0 has auxiliary equation λ 10.1λ + 1 = 0 or λ 10)λ 1/10) = 0, 16 4

and so has general solution x n = A10 n ) + B/10 n. To find a particular solution of we try x n = Cn + D. This gives x n 10.1x n 1 + x n =.7n, Cn+D 10.1Cn 1)+D)+Cn )+D = 8.1Cn+8.1D 8.1C =.7n. Since this holds for all n, we have 8.1C =.7, 8.1D 8.1C = 0 so C = D = 1/3. Hence the general solution of the recurrence is x n = 10 n A + B 10 n + n + 1 3. ABSTRACT Content definition, well-known examples, solution of linear recurrences homogeneous and non-homogeneous) In this Note we study the solution of linear recurrences. Those students familiar with the solution of linear ordinary differential equations will recognise much that is in this Note. Because recurrence relationships are closely related to recursive algorithms, recurrences arise naturally in the analysis of the latter. History The most useful recurrences are non-linear and are generally beyond the scope of this module. These are to be found mostly in the area of mathematical physics. 16