Recurrence Relations
A recurrence tells you how to get each term from the ones before it, like H(n) = 2H(n − 1) + 1. Give it a starting value and the whole sequence is determined. It's often the most natural way to describe a count, because you can ask "how does the problem of size n reduce to a smaller one?"
What the symbols mean
- Fibonacci number
Each one is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, …
- Hanoi moves
The fewest moves to transfer n disks in the Tower of Hanoi.
Explanation
A recurrence relation is simply a rule for getting each term of a sequence from the ones before it: "to get the next number, do something to the last one or two." The name comes from the sequence recurring, or calling back to itself. The sequences in the last lesson had formulas you could write down right away, but lots of sequences don't; what you can usually see instead is how one term relates to the previous ones. just reads "each Fibonacci number is the sum of the two before it," and reads "do the smaller job twice, plus one extra move." The little subscripts (, , ) are only place numbers in the list. It's the same idea as induction, run forward: know the start, know how to take one step, and you know everything.
Tower of Hanoi. You have disks stacked on one peg, largest at the bottom, and you want them on another peg, moving one disk at a time and never putting a bigger disk on a smaller one. Think about the biggest disk. It can only move when everything else is out of the way, sitting on the third peg. So: move the top out of the way ( moves), move the biggest disk (1 move), then move the back on top of it ( moves). That gives . Listing values, , these are each one less than a power of 2, which suggests . Induction proves it: .
Fibonacci numbers show up in a surprising number of counting problems. Here's one. Let be the number of bit strings of length with no two consecutive 1s. Look at how a valid string ends. If it ends in 0, anything valid of length can come before it. If it ends in 1, the bit before that has to be 0, so it ends in 01, and anything valid of length comes before that. Those two cases don't overlap and cover everything, so . With and , that makes .
Solving a recurrence means finding a closed form, so you can jump straight to the 100th term. One approach is to compute terms, guess a pattern, and prove it by induction, as we did for Hanoi. For linear recurrences like Fibonacci there's a systematic method using characteristic roots, which is the next lesson.
Ratios of consecutive Fibonacci numbers approach the golden ratio . We'll see exactly why in the next lesson too.
See it
Worked examples
Count the 4-bit strings with no two consecutive 1s.
- 1
Start with the small cases by hand: ("0", "1") and ("00", "01", "10").
Practice
Type your answer and check it. Solve them all to complete the lesson.
What is ?
What is the fewest number of moves to solve the Tower of Hanoi with 6 disks?
If and , what is ?
How many 5-bit strings have no two consecutive 1s?
A lake holds 1000 fish. Each year the population grows 10%, and then 50 fish are caught: with . Find .
How many ways are there to climb a 10-step staircase taking 1 or 2 steps at a time?
The hardest one here. Get it, and you've got this lesson.
straight lines are drawn in the plane, no two parallel and no three through one point. Into how many regions do 10 lines cut the plane?
Where it's used
Recurrences describe population growth, loan balances and the running time of recursive algorithms such as merge sort.