Solving Linear Recurrence Relations. Niloufar Shafiei

Similar documents
Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1

Discrete Mathematics: Homework 7 solution. Due:

Systems of Linear Equations

Assignment 5 - Due Friday March 6

SEQUENCES ARITHMETIC SEQUENCES. Examples

Linear Equations in Linear Algebra

160 CHAPTER 4. VECTOR SPACES

Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally

Math 55: Discrete Mathematics

MATH 304 Linear Algebra Lecture 18: Rank and nullity of a matrix.

Math 55: Discrete Mathematics

Core Maths C1. Revision Notes

On closed-form solutions to a class of ordinary differential equations

Lecture 4: Partitioned Matrices and Determinants

TAKE-AWAY GAMES. ALLEN J. SCHWENK California Institute of Technology, Pasadena, California INTRODUCTION

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

the recursion-tree method

10.2 ITERATIVE METHODS FOR SOLVING LINEAR SYSTEMS. The Jacobi Method

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.

Collatz Sequence. Fibbonacci Sequence. n is even; Recurrence Relation: a n+1 = a n + a n 1.

ON THE EMBEDDING OF BIRKHOFF-WITT RINGS IN QUOTIENT FIELDS

Methods for Finding Bases

Mathematics for Algorithm and System Analysis

SOME PROPERTIES OF SYMBOL ALGEBRAS OF DEGREE THREE

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity.

CS473 - Algorithms I

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Metric Spaces. Chapter Metrics

Appendix: Solving Recurrences [Fa 10] Wil Wheaton: Embrace the dark side! Sheldon: That s not even from your franchise!

Nonhomogeneous Linear Equations

Benford s Law: Tables of Logarithms, Tax Cheats, and The Leading Digit Phenomenon

1. First-order Ordinary Differential Equations

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set.

6.042/18.062J Mathematics for Computer Science December 12, 2006 Tom Leighton and Ronitt Rubinfeld. Random Walks

Math 115 Spring 2011 Written Homework 5 Solutions

Notes on Determinant

SECTION 10-5 Multiplication Principle, Permutations, and Combinations

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

Lecture 5 Principal Minors and the Hessian

Solving Systems of Linear Equations Using Matrices

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

Continued Fractions and the Euclidean Algorithm

Gröbner Bases and their Applications

Taylor and Maclaurin Series

Randomized algorithms

4/1/2017. PS. Sequences and Series FROM 9.2 AND 9.3 IN THE BOOK AS WELL AS FROM OTHER SOURCES. TODAY IS NATIONAL MANATEE APPRECIATION DAY

Mathematical Induction. Lecture 10-11

On continued fractions of the square root of prime numbers

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

4.5 Linear Dependence and Linear Independence

( ) which must be a vector

9.2 Summation Notation

Inner Product Spaces

Subspaces of R n LECTURE Subspaces

Phantom bonuses. November 22, 2004

Answer: (a) Since we cannot repeat men on the committee, and the order we select them in does not matter, ( )

Linear Algebra I. Ronald van Luijk, 2012

The Chinese Remainder Theorem

Quotient Rings and Field Extensions

Handout NUMBER THEORY

SECTION 10-2 Mathematical Induction

Introduction to Time Series Analysis. Lecture 6.

Zero: If P is a polynomial and if c is a number such that P (c) = 0 then c is a zero of P.

3.2 Roulette and Markov Chains

So far, we have looked at homogeneous equations

Creating, Solving, and Graphing Systems of Linear Equations and Linear Inequalities

Lecture 14: Section 3.3

These axioms must hold for all vectors ū, v, and w in V and all scalars c and d.

MATH2210 Notebook 1 Fall Semester 2016/ MATH2210 Notebook Solving Systems of Linear Equations... 3

Reduced echelon form: Add the following conditions to conditions 1, 2, and 3 above:

1.2. Successive Differences

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

Second Order Linear Nonhomogeneous Differential Equations; Method of Undetermined Coefficients. y + p(t) y + q(t) y = g(t), g(t) 0.

Extrinsic geometric flows

THE DIMENSION OF A VECTOR SPACE

This unit will lay the groundwork for later units where the students will extend this knowledge to quadratic and exponential functions.

God created the integers and the rest is the work of man. (Leopold Kronecker, in an after-dinner speech at a conference, Berlin, 1886)

Stanford Math Circle: Sunday, May 9, 2010 Square-Triangular Numbers, Pell s Equation, and Continued Fractions

Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem)

LS.6 Solution Matrices

COWLEY COLLEGE & Area Vocational Technical School

