Loading lessons...
Generating Functions & Solving Recurrences
1. Definition
The (ordinary) generating function of a sequence a₀, a₁, a₂, … is the formal power series
G(x) = ∑k=0∞ ak xk = a0 + a1 x + a2 x2 + …
We treat x as a placeholder; the coefficient of xᵏ stores aₖ.
2. Standard Generating Functions
| Sequence aₖ | G(x) |
|---|---|
| 1, 1, 1, … | 1/(1 − x) |
| c, c, c, … | c/(1 − x) |
| 1, −1, 1, −1, … | 1/(1 + x) |
| aᵏ | 1/(1 − ax) |
| (−a)ᵏ | 1/(1 + ax) |
| k + 1 (1, 2, 3, …) | 1/(1 − x)² |
| k (0, 1, 2, 3, …) | x/(1 − x)² |
| k² | x(1 + x)/(1 − x)³ |
| k·aᵏ | ax/(1 − ax)² |
| C(n, k) | (1 + x)ⁿ |
| C(n + k − 1, k) | 1/(1 − x)ⁿ |
Building generating functions by shifting, scaling and adding
Solved-find the generating function
- 2, 2, 2, … → 2/(1 − x)
- 3, −3, 3, −3, … → 3/(1 + x)
- 0, 0, 1, 1, 1, … → x²/(1 − x) (shift right by 2)
- 1, 1, 0, 1, 1, 1, … → 1/(1 − x) − x²
- 1, 0, −1, 0, 1, 0, −1, … → 1/(1 + x²)
- aₖ = 4ᵏ → 1/(1 − 4x); aₖ = (−2)ᵏ → 1/(1 + 2x)
- aₖ = 2 + 3k → 2/(1 − x) + 3x/(1 − x)² (by linearity)
- aₖ = C(8, k) → (1 + x)⁸
Warning
For aₖ = 2 + 3k, the "3k" part is 3·x/(1 − x)², not 3/(1 − x)² (that would be 3(k + 1)).
3. Operations
| Operation on sequences | Effect on G(x) |
|---|---|
| add aₖ + bₖ | A(x) + B(x) |
| multiply by c | c·A(x) |
| shift right (prepend a zero) | x·A(x) |
| convolution Σ aᵢbₖ₋ᵢ | A(x)·B(x) |
4. Counting with Generating Functions
The number of solutions of e₁ + e₂ + e₃ = 17 with 2 ≤ e₁ ≤ 5, 3 ≤ e₂ ≤ 6, 4 ≤ e₃ ≤ 7 is the coefficient of x¹⁷ in (x² + … + x⁵)(x³ + … + x⁶)(x⁴ + … + x⁷), which is 3.
5. Solving Recurrences with Generating Functions
Steps
- Multiply the recurrence by xʳ and sum over the r for which it holds (r ≥ order).
- Express each sum in terms of G(x), using the initial conditions.
- Solve for G(x), split into partial fractions.
- Read off aᵣ from the standard table.
Solved. ar - 2ar-1 - 3ar-2 = 0, a₀ = 3, a₁ = 1.
∑r ≥ 2 ar xr - 2x ∑r ≥ 2 ar-1 xr-1 - 3x2 ∑r ≥ 2 ar-2 xr-2 = 0
(G − 3 − x) − 2x(G − 3) − 3x²G = 0 G(1 − 2x − 3x²) = 3 + x − 6x = 3 − 5x G = (3 − 5x)/((1 + x)(1 − 3x)) = 2/(1 + x) + 1/(1 − 3x) ar = 2(-1)r + 3r (check: a₀ = 3 ✓, a₁ = −2 + 3 = 1 ✓).
Solved. aₙ = 3aₙ₋₁ for n ≥ 1, a₀ = 2. G − 2 = 3xG → G = 2/(1 − 3x) → an = 2 · 3n.
🎯 END-TERM EXAM PREP
📝 IPU End-Term Exam Corner (5-10 Marks)
- Q1. Find the generating functions of (i) 1, 1, 1, … (ii) 0, 1, 2, 3, … (iii) aₖ = 2 + 3k. (5 Marks)
- Q2. Solve ar - 2ar-1 - 3ar-2 = 0, a₀ = 3, a₁ = 1 using generating functions. (10 Marks)
- Q3. Use generating functions to find the number of solutions of e₁ + e₂ + e₃ = 17 under the bounds above. (5 Marks)