A recurrence plus initial conditions determines the sequence
Order k needs k initial values. With them every term is determined; without them the recurrence describes a family.
A recurrence gives each term from previous ones. Setting one up is modelling; solving it means finding a closed form. This lesson does the first and prepares the second.
Core ideas
Most of the difficulty in recurrences is setting them up. The solving techniques of “Solving Linear Recurrences” and “Divide-and-Conquer Recurrences” are mechanical once the recurrence is right.
Order k needs k initial values. With them every term is determined; without them the recurrence describes a family.
aₙ = 2aₙ₋₁ + 3aₙ₋₂ is linear. aₙ = aₙ₋₁² and aₙ = aₙ₋₁ · aₙ₋₂ are not, and the techniques of “Solving Linear Recurrences” do not apply to them.
The + f(n) in a nonhomogeneous recurrence is what makes the Tower of Hanoi 2aₙ₋₁ + 1 rather than 2aₙ₋₁.
The material
The classification, then four models built from scratch.
A recurrence relation expresses aₙ in terms of earlier terms of the sequence. Its order is how far back it reaches. Initial conditions supply the first terms outright.
aₙ = c₁aₙ₋₁ + c₂aₙ₋₂ + ⋯ + c_k aₙ₋ₖ, with the cᵢ constants and c_k ≠ 0. Linear: terms appear to the first power and are not multiplied together. Homogeneous: no term without an a in it.
A balance growing at r per period: aₙ = (1 + r)aₙ₋₁, with a₀ the initial deposit. First order, linear, homogeneous, and its solution a₀(1+r)ⁿ is immediate.
Hₙ = 2Hₙ₋₁ + 1, H₁ = 1. First order, linear, nonhomogeneous — the +1 is the single move of the largest disc, and it is what makes the answer 2ⁿ − 1 rather than a power of 2.
Fibonacci Fₙ = Fₙ₋₁ + Fₙ₋₂ is second order, linear, homogeneous. It counts more than rabbits: the number of binary strings of length n with no two consecutive 1s satisfies it too, because such a string either ends in 0 (any valid string of length n−1) or in 01 (any valid string of length n−2).
That derivation is the model for setting up a counting recurrence: split the objects by their last piece, and each part is counted by a smaller instance of the same problem. Getting the split right — exhaustive and non-overlapping — is the whole task.
How many strings of length n over {0,1,2} contain an even number of 0s? Let aₙ be that count. A valid string of length n is a valid string of length n−1 followed by 1 or 2, or an invalid one followed by 0. Since there are 3ⁿ⁻¹ strings in total, aₙ = 2aₙ₋₁ + (3ⁿ⁻¹ − aₙ₋₁) = aₙ₋₁ + 3ⁿ⁻¹, with a₁ = 2. Nonhomogeneous, with f(n) = 3ⁿ⁻¹.
Before any technique, a recurrence can often be solved by unrolling it and spotting the pattern — then proving the guess by induction. That last step is not optional: unrolling produces a conjecture.
The geometric sum from “Induction with Sums and Products” finished it. Unrolling works well for first-order recurrences and becomes unmanageable for higher orders, which is why “Solving Linear Recurrences” exists.
Interactive
Iterated and solved, then compared
Method
Find the last decision; everything before it is a smaller instance.
"The number of …of length n". A vague definition produces a recurrence that counts something else.
Classify the objects by their final element or final move. Each class should correspond to a smaller instance.
Every object in exactly one class. Overlap double-counts; a gap undercounts, and neither shows up until the numbers are wrong.
A second-order recurrence needs two, and computing them by hand from the definition is where off-by-one errors surface.
Let aₙ be the number of binary strings of length n with no 11.
Same recurrence as Fibonacci, different initial conditions, so the sequence is shifted. That is the general situation: the recurrence determines the shape of the solution and the initial conditions select which one, which is exactly what “Solving Linear Recurrences” formalises.
Find a recurrence for the number of ways to tile a 2 × n strip with 1 × 2 dominoes, and check a₁ through a₄ by drawing them. You should get Fibonacci again, which is worth understanding rather than noticing.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.