Key idea of this section
A(x) = ∑ₙ aₙ xⁿ ∈ ℂ[[x]] disjoint union ↔ A + B, ordered pair ↔ A · B, sequence ↔ 1/(1 − A)
The ring of formal power series
The ordinary generating function (OGF) of a sequence (aₙ) is the formal power series A(x) = ∑ aₙ xⁿ. Formal power series are added termwise and multiplied by the Cauchy product, [xⁿ] A(x)B(x) = ∑ₖ aₖ bₙ₋ₖ. With these operations ℂ[[x]] is an integral domain, and A(x) is invertible if and only if a₀ ≠ 0 (the coefficients of the inverse are found recursively). The composition A(B(x)) is defined whenever b₀ = 0, since then only finitely many terms contribute to each coefficient. Formal differentiation obeys the usual rules. None of this requires convergence; convergence becomes relevant only for asymptotics.
The symbolic dictionary
Let 𝒜 be a combinatorial class: a set with a size function such that the number aₙ of objects of size n is finite. If 𝒜 and ℬ are disjoint, the OGF of their union is A + B. The OGF of the Cartesian product 𝒜 × ℬ, with size additive, is A · B, because an ordered pair of total size n consists of an object of size k and one of size n − k. If a₀ = 0, the class of finite sequences of objects of 𝒜 has OGF 1 + A + A² + ⋯ = 1/(1 − A). These three rules, systematized by Flajolet and Sedgewick in Analytic Combinatorics (2009), translate combinatorial descriptions directly into equations.
Example 5.1 (compositions). A composition is a sequence of positive integers. The class of positive integers has OGF x/(1 − x), so compositions have OGF 1/(1 − x/(1 − x)) = (1 − x)/(1 − 2x), and there are 2ⁿ⁻¹ compositions of n ≥ 1. Restricting to parts in {1, 2} gives 1/(1 − x − x²), the Fibonacci generating function shifted by one place.
Example 5.2 (making change). The number of ways to make n cents from coins of values 1, 5, 10, 25 is [xⁿ] 1/((1 − x)(1 − x⁵)(1 − x¹⁰)(1 − x²⁵)), since each factor 1/(1 − xd) = 1 + xd + x2d + ⋯ records how many coins of value d are used. Multiplying out (or running the corresponding dynamic program) gives 49 ways for n = 50; adding a 50-cent coin gives 292 ways to make a dollar, a figure made famous by Pólya.
Rational generating functions
Theorem 5.3. A sequence satisfies a linear recurrence with constant coefficients of order d (for all n ≥ d) if and only if its OGF is P(x)/Q(x) with Q(x) = 1 − c₁x − ⋯ − cd xd and deg P < d.
Proof. If aₙ = c₁aₙ₋₁ + ⋯ + cd an−d for n ≥ d, then the coefficient of xⁿ in Q(x)A(x) vanishes for n ≥ d, so Q(x)A(x) = P(x) is a polynomial of degree less than d. Conversely, if Q(x)A(x) = P(x) with deg P < d, comparing coefficients of xⁿ for n ≥ d recovers the recurrence. ∎ Note that Q(x) = xd χ(1/x): the poles of A are the reciprocals of the characteristic roots, and partial fractions reproduce Theorem 4.1, since 1/(1 − rx)m = ∑ₙ C(n + m − 1, m − 1) rⁿ xⁿ and C(n + m − 1, m − 1) is a polynomial in n of degree m − 1.
Coefficient extraction
Three formulas cover most extractions: [xⁿ] (1 − x)⁻ᵐ = C(n + m − 1, m − 1); [xⁿ] xk A(x) = [xⁿ⁻ᵏ] A(x); and [xⁿ] A(x)/(1 − x) = a₀ + a₁ + ⋯ + aₙ (partial sums). Differentiation gives moment-type sums: applying (x d/dx) twice to 1/(1 − x) yields ∑ n² xⁿ = x(1 + x)/(1 − x)³.
Example 5.4. The number of solutions of x₁ + x₂ + x₃ + x₄ = 12 with every xᵢ ≥ 2 is [x¹²] (x² + x³ + ⋯)⁴ = [x¹²] x⁸(1 − x)⁻⁴ = [x⁴] (1 − x)⁻⁴ = C(7, 3) = 35, in agreement with stars and bars.
Growth rates from singularities
If A(x) has radius of convergence ρ, then limsup |aₙ|1/n = 1/ρ (Cauchy–Hadamard), and when aₙ ≥ 0 Pringsheim's theorem guarantees that x = ρ itself is a singularity. Locating the dominant singularity and its type yields precise asymptotics: a simple pole at ρ gives aₙ ≈ c ρ⁻ⁿ, while a square-root singularity, as for the Catalan numbers in Lesson 9, gives aₙ ≈ c ρ⁻ⁿ n−3/2. This is the starting point of singularity analysis (Flajolet–Odlyzko, 1990).
Exercise
- (a)Find the number of ways to pay 20 cents with coins of value 1, 2 and 5.
- (b)Find [x¹⁰] (1 + x)²/(1 − x)².
- (c)Find a closed form for the OGF of the sequence aₙ = n² 3ⁿ.
Show solution
Answers: (a) 29. (b) (1 + x)²(1 − x)⁻² = (1 + 2x + x²) ∑ (n + 1)xⁿ, so the coefficient is 11 + 2·10 + 9 = 40. (c) Substitute 3x for x in x(1 + x)/(1 − x)³ to get 3x(1 + 3x)/(1 − 3x)³.