Inner product. Definition of inner product

Linear Programming I

Triangle deletion. Ernie Croot. February 3, 2010

Circles in Triangles. This problem gives you the chance to: use algebra to explore a geometric situation

1 VECTOR SPACES AND SUBSPACES

SMT 2014 Algebra Test Solutions February 15, 2014

DIFFERENTIABILITY OF COMPLEX FUNCTIONS. Contents

1.2 Solving a System of Linear Equations

Zeros of a Polynomial Function

Second-Order Linear Differential Equations

Probability Generating Functions

Linear Algebra Notes

Linearly Independent Sets and Linearly Dependent Sets

NOTES ON LINEAR TRANSFORMATIONS

Refined enumerations of alternating sign matrices. Ilse Fischer. Universität Wien

MA106 Linear Algebra lecture notes

Matrix-Chain Multiplication

3. Mathematical Induction

Polynomial Invariants

Transcription:

Solving Linear Recurrence Relations Niloufar Shafiei

Review A recursive definition of a sequence specifies Initial conditions Recurrence relation Example: a 0 =0 and a 1 =3 Initial conditions a n = 2a n-1 - a n-2 a n = 3n Recurrence relation Solution 1

Linear recurrences Linear recurrence: Each term of a sequence is a linear function of earlier terms in the sequence. For example: a 0 = 1 a 1 = 6 a 2 = 10 a n = a n-1 + 2a n-2 + 3a n-3 a 3 = a 0 + 2a 1 + 3a 2 = 1 + 2(6) + 3(10) = 43 2

Linear recurrences Linear recurrences 1. Linear homogeneous recurrences 2. Linear non-homogeneous recurrences 3

Linear homogeneous recurrences A linear homogenous recurrence relation of degree k with constant coefficients is a recurrence relation of the form a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k, where c 1, c 2,, c k are real numbers, and c k 0. a n is expressed in terms of the previous k terms of the sequence, so its degree is k. This recurrence includes k initial conditions. a 0 = C 0 a 1 = C 1 a k = C k 4

Example Determine if the following recurrence relations are linear homogeneous recurrence relations with constant coefficients. P n = (1.11)P n-1 a linear homogeneous recurrence relation of degree one a n = a n-1 + a 2 n-2 not linear f n = f n-1 + f n-2 a linear homogeneous recurrence relation of degree two H n = 2H n-1 +1 not homogeneous a n = a n-6 a linear homogeneous recurrence relation of degree six B n = nb n-1 does not have constant coefficient 5

Solving linear homogeneous recurrences Proposition 1: Let a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k be a linear homogeneous recurrence. Assume the sequence a n satisfies the recurrence. Assume the sequence a n also satisfies the recurrence. So, b n = a n + a n and d n = a n are also sequences that satisfy the recurrence. ( is any constant) Proof: b n = a n + a n = (c 1 a n-1 + c 2 a n-2 + + c k a n-k ) + (c 1 a n-1 + c 2 a n-2 + + c k a n-k ) = c 1 (a n-1 + a n-1 ) + c 2 (a n-2 + a n-2 ) + + c k (a n-k + a n-k ) = c 1 b n-1 + c 2 b n-2 + + c k b n-k So, b n is a solution of the recurrence. 6

Solving linear homogeneous recurrences Proposition 1: Let a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k be a linear homogeneous recurrence. Assume the sequence a n satisfies the recurrence. Assume the sequence a n also satisfies the recurrence. So, b n = a n + a n and d n = a n are also sequences that satisfy the recurrence. ( is any constant) Proof: d n = a n = (c 1 a n-1 + c 2 a n-2 + + c k a n-k ) = c 1 ( a n-1 ) + c 2 ( a n-2 ) + + c k ( a n-k ) = c 1 d n-1 + c 2 d n-2 + + c k d n-k So, d n is a solution of the recurrence. 7

Solving linear homogeneous recurrences It follows from the previous proposition, if we find some solutions to a linear homogeneous recurrence, then any linear combination of them will also be a solution to the linear homogeneous recurrence. 8

Solving linear homogeneous recurrences Geometric sequences come up a lot when solving linear homogeneous recurrences. So, try to find any solution of the form a n = r n that satisfies the recurrence relation. 9

Solving linear homogeneous recurrences Recurrence relation a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k Try to find a solution of form r n r n = c 1 r n-1 + c 2 r n-2 + + c k r n-k r n - c 1 r n-1 - c 2 r n-2 - - c k r n-k = 0 r k - c 1 r k-1 - c 2 r k-2 - - c k = 0 (dividing both sides by r n-k ) This equation is called the characteristic equation. 10

Example Example: The Fibonacci recurrence is F n = F n-1 + F n-2 Its characteristic equation is r 2 - r - 1 = 0 11

Solving linear homogeneous recurrences Proposition 2: r is a solution of r k - c 1 r k-1 - c 2 r k-2 - - c k = 0 if and only if r n is a solution of a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k. Example: consider the characteristic equation r 2-4r + 4 = 0. r 2-4r + 4 = (r - 2) 2 = 0 So, r=2. So, 2 n satisfies the recurrence F n = 4F n-1-4f n-2. 2 n = 4. 2 n-1-4. 2 n-2 2 n-2 ( 4-8 + 4) = 0 12

Solving linear homogeneous recurrences Theorem 1: Consider the characteristic equation r k - c 1 r k-1 - c 2 r k-2 - - c k = 0 and the recurrence a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k. Assume r 1, r 2, and r m all satisfy the equation. Let 1, 2,, m be any constants. So, a n = 1 r n 1 + 2 r n 2 + + m r n m satisfies the recurrence. Proof: By Proposition 2, i r i n satisfies the recurrence. So, by Proposition 1, i i r i n satisfies the recurrence. Applying Proposition 1 again, the sequence a n = 1 r 1 n + 2 r 2 n + + m r m n satisfies the recurrence. 13

Example What is the solution of the recurrence relation a n = a n-1 + 2a n-2 with a 0 =2 and a 1 =7? Solution: Since it is linear homogeneous recurrence, first find its characteristic equation r 2 - r - 2 = 0 (r+1)(r-2) = 0 r 1 = 2 and r 2 = -1 So, by theorem a n = 1 2 n + 2 (-1) n is a solution. Now we should find 1 and 2 using initial conditions. a 0 = 1 + 2 = 2 a 1 = 1 2 + 2 (-1) = 7 So, 1 = 3 and 2 = -1. a n = 3. 2 n - (-1) n is a solution. 14

Example What is the solution of the recurrence relation f n = f n-1 + f n-2 with f 0 =0 and f 1 =1? Solution: Since it is linear homogeneous recurrence, first find its characteristic equation r 2 - r - 1 = 0 r 1 = (1+ )/2 and r 2 = (1- )/2 So, by theorem f n = 1 ((1+ )/2) n + 2 ((1- )/2) n is a solution. Now we should find 1 and 2 using initial conditions. f 0 = 1 + 2 = 0 f 1 = 1 (1+ )/2 + 2 (1- )/2 = 1 So, 1 = 1/ and 2 = -1/. a n = 1/. ((1+ )/2) n - 1/ ((1- )/2) n is a solution. 15

Example What is the solution of the recurrence relation a n = -a n-1 + 4a n-2 + 4a n-3 with a 0 =8, a 1 =6 and a 2 =26? Solution: Since it is linear homogeneous recurrence, first find its characteristic equation r 3 + r 2-4r - 4 = 0 (r+1)(r+2)(r-2) = 0 r 1 = -1, r 2 = -2 and r 3 = 2 So, by theorem a n = 1 (-1) n + 2 (-2) n + 3 2 n is a solution. Now we should find 1, 2 and 3 using initial conditions. a 0 = 1 + 2 + 3 = 8 a 1 = - 1-2 2 + 2 3 = 6 a 2 = 1 + 4 2 + 4 3 = 26 So, 1 = 2, 2 = 1 and 3 = 5. a n = 2. (-1) n + (-2) n + 5. 2 n is a solution. 16

Solving linear homogeneous recurrences If the characteristic equation has k distinct solutions r 1, r 2,, r k, it can be written as (r - r 1 )(r - r 2 ) (r - r k ) = 0. If, after factoring, the equation has m+1 factors of (r - r 1 ), for example, r 1 is called a solution of the characteristic equation with multiplicity m+1. When this happens, not only r 1 n is a solution, but also nr 1n, n 2 r 1n, and n m r 1 n are solutions of the recurrence. 17

Solving linear homogeneous recurrences Proposition 3: Assume r 0 is a solution of the characteristic equation with multiplicity at least m+1. So, n m r n 0 is a solution to the recurrence. 18

Solving linear homogeneous recurrences When a characteristic equation has fewer than k distinct solutions: We obtain sequences of the form described in Proposition 3. By Proposition 1, we know any combination of these solutions is also a solution to the recurrence. We can find those that satisfies the initial conditions. 19

Solving linear homogeneous recurrences Theorem 2: Consider the characteristic equation r k - c 1 r k-1 - c 2 r k-2 - - c k = 0 and the recurrence a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k. Assume the characteristic equation has t k distinct solutions. Let i (1 i t) r i with multiplicity m i be a solution of the equation. Let i,j (1 i t and 0 j m i -1) ij be a constant. So, a n = ( 10 + 11 n+ + 1,m1-1 nm 1-1 ) r n 1 + ( 20 + 21 n+ + 2,m2-1 nm 2-1 ) r 2 n + + ( t0 + t1 n+ + t,mt -1 nm t -1 ) r t n satisfies the recurrence. 20

Example What is the solution of the recurrence relation a n = 6a n-1-9a n-2 with a 0 =1 and a 1 =6? Solution: First find its characteristic equation r 2-6r + 9 = 0 (r - 3) 2 = 0 r 1 = 3 (Its multiplicity is 2.) So, by theorem a n = ( 10 + 11 n)(3) n is a solution. Now we should find constants using initial conditions. a 0 = 10 = 1 a 1 = 3 10 + 3 11 = 6 So, 11 = 1 and 10 = 1. a n = 3 n + n3 n is a solution. 21

Example What is the solution of the recurrence relation a n = -3a n-1-3a n-2 - a n-3 with a 0 =1, a 1 =-2 and a 2 =-1? Solution: Find its characteristic equation r 3 + 3r 2 + 3r + 1 = 0 (r + 1) 3 = 0 r 1 = -1 (Its multiplicity is 3.) So, by theorem a n = ( 10 + 11 n + 12 n 2 )(-1) n is a solution. Now we should find constants using initial conditions. a 0 = 10 = 1 a 1 = - 10-11 - 12 = -2 a 2 = 10 + 2 11 + 4 12 = -1 So, 10 = 1, 11 = 3 and 12 = -2. a n = (1 + 3n - 2n 2 ) (-1) n is a solution. 22

Example What is the solution of the recurrence relation a n = 8a n-2-16a n-4, for n 4, with a 0 =1, a 1 =4, a 2 =28 and a 3 =32? Solution: Find its characteristic equation r 4-8r 2 + 16 = 0 (r 2-4) 2 = (r-2) 2 (r+2) 2 = 0 r 1 = 2 r 2 = -2 (Their multiplicities are 2.) So, by theorem a n = ( 10 + 11 n)(2) n + ( 20 + 21 n)(-2) n is a solution. Now we should find constants using initial conditions. a 0 = 10 + 20 = 1 a 1 = 2 10 + 2 11-2 20-2 21 = 4 a 2 = 4 10 + 8 11 + 4 20 + 8 21 = 28 a 3 = 8 10 + 24 11-8 20-24 21 = 32 So, 10 = 1, 11 = 2, 20 = 0 and 21 = 1. a n = (1 + 2n) 2 n + n (-2) n is a solution. 23

Linear non-homogeneous recurrences A linear non-homogenous recurrence relation with constant coefficients is a recurrence relation of the form a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k + f(n), where c 1, c 2,, c k are real numbers, and f(n) is a function depending only on n. The recurrence relation a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k, is called the associated homogeneous recurrence relation. This recurrence includes k initial conditions. a 0 = C 0 a 1 = C 1 a k = C k 24

Example The following recurrence relations are linear nonhomogeneous recurrence relations. a n = a n-1 + 2 n a n = a n-1 + a n-2 + n 2 + n + 1 a n = a n-1 + a n-4 + n! a n = a n-6 + n2 n 25

Linear non-homogeneous recurrences Proposition 4: Let a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k + f(n) be a linear non-homogeneous recurrence. Assume the sequence b n satisfies the recurrence. Another sequence a n satisfies the nonhomogeneous recurrence if and only if h n = a n - b n is also a sequence that satisfies the associated homogeneous recurrence. 26

Linear non-homogeneous recurrences Proof: Part1: if h n satisfies the associated homogeneous recurrence then a n is satisfies the non-homogeneous recurrence. b n = c 1 b n-1 + c 2 b n-2 + + c k b n-k + f(n) h n = c 1 h n-1 + c 2 h n-2 + + c k h n-k b n + h n = c 1 (b n-1 + h n-1 ) + c 2 (b n-2 + h n-2 ) + + c k (b n-k + h n-k ) + f(n) Since a n = b n + h n, a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k + f(n). So, a n is a solution of the non-homogeneous recurrence. 27

Linear non-homogeneous recurrences Proof: Part2: if a n satisfies the non-homogeneous recurrence then h n is satisfies the associated homogeneous recurrence. b n = c 1 b n-1 + c 2 b n-2 + + c k b n-k + f(n) a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k + f(n) a n - b n = c 1 (a n-1 - b n-1 ) + c 2 (a n-2 - b n-2 ) + + c k (a n-k - b n-k ) Since h n = a n - b n, h n = c 1 h n-1 + c 2 h n-2 + + c k h n-k So, h n is a solution of the associated homogeneous recurrence. 28

Linear non-homogeneous recurrences Proposition 4: Let a n = c 1 a n-1 + c 2 a n-2 + + c k a n-k + f(n) be a linear nonhomogeneous recurrence. Assume the sequence b n satisfies the recurrence. Another sequence a n satisfies the non-homogeneous recurrence if and only if h n = a n - b n is also a sequence that satisfies the associated homogeneous recurrence. We already know how to find h n. For many common f(n), a solution b n to the non-homogeneous recurrence is similar to f(n). Then you should find solution a n = b n + h n to the nonhomogeneous recurrence that satisfies both recurrence and initial conditions. 29

Example What is the solution of the recurrence relation a n = a n-1 + a n-2 + 3n + 1 for n 2, with a 0 =2 and a 1 =3? Solution: Since it is linear non-homogeneous recurrence, b n is similar to f(n) Guess: b n = cn + d b n = b n-1 + b n-2 + 3n + 1 cn + d = c(n-1) + d + c(n-2) + d + 3n + 1 cn + d = cn - c + d + cn -2c + d +3n + 1 0 = (3+c)n + (d-3c+1) c = -3 d=-10 So, b n = - 3n - 10. (b n only satisfies the recurrence, it does not satisfy the initial conditions.) 30

Example What is the solution of the recurrence relation a n = a n-1 + a n-2 + 3n + 1 for n 2, with a 0 =2 and a 1 =3? Solution: We are looking for a n that satisfies both recurrence and initial conditions. a n = b n + h n where h n is a solution for the associated homogeneous recurrence: h n = h n-1 + h n-2 By previous example, we know h n = 1 ((1+ )/2) n + 2 ((1- )/2) n. a n = b n + h n = - 3n - 10 + 1 ((1+ )/2) n + 2 ((1- )/2) n Now we should find constants using initial conditions. a 0 = -10 + 1 + 2 = 2 a 1 = -13 + 1 (1+ )/2 + 2 (1- )/2 = 3 1 = 6 + 2 2 = 6-2 So, a n = -3n - 10 + (6 + 2 )((1+ )/2) n + (6-2 )((1- )/2) n. 31

Example What is the solution of the recurrence relation a n = 2a n-1 - a n-2 + 2 n for n 2, with a 0 =1 and a 1 =2? Solution: Since it is linear non-homogeneous recurrence, b n is similar to f(n) Guess: b n = c2 n + d b n = 2b n-1 - b n-2 + 2 n c2 n + d = 2(c2 n-1 + d) - (c2 n-2 + d) + 2 n c2 n + d = c2 n + 2d - c2 n-2 - d + 2 n 0 = (-4c + 4c - c + 4)2 n-2 + (-d + 2d -d) c = 4 d=0 So, b n = 4. 2 n. (b n only satisfies the recurrence, it does not satisfy the initial conditions.) 32

Example What is the solution of the recurrence relation a n = 2a n-1 - a n-2 + 2 n for n 2, with a 0 =1 and a 1 =2? Solution: We are looking for a n that satisfies both recurrence and initial conditions. a n = b n + h n where h n is a solution for the associated homogeneous recurrence: h n = 2h n-1 - h n-2. Find its characteristic equation r 2-2r + 1 = 0 (r - 1) 2 = 0 r 1 = 1 (Its multiplicity is 2.) So, by theorem h n = ( 1 + 2 n)(1) n = 1 + 2 n is a solution. 33

Example What is the solution of the recurrence relation a n = 2a n-1 - a n-2 + 2 n for n 2, with a 0 =1 and a 1 =2? Solution: a n = b n + h n a n = 4. 2 n + 1 + 2 n is a solution. Now we should find constants using initial conditions. a 0 = 4 + 1 = 1 a 1 = 8-1 + 2 = 2 1 = -3 2 = -3 So, a n = 4. 2 n - 3n - 3. 34

Recommended exercises 1,3,15,17,19,21,23,25,31,35 Eric Ruppert s Notes about Solving Recurrences (http://www.cse.yorku.ca/course_archive/2007-08/f/1019/a/recurrence.pdf) 35