Introduction to Recurrence
Section titled βIntroduction to RecurrenceβRecursion uses earlier terms of a sequence to construct the next term. It appears in explicit recurrence problems on the AIME, USAMO, and USAJMO, as well as in counting and other combinatorics problems.
These notes are adapted in part from Jeffrey Chenβs Recursion in the AIME handout and the generating-functions section of the summations notes.
A recurrence relation expresses a term of a sequence in terms of earlier terms. For example,
means that every term is three times the previous one. If , then
so the sequence begins
Because the relation holds for every valid , we can repeatedly substitute backwards. For instance, if
then
In contest math, we often do not need a closed form.
Explicit Formulas and Shifts
Section titled βExplicit Formulas and ShiftsβAn explicit formula computes directly from . Repeatedly applying gives when the indexing starts at zero. An arithmetic recurrence similarly gives . Check the starting index: with instead, the exponents and increments use .
For an affine recurrence with , find a fixed value . Subtracting it gives , a geometric recurrence.
Example. A sequence satisfies and . Find .
The fixed value solves , so . Set . Then and , giving
At this gives one, and substitution reproduces the recurrence, verifying the formula.
Characteristic Roots
Section titled βCharacteristic RootsβFor a homogeneous linear recurrence , try a solution . This gives the characteristic equation . If its roots are distinct, the general solution is , with the constants determined by two initial values. Substitution verifies the recurrence, and the initial values determine every later term uniquely.
Example. Find the sequence with , , and for .
The characteristic equation is . Write . The initial values give and , hence . Thus
For a nonzero repeated characteristic root , use instead. Nonhomogeneous recurrences need an additional particular solution; the fixed-value shift above is one simple example.
Iteration Modulo an Integer
Section titled βIteration Modulo an IntegerβWhen only a remainder is requested, track residues rather than the entire sequence. For a first-order recurrence modulo , there are only states, so some state eventually repeats. A deterministic transition then repeats forever from that point. For a second-order recurrence, the state must include the pair of consecutive residues.
Example. Let and . Find .
The residues are . The return to the full state zero proves a period of three. Since , the requested remainder is .
Recursive Counting
Section titled βRecursive CountingβRecursion becomes especially useful when direct counting is messy but a βlast moveβ or βfinal case splitβ is easy to describe.
Staircase Problem
Section titled βStaircase ProblemβExample. Fred wants to climb a -step staircase. He can climb either or steps at a time. In how many ways can he climb the staircase?
Solution. Instead of counting only the -step case, define
Now think about Fredβs last move:
- If his last move is a single step, then before that he had climbed stairs.
- If his last move is a double step, then before that he had climbed stairs.
These are the only possibilities, so
The initial values are
So the sequence begins
Therefore,
This is the Fibonacci recurrence in disguise, which appears constantly in AMC and AIME counting problems.
Spacy Subsets
Section titled βSpacy SubsetsβExample. (2007 AMC 12) Call a set of integers spacy if it contains no more than one out of any three consecutive integers. How many subsets of , including the empty set, are spacy?
Solution. Let
Now split into two cases:
- If a spacy subset contains , then it cannot contain or . So the rest of the set is a spacy subset of , giving possibilities.
- If a spacy subset does not contain , then it is just a spacy subset of , giving possibilities.
Hence
The initial values are
since the spacy subsets are:
- for : ,
- for : ,
- for : .
Now compute forward:
So the answer is
Tower of Cubes
Section titled βTower of CubesβExample. (AIME 2006) A collection of eight cubes consists of one cube with edge length for each integer from to . A tower is built using all eight cubes, and the cube immediately on top of a cube with edge length must have edge length at most . How many towers can be constructed?
Solution. Define
Look at the cube of edge length . In a valid tower, it can be:
- at the bottom,
- directly above cube ,
- directly above cube .
So for each valid tower on cubes, there are exactly three ways to insert cube . Thus
We begin with
since either the cube of side length is on the bottom and is on top, or vice versa.
Then
This is a good reminder that some recurrences only become valid after the first few terms; here the relation is not meant to be applied at itself.
Catalan Numbers
Section titled βCatalan NumbersβCatalan numbers arise in many recursive counting problems where a structure splits naturally into a left part and a right part.
Example. How many paths are there from to using only right and up steps, such that the path never goes above the line ?
Let
To get a recurrence, look at the first point after where the path returns to the diagonal.
Then:
- the initial portion of the path contributes possibilities,
- the remaining portion contributes possibilities.
Summing over all possible first return points gives
For example, when , there are such paths.
Theorem 4.2 (Catalan Numbers). The th Catalan number has explicit formula
The reflection argument on the distributions and lattice paths page proves this closed form. Here the recurrence shows how it arises from splitting a path at its first return to the diagonal.
Balanced Brackets
Section titled βBalanced BracketsβExample. How many ways are there to arrange open brackets and closed brackets so that, reading from left to right, the number of closed brackets never exceeds the number of open brackets?
Solution. This is a Catalan-number problem.
Make the following bijection:
- each open bracket corresponds to a step to the right,
- each closed bracket corresponds to a step upward.
Then a bracket string with opens and closes becomes a path from to . The condition that the number of closed brackets never exceeds the number of open brackets means the path never goes above the line .
So the answer is simply
Generating Functions
Section titled βGenerating FunctionsβGenerating functions turn linear recurrences into algebraic equations and can also help evaluate sums. This section adapts the generating-functions material from the summations handout to recurrence problems. For a nonnegative integer upper index, use when or ; this convention lets us write coefficient sums without extra endpoint cases.
The basic idea is this: given a sequence , package it into the formal power series
Here denotes the coefficient of , so . We use formal power series: identities are compared coefficient by coefficient without assigning a numerical value to . A rearrangement is valid in this setting when each coefficient receives only finitely many contributions. If we evaluate an infinite series at a numerical , we must also check convergence.
Multiplying generating functions performs a convolution: . This is why products describe structures built from two independent size contributions.
That lets us turn a whole sequence into one algebraic object. This is useful because:
- may have a nice closed form.
- The coefficients of encode the entire sequence.
- Recurrence relations often turn into algebraic equations in .
- Once you get a rational expression for , partial fractions can recover a closed form.
Toy Applications
Section titled βToy ApplicationsβExample. Show that
Let . Then
Plugging in gives the identity immediately.
Example. Compute
Differentiate the previous generating function:
Now set :
Exercise 5.3. Compute
Linear Recurrences
Section titled βLinear RecurrencesβConsider the Lucas numbers defined by
The first few terms are
Theorem 5.4 (Closed Form for Lucas Numbers). Let
Then
Proof (Lucas-number formula). Consider the generating function
Now write shifted copies:
Because , subtracting gives
So
hence
Factor the denominator:
Then partial fractions give
Expand each as a geometric series:
Matching coefficients yields
Exercise 5.5. Derive Binetβs formula for Fibonacci numbers:
As an intermediate step, show that the Fibonacci generating function is
Common Generating Functions
Section titled βCommon Generating FunctionsβWe already know
and
The next result gives many more useful expansions.
Theorem 5.6 (Generalized Binomial Theorem). For any real number , the following is a formal power-series identity. As a numerical series it converges to the stated function for ; if is a nonnegative integer, it is a finite polynomial identity valid for every :
where and, for ,
Proof (Generalized binomial coefficients). Write
and differentiate enough times to isolate the coefficient you want. For example, comparing constant terms after three derivatives gives
Important consequences, interpreted formally or within their intervals of convergence:
- Setting gives
- More generally,
- Also,
- A very important identity is
- Integrating that identity gives the Catalan generating function: where
- The exponential series is
For quick reference:
| Generating function | Sequence |
|---|---|
Example. (HMMT 2007 Combinatorics #9) Let be the set of triples of positive integers satisfying . Compute
Consider
We want the coefficient of . Since
we get
So we need the coefficient of in , which is
Snake Oil Method
Section titled βSnake Oil MethodβThe βSnake Oilβ method is a systematic way to evaluate a sum depending on a free variable. Suppose
Example. For , compute
Let
Then
After shifting indices and using
we obtain
This is geometric:
Partial fractions give
Therefore
so
Example. For , compute
Again,
Rewrite using :
Thus
This is the Fibonacci generating function, so the sum equals .
If the free variable appears in many places at once, Snake Oil often works better after you first generalize the identity.
Problems
Section titled βProblemsβProblem 5.11. Prove that for every integer ,
Problem 5.12. For integers , prove that
Problem 5.13. Let be positive integers. Compute
Problem 5.14. For , compute
Choosing States for Restricted Counting
Section titled βChoosing States for Restricted CountingβA single count may not contain enough information to extend a structure by one step. Define several states that record exactly the feature affecting the next choice. Extra history that cannot influence later moves is unnecessary; missing relevant history leads to an incorrect recurrence.
For strings with forbidden runs, the length of the current trailing run is a natural state. For tilings, record the shape of the unfinished boundary. For a random walk, record the current position and any feature that changes the transition rule.
Example. Find the number of binary strings of length eight containing no three consecutive ones, and derive a generating function for the counts.
Let count valid strings of length , with for the empty string. A valid string ends with zero, with zero followed by one, or with zero followed by two ones, except for the short strings handled by initial values. For this gives
Equivalently, use states for trailing runs of zero, one, or two ones. Appending zero sends every state to the first; appending one advances the run length and is forbidden from the third state.
The counts are , so the answer is . Multiplying by the recurrence denominator leaves only the initial corrections:
Thus . The numerator records the initial conditions rather than being an arbitrary adjustment.
Repeated Roots and Nonhomogeneous Terms
Section titled βRepeated Roots and Nonhomogeneous TermsβFor a repeated nonzero characteristic root , the two independent solutions are and . The extra factor of is necessary because two constant multiples of the same geometric sequence would supply only one free initial condition.
Example. Solve with .
The characteristic polynomial is , so use . The first value gives , and the second gives , hence . Therefore
Substitution verifies the recurrence. Together with the two initial values, uniqueness of the recursively defined sequence proves the formula.
For a nonhomogeneous recurrence, first solve the homogeneous part and then find one particular solution. If the forcing term already resembles a homogeneous solution, multiply the trial by , or by a higher power of when there is repeated overlap. This is the discrete counterpart of resonance in differential equations.
Example. Solve with .
A trial fails because the homogeneous recurrence already has that form. Instead, divide by the common geometric factor. Let . Then
With , we obtain and . This transformation also explains why the factor of appears.
Nonlinear Recurrences That Become Linear
Section titled βNonlinear Recurrences That Become LinearβThe apparent degree of a recurrence can be misleading. A reciprocal, shift, or ratio may reveal a linear relation. Choose the substitution by examining how the operation changes the denominator or the fixed points.
Example. A sequence satisfies and . Find and its limit.
All terms remain positive, so reciprocals are allowed. Set . The recurrence becomes
Hence and . The terms tend to zero. Guessing the limit from the fixed-point equation alone would not have proved convergence; the explicit formula proves both the values and the limit.
For recurrences involving two coupled quantities, an invariant can be more useful than a closed form. Under the update
direct expansion gives . Starting from therefore produces integer solutions of forever. When the question concerns divisibility or an equation satisfied by the terms, this invariant may answer it without diagonalizing the update.
Ordinary and Exponential Generating Functions
Section titled βOrdinary and Exponential Generating FunctionsβOrdinary generating functions multiply by convolution because the coefficient records only the total size. For labeled objects, an exponential generating function uses instead. The factorial denominator makes multiplication insert the binomial coefficient choosing which labels belong to each component:
Use the ordinary version for counts where sizes split without choosing labels, and the exponential version when distributing distinct labels among components. The two conventions encode different counting rules; switching between them without changing coefficients changes the problem.
For example, assigning distinct objects to three named nonempty boxes is counted by . Expanding the cube gives for , agreeing with inclusionβexclusion. This connection explains why generating functions can recover formulas first found by a completely different method.
Key Equations
Section titled βKey EquationsβPractice Problems
Section titled βPractice ProblemsβThese are good recursion problems to revisit after you are comfortable with the examples above.
Exercise 5.1. How many ways are there to tile a board with dominoes?
Exercise 5.2 (AMC 12 2019). How many binary sequences of length begin with , end with , contain no two consecutive βs, and contain no three consecutive βs?
Exercise 5.3 (AIME 2015). There are possible -letter strings using only and . How many do not contain more than three adjacent identical letters?
Exercise 5.4. Given a regular -gon, how many ways are there to pair vertices with nonintersecting chords?
Exercise 5.5 (AIME 2001). A mail carrier delivers mail to the nineteen houses on one side of Elm Street. No two adjacent houses receive mail on the same day, and there are never more than two consecutive houses that get no mail. How many delivery patterns are possible?