Setting Up Recurrences
A recurrence counts a large problem in terms of smaller versions of itself. To build one:
- [leftmargin=*,itemsep=1pt]
- Define the sequence precisely. Let be the number of ways to do the task of “size” . Being sloppy here is the #1 source of errors --- write a one-sentence definition.
- Condition on a first (or last) choice. Look at the object and split into cases based on one feature: the first tile, the last step, whether an element is used, the height of the last column, etc.
- Express each case using smaller . Each case should leave a strictly smaller sub-problem of the same type, so it is counted by for some .
- Nail the base cases. Determine (or ) directly by hand. Count the “empty” object carefully: usually .
The recurrence plus base cases determines every term.
Let be the number of ordered sequences of s and s summing to (order matters). Condition on the first number in the sequence:
- [leftmargin=*,itemsep=1pt]
- If it is a , the rest sums to : that is ways.
- If it is a , the rest sums to : that is ways.
So . Base cases: (the empty sequence) and . This gives --- the Fibonacci numbers.
Tips. (1) Prefer conditioning on the first or last element --- it usually leaves a clean sub-problem. (2) Always sanity-check by hand-counting against your formula. (3) Decide up front whether order matters and whether should be or .
Fibonacci & Tiling / Domino Problems
The Fibonacci numbers satisfy
giving Many tiling problems reduce to this.
Square--domino tilings. Let be the number of ways to tile a strip using squares and dominoes. Look at the tile covering the last cell: a square (leaving a strip) or a domino (leaving a strip). So with , i.e. .
Let be the number of ways to tile a board with dominoes. Consider the leftmost column:
- [leftmargin=*,itemsep=1pt]
- One vertical domino fills the column, leaving a board: ways.
- Two horizontal dominoes fill the first two columns, leaving a board: ways.
Hence , with , . So ; e.g. a board has tilings.
Tips. The recurrence comes from “what covers the boundary cell?” Different tile sets change the recurrence: squares + dominoes + trominoes on a strip give . Watch indexing: confirm which Fibonacci index your base cases land on.
State-Based Counting Recursions
When the next choice depends on the current situation, define one sequence per state and let them recurse together. Steps:
- [leftmargin=*,itemsep=1pt]
- Identify the finite information (the “state”) you must remember to extend a valid object by one step.
- Define = number of length- objects ending in each state.
- Write transition equations: each state's next value is a sum over states that may legally precede it.
- The answer is usually the sum of all states at length .
This is the “transfer matrix” / finite-automaton viewpoint.
Count length- binary strings with no “11”. Track the last bit. Let = number ending in , = number ending in .
- [leftmargin=*,itemsep=1pt]
- A string ending in can be preceded by anything: .
- A string ending in must have before it: .
With , the total satisfies (Fibonacci again!), giving
Tips. Keep the state as small as possible --- only remember what the next transition needs. If a constraint says “no three in a row,” your state is the length of the current run, so you may need two or three coupled sequences.
Catalan Numbers
The Catalan numbers are
First values:
They count an astonishing number of things. Three canonical interpretations:
- [leftmargin=*,itemsep=1pt]
- Lattice paths / ballots: monotonic paths from to using steps right/up that never cross above the diagonal . Equivalently, sequences of s and s with every partial sum .
- Balanced parentheses: the number of ways to correctly match pairs of parentheses (every prefix has ).
- Triangulations: the number of ways to cut a convex -gon into triangles using non-crossing diagonals.
Other appearances: binary trees with internal nodes, non-crossing handshakes among people, mountain ranges, and stack-sortable permutations.
How many ways to fully parenthesize a product of factors, e.g. ? This is :
Why ? In a balanced string, the first “(” closes at some point, splitting the string into an inner balanced block (size ) and a following balanced block (size ). Summing over the split point gives the convolution. This same split proves the triangulation and binary-tree counts.
Tips. If a counting problem involves “never falls behind,” “non-crossing,” or “a valid bracket/matching structure,” suspect Catalan. Memorize through : . The ratio makes them fast to extend.
Generating Functions (introduction)
A (ordinary) generating function packages a sequence into one formal power series
The exponent of is a “label” tracking a total (size, weight, sum), and the coefficient counts objects with that total. The magic:
If counts choices for part 1 (weighted by size) and counts part 2, then the product has -coefficient --- exactly the number of ways to split total between the two parts. Useful building blocks:
In how many ways can you make cents using pennies (1c), nickels (5c), and dimes (10c), unlimited supply, order irrelevant? Each coin type contributes a geometric factor tracking how much value it supplies:
The coefficient of in is the answer. For instance : pennies; (nickels); a nickel pennies; one dime. Products of GFs automatically handle “distribute the total among independent parts.”
Tips. Treat as a formal symbol --- convergence does not matter. “Choose one of several” becomes a sum of terms; “do several things independently” becomes a product of series. To read off a coefficient, use or partial fractions.
Solving Simple Linear Recurrences
For a linear recurrence with constant coefficients
guess . Substituting and dividing by gives the characteristic equation
- [leftmargin=*,itemsep=1pt]
- Distinct roots : the general solution is .
- Repeated root : use .
Fix from two initial values. The same idea extends to order : a degree- characteristic polynomial with roots.
Given . Characteristic equation: , i.e. , so and . Thus
Initial conditions: and . Solving, , so
Check: . ✓
Tips. Bring everything to one side so the characteristic polynomial is clear. Complex roots are fine --- they produce oscillating solutions. For a nonhomogeneous recurrence (), add a particular solution (try a constant for constant , a linear guess for linear ) to the homogeneous solution.
Going Deeper: Closed Forms and Proofs
(A) The Catalan closed form by reflection. Count lattice paths from to (steps R and U) that stay weakly below the diagonal. Total paths: . A bad path touches the line . Reflect the portion of a bad path after its first touch across : this bijects bad paths with all paths from to , of which there are . Hence
(B) Solving a recurrence with a generating function. Let . The convolution says . Solving the quadratic,
and expanding by the binomial series recovers . This “turn the recurrence into an equation for , solve, expand” pipeline is the general method.
(C) Binet's formula for Fibonacci. The characteristic equation has roots and . Then
Since , is the nearest integer to , so Fibonacci numbers grow like .
The Fibonacci GF is . Factor the denominator using and split by partial fractions:
which reads off Binet's formula directly. Partial fractions on -type denominators is the bridge from recurrence to closed form.
Big picture. Recursion, Catalan numbers, and generating functions are one connected toolkit. Recursion is how you discover a count by conditioning on a first/last choice or a state. Generating functions are how you package and solve those recurrences --- products encode independent choices, and solving an algebraic equation for yields closed forms. Catalan numbers are the flagship example where all three views (a convolution recurrence, a reflection/bijection argument, and a GF quadratic) meet in one answer. When you see “count in terms of smaller cases,” set up ; when you see “combine independent totals,” multiply GFs; when you see “non-crossing / balanced / never-behind,” reach for Catalan.
Nonhomogeneous & Higher-Order Linear Recurrences
A linear recurrence with a forcing term,
is solved by
where is the general solution of the homogeneous part (characteristic roots, as before) and is any one particular solution. To find , guess a form matching and solve for its constants:
Resonance (the crucial trap). If your guess already solves the homogeneous equation --- e.g. but is a characteristic root, or is constant but is a root --- multiply the guess by (by if is a root of multiplicity ). This is the same “multiply by for a repeated root” rule seen in the homogeneous case.
Solve with .
Homogeneous part: , so and .
Particular part: the natural guess is resonant because is already a root. Multiply by : try . Substituting,
Divide by : , i.e. , giving . So .
Combine and fit: . From and we get . Thus
Check: , and . ✓
Tips. (1) Always solve the homogeneous roots first --- you cannot detect resonance until you know them. (2) A constant forcing term with a root needs the guess (not ). (3) If is a sum of pieces, find a particular solution for each piece separately and add. (4) Fit the constants using the full solution , never the homogeneous part alone.
The Transfer-Matrix Method
A coupled linear recurrence among finitely many states is one matrix acting on a state vector. If collects the state values at step and , then
For the Fibonacci recurrence, taking ,
The matrix's eigenvalues are exactly the characteristic roots , which is why (hence every entry) is a combination of and --- another route to Binet's formula. Taking determinants of the boxed identity gives instantly (Cassini's identity).
Counting walks. If is the adjacency matrix of a (multi)graph, then counts walks of length from vertex to , and counts closed walks. This packages “count paths through states” as matrix powers.
Three vertices of a triangle are all mutually adjacent. How many closed walks of length start and end at vertex ? The adjacency matrix is where is all-ones:
Its eigenvalues: has eigenvalues , so has eigenvalues . By symmetry every diagonal entry of is equal, and , so
Check : closed walks number , and . ✓ For we get , the two directed triangles and . This is the standard AIME-style “ant walks on a solid/graph and returns home” setup.
Tips. (1) Order- scalar recurrences become companion matrices whose characteristic polynomial is the recurrence's. (2) For symmetric transition structures, diagonalizing via eigenvalues turns into a clean closed form --- look for an all-ones or circulant pattern. (3) and identities (Cassini) fall out for free. (4) On a highly symmetric graph, “lump” equivalent vertices into one state to shrink the matrix.
The Cycle Lemma & the Ballot Problem
The reflection principle is one proof of the Catalan/ballot counts; the cycle lemma is a slicker, purely combinatorial one.
Cycle Lemma (Dvoretzky--Motzkin). Take any sequence of steps that are 's and 's summing to (so ups and downs). Among its cyclic rotations, exactly one has all partial sums strictly positive.
Ballot Theorem. In an election where gets votes and gets votes, the number of orderings of the ballots in which is strictly ahead throughout is
Catalan is the boundary case: paths from to staying strictly below the diagonal except at the ends correspond to shifted, and the ballot formula collapses to .
In how many ways can people holding a $5 bill and people holding a $10 bill line up at a box office charging $5, starting with an empty till, so the cashier can always give change?
Model each $5 as and each $10 as . There are people; the partial sums must stay (in fact after the first person once we require never getting stuck), and the total is . Any arrangement of the steps summing to has, by the cycle lemma, exactly one of its rotations with all partial sums positive. Since the total number of step-sequences is and they group into rotation-classes each contributing exactly one good sequence,
For ($5,$5,$5 and $10,$10): . ✓ The one-good-rotation-per-class argument avoids any reflection bijection entirely.
Tips. (1) The cycle lemma also proves the Fuss--Catalan numbers (paths with up-steps and down-steps ) --- same one-good-rotation idea. (2) “Strictly ahead” vs. “never behind” shifts an index by one; recount a tiny case to pin it down. (3) When a problem says “running total never goes negative” and you can cyclically shift without changing the count, reach for the cycle lemma instead of reflection.
Exponential Generating Functions
When objects are built on labeled elements (people, positions that are distinguishable), the right bookkeeping tool is the exponential generating function
The key rule mirrors the ordinary case but with a binomial-flavored product:
The appears because you first choose which labels go to the -part. Building blocks:
The Exponential Formula passes from “connected” pieces to arbitrary disjoint unions of them (set partitions into blocks, permutations into cycles, graphs into components).
A derangement is a permutation with no fixed point; let be their count. Every permutation splits its labels into a set of fixed points and a derangement of the rest:
In EGF language this is a product: (all permutations) (choose fixed points) (derange the rest), i.e.
Reading off the coefficient of ,
the familiar inclusion--exclusion formula, and is the nearest integer to . From one also reads the recurrences and .
Big picture. Use an ordinary GF when parts combine by “split the total” (unlabeled: coins, compositions, tilings); use an exponential GF when parts combine by “distribute distinct labels” (labeled: permutations, set partitions, surjections). The dictionary --- product independent combination, disjoint components --- lets you write the answer's generating function directly from a structural description, then extract by expanding.
Formulas, Proofs & Tips
What it means. Define a term from earlier terms; Catalan numbers count balanced structures.
Example. Fibonacci: ; and .
Why it works. Fibonacci-style counts split on the last step: a tiling ending in a single square leaves ways, one ending in a domino leaves , and the cases do not overlap. Catalan counts paths that never dip below the axis — the reflection argument removes exactly bad paths.
Tip. Always state the base cases; a recursion without them defines nothing.