Recurrence relations and counting
Derive recurrences from reversible structural cases and supply the initial data that make them determine a sequence.
On this page
The question for today
What you’ll understand
- Derive a counting recurrence using disjoint exhaustive cases.
- Choose enough state information to extend a structure correctly.
- Verify boundary values and distinguish counts from probabilities.
A recurrence replaces one large counting problem by smaller ones, but it is only reliable when the reduction has a structural explanation. A strip assembled from short tiles offers a useful example: its final tile tells us exactly which smaller strip remains. Other problems require remembering a boundary condition, such as the last symbol of a word. The central design question is therefore not which familiar sequence appears, but which information makes every extension unambiguous.
Peeling off the last component
Let a strip of integer length n be tiled with unit squares and length-two dominoes, all tiles having one color. Every nonempty tiling ends either with a square or with a domino. Removing that last tile leaves a tiling of length n minus one or n minus two, respectively. These cases are disjoint because their final tiles differ, and exhaustive because no other tile lengths are allowed. Reattaching the removed tile provides the inverse map in each case.
The empty strip has one tiling, and the length-one strip has one tiling. With these initial values, the recurrence determines each later value by induction. Defining the count at negative lengths to be zero can simplify formulas, but that is an explicit convention rather than another physical strip. A different tile palette changes the recurrence: two square colors contribute twice the shorter-strip count. The coefficients record the number of reversible extension choices, not an adjustment guessed after comparing a few terms.
A state summarizes the relevant boundary
Consider binary words with no adjacent ones. To append a zero, every valid shorter word is eligible; to append a one, only words ending in zero are eligible. A total count alone does not describe those eligibility classes, so temporarily keep separate counts for final zero and final one. The empty word needs its own initial interpretation, or the length-one cases can be supplied directly. This state-based view is the counting analogue of tracking sufficient boundary data in an algorithm.
State transitions count extensions, whereas a stochastic transition matrix distributes probability. These should not be confused: both may use matrix multiplication, but their entries have different meanings and their row sums obey different rules. Finite-state recurrences are particularly effective for restrictions on a bounded window of recent symbols. If eligibility depends on an unbounded statistic, the state may need to grow with size. Claiming that a finite state captures the rule requires proving that two histories in that state have identical future possibilities.
Verification comes before closed forms
A proposed recurrence should be checked at its first valid index and against small direct enumerations. This catches missing empty objects, overlapping cases, and off-by-one choices of size. To establish uniqueness, assume all previous values have been determined and use the recurrence to determine the next. A closed form then needs to satisfy both the recurrence and every required initial value. Matching only the recurrence leaves an entire family of possible sequences.
Recurrences can be computationally useful even without a closed form. Tabulating each value once avoids the duplicated work of a naive recursive program. Integer arithmetic keeps counts exact; machine integers may overflow long before the underlying structural argument fails. A recurrence that subtracts large counts can also be less numerically stable in floating-point arithmetic than one with positive terms. The proof, the algorithm, and the chosen numeric representation are separate parts of a trustworthy counting calculation.
Work it through
Five cells with two square colors
A length-five strip uses red or blue unit squares and uncolored length-two dominoes. Derive and evaluate its count.
Let a₀=1 and a₁=2. Ending with a square offers two color choices after any shorter tiling; ending with a domino offers one choice after a tiling two units shorter.
Thus aₙ=2aₙ₋₁+aₙ₋₂. Calculate a₂=5 and a₃=12, retaining the empty tiling in the a₂ computation.
Continue with a₄=29 and a₅=70. As a separate check, split by the number of dominoes: zero gives 32, one gives 4×8=32, and two gives 3×2=6.
The count is seventy, agreeing with the independent split 32+32+6.
The living notebook
Explore the model
Interactive lab · modular
A fully specified recurrence state
Pause and Reset, then set modulus m=12 and additive step a=5. Predict the first repeated residue for rₙ₊₁=rₙ+5 mod 12, starting from zero; Step advances one recurrence update. For a fresh comparison, Reset and set m=12 and a=4. Predict which residues remain reachable.
- Residue r0
- 0
- Orbit period · m/gcd(m,a)
- 12
- Distinct residues visited
- 1 of 12
Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forThe first orbit has period twelve; the second is 0,4,8 with period three. This deterministic recurrence shows why initial state and update matter. It does not count tilings or encode forbidden-word histories.
Pause & reason
Check your understanding
Your turn
Try it yourself
How many binary words of length five avoid adjacent ones? Give initial values and intermediate counts, rather than only a final number.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Partition by the final symbol, or use the total-count recurrence with lengths zero and one.
Compare with the solution
The empty word contributes b₀=1 and the length-one words give b₁=2. A word ending in zero extends any shorter valid word; a word ending in one, at length at least two, must end in 01 and extends a word two places shorter. Thus b₂=3, b₃=5, b₄=8, and b₅=13. The suffix cases are disjoint and reversible, so thirteen is the exact count.
Keep the idea
Take it with you
- A valid recurrence comes from disjoint, exhaustive, reversible cases.
- State variables must retain every boundary feature that affects extensions.
- Initial conditions and index ranges are part of the theorem.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.