Advanced Combinatorics
Generating Functions
Overview
Generating functions convert combinatorial sequences and recurrences into algebraic objects. The trick: multiply aā by xāæ and sum, then translate the recurrence into an equation for G(x). Solving algebraically and expanding back gives the closed form. Generating functions unify three separate techniques: solving recurrences, counting with constraints, and computing moments of distributions. In quant contexts, probability generating functions are used to compute moments and characterize distributions defined recursively (like branching processes).
How to Recognize
- āYou have a recurrence and need a closed form
- āCounting problems with an algebraic structure
- ā'How many ways to...' with a sum constraint and varying parts
- āSolving linear recurrences with variable coefficients
- āProbability distributions defined recursively
Step-by-Step Approach
- 1.Define G(x) = Ī£ aā xāæ (ordinary generating function, OGF)
- 2.Translate recurrence into algebraic equation for G(x)
- 3.Solve for G(x) ā usually a rational function
- 4.Partial fractions ā read off aā from known series (1/(1-αx) = Ī£ αāæxāæ)
- 5.For probability: pgf G(x) = E[x^X] ā G'(1) = E[X], G''(1) = E[X(X-1)]
Key Formulas
Worked Examples
Problem
How many ways can you make change for n cents using pennies (1Ā¢) and nickels (5Ā¢)?
Solution
Let aā = number of ways to make n cents. G(x) = Ī£ aāxāæ.
Pennies contribute: 1 + x + x² + ... = 1/(1-x) (use 0,1,2,... pennies).
Nickels contribute: 1 + xāµ + x¹Ⱐ+ ... = 1/(1-xāµ) (use 0,1,2,... nickels).
G(x) = 1/(1-x) Ć 1/(1-xāµ) = coefficient of xāæ is the number of ways.
For n=10: ways = coefficients of x¹Ⱐin 1/((1-x)(1-xāµ)). Enumerate: (0 nickels: 11 pennies... wait, 10 pennies: 1 way), (1 nickel, 5 pennies: 1 way), (2 nickels: 1 way). Total: 3 ways.
Answer
For n=10Ā¢: 3 ways (10 pennies; 1 nickel + 5 pennies; 2 nickels). Generating function: G(x) = 1/((1-x)(1-x^5)).
Common Mistakes
- !
Evaluating at x=1 to get the 'count' ā but G(1) often diverges. Use G(1) only when the sequence is a probability distribution (then G(1) = 1 is the normalization check).
- !
Not recognizing 1/(1-αx) as the geometric series generating function. Most rational generating functions decompose into partial fractions of this form.
- !
Confusing OGF and EGF (exponential generating function). For labeled structures, use EGF = Ī£ aā xāæ/n!. Compositions = OGF; permutations/labeled structures = EGF.
Practice Problems
Click "Show Answer" to revealFind a closed form for the number of ways to tile a 2Ćn board with 1Ć2 dominoes.
The number of ways to climb n stairs, taking 1 or 2 steps at a time, satisfies what recurrence? Solve for the closed form.