core28 min studyLesson 222 in Mathematics

Recurrence relations and counting

Derive recurrences from reversible structural cases and supply the initial data that make them determine a sequence.

On this page

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.

t0=1,t1=1,tn=tn−1+tn−2(n≥2)t_0=1,\quad t_1=1,\quad t_n=t_{n-1}+t_{n-2}\quad(n\ge2)
The two summands count tilings ending in a square and a domino. Two initial values are needed for this second-order recurrence.↔ Scroll wide equations horizontally.

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.

(zn+1on+1)=(1110)(znon),z1=o1=1\begin{pmatrix}z_{n+1}\\o_{n+1}\end{pmatrix}=\begin{pmatrix}1&1\\1&0\end{pmatrix}\begin{pmatrix}z_n\\o_n\end{pmatrix},\qquad z_1=o_1=1
The first row appends zero to either terminal state; the second appends one only to a word ending in zero. These entries count extensions.↔ Scroll wide equations horizontally.

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.

b0=1,b1=2,bn=bn−1+bn−2(n≥2)b_0=1,\quad b_1=2,\quad b_n=b_{n-1}+b_{n-2}\quad(n\ge2)
The total number of binary words avoiding adjacent ones follows the same recurrence as the tilings but has different initial values.↔ Scroll wide equations horizontally.

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.

  1. 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.

  2. Thus aₙ=2aₙ₋₁+aₙ₋₂. Calculate a₂=5 and a₃=12, retaining the empty tiling in the a₂ computation.

  3. 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.

a5=2a4+a3=2⋅29+12=70a_5=2a_4+a_3=2\cdot29+12=70
The coefficient two counts square colors; the index shift counts removed length.↔ Scroll wide equations horizontally.
The result

The count is seventy, agreeing with the independent split 32+32+6.

Explore the model

Interactive lab

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.

A fully specified recurrence stateAddition 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. Current readings: Residue r0: 0; Orbit period · m/gcd(m,a): 12; Distinct residues visited: 1 of 12. All parameters are adjustable with the labeled controls below.Repeated addition modulo 12: the current residue is 0, and the orbit period is 12.01234567891011+ 5mod 12An additive orbitn = 0rₙ = 0Period = 12Cycle starts at 0:0 → 5 → 10 → 3 →8 → 1 → 6 → 11 →4 → 9 → 2 → 7 → 0Exact residues · two additions per second
Additive orbitCurrent residue / next edge
Residue r0
0
Orbit period · m/gcd(m,a)
12
Distinct residues visited
1 of 12
t = 0 s

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.

Check your understanding

Why do tilings with uncolored unit squares and dominoes and binary words avoiding adjacent ones have different counts, although both obey aₙ=aₙ₋₁+aₙ₋₂?

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.

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.