Recurrence Relation Notes
Recurrence Relation Notes
Recurrence Relations
a0 = 1 a1 = 1
an = an − 1+an−2
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 1/23 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 2/23
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 3/23 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 4/23
I Given an arbitrary recurrence relation, is there a mechanical way to I Which of these are linear homogenous recurrence relations with
obtain the closed form solution? constant coefficients?
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 5/23 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 6/23
1
Characteristic Polynomial Characteristic Equation Examples
I an =2an−1+5an−3
I i.e., replace ai with ri−(n−k)
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 7/23 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 8/23
I What are the characteristic roots of the following recurrence relations? I Then the closed form solution for an is of the form:
krkn
I an =2an−1+3an−2
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 9/23 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 10/23
Find a closed form solution for the recurrence an = an−1 I So far, we assume all characteristic roots are distinct – what happens if
this is not the case?
with initial conditions a0 = 2 and a1 = 7 I Characteristic
I Coefficients:
an = X(αi,0 + αi,1 · n + ... + αi,mi−1 · nmi−1)rin
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 11/23 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 12/23
2
Why is this theorem useful? How do we find a particular solution?
Theorem: Consider an = c1an−1 + ... +ckan−k +F(n) where:
I If we can find a particular solution, then we can also mechanically find
a solution that satisfies initial conditions. F(n) = (btnt +bt−1nt−1 + ... +b1n +b0)sn
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 17/23 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 18/23
Example I Example II
I Consider again the recurrence an = 3an−1 +2n
I Find a particular solution for an = 6an−1 − 9an−2 +2n I
I Here, s = 1 and characteristic root is 3
Characteristic root:
I Hence, there exists a particular solution of the form p1n +p0
p1n +p0 = 3(p1(n − 1)+p0)+2n I Find p0 such that p0 · 2n = 6(p0 · 2n−1) − 9(p0 · 2n−2)+2n
I A particular solution:
Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 19/23 Instructor: I¸sıl Dillig, CS311H: Discrete Mathematics Recurrence Relations 20/23
I Goal: Move all the disks to a different peg (e.g., second one) many steps does it take to move Tn disks?
I Rule 1: Larger disks cannot rest on top of smaller disks I Idea: First move the topmost n − 1 disks to peg 3; can be done in
Tn−1 steps
I Rule 2: Can only move the top-most disk at a time
I Question: How many steps does it take to move all n disks? I Now, move bottom-most disk to peg 2 – takes just 1 step
3
Towers of Hanoi, cont.
I Recurrence relation:
I Initial condition:
I Solve for α: