Coefficients are the answers
[xᵏ]G(x) — the coefficient of xᵏ — is the count for size k. The whole sequence travels together.
A generating function packs a counting sequence into one formal power series. Multiplying series corresponds to combining choices, so a counting problem becomes an algebra problem.
Core ideas
The idea is a change of representation: turn a sequence into a function so that operations on sequences become arithmetic.
[xᵏ]G(x) — the coefficient of xᵏ — is the count for size k. The whole sequence travels together.
Multiplying two generating functions convolves their coefficients, which is exactly "choose some from the first source and the rest from the second".
Convergence is irrelevant. x is a bookkeeping symbol and the series is a way of writing an infinite sequence, not a function to be evaluated.
The material
The definition, the basic series, and two problems solved by algebra.
For a sequence a₀, a₁, a₂, …, its generating function is the formal power series G(x) = Σ_{k≥0} a_k x^k. Two series are equal exactly when all their coefficients agree.
The fifth line is “Combinations with Repetition” in a different notation, and that is the point of the method: 1/(1−x)ⁿ encodes "choose any number from each of n types", and its coefficients are exactly the stars-and-bars counts.
If A(x) counts the ways to pick items from source 1 and B(x) from source 2, then the coefficient of xᵏ in A(x)B(x) is Σ_j a_j b_{k−j} — take j items from the first source and k − j from the second, over all splits. That is precisely the product rule combined with the sum rule.
In how many ways can n cents be made from pennies, nickels and dimes? Each denomination contributes a factor: 1/(1−x) for pennies, 1/(1−x⁵) for nickels, 1/(1−x¹⁰) for dimes. The answer is the coefficient of xⁿ in the product. For n = 25 it is 12.
How many ways to choose 10 items from 4 types with at most 3 of each? Each type contributes 1 + x + x² + x³, so the answer is [x¹⁰](1 + x + x² + x³)⁴. Expanding gives 10. Check it another way: a selection is short of the maximum 12 by 2, spread over four types, and “Combinations with Repetition” counts those spreads as C(5, 2) = 10. Inclusion and exclusion would also work; the generating function encodes the constraint directly.
Generating functions solve recurrences by turning them into equations. For aₙ = 3aₙ₋₁ with a₀ = 1, write G(x) = Σ aₙxⁿ. Multiplying the recurrence by xⁿ and summing gives G(x) − 1 = 3xG(x), so G(x) = 1/(1 − 3x), whose coefficients are 3ⁿ.
The same method handles Fibonacci: G(x) = x/(1 − x − x²), and a partial-fraction decomposition recovers Binet's formula from “Solving Linear Recurrences” in Induction and Recursion. The method is more general than characteristic roots, and it extends to recurrences those cannot touch.
Addition, multiplication and (when a₀ ≠ 0) inversion of formal power series are well defined coefficient by coefficient, with no convergence question, because each coefficient of a product depends on finitely many coefficients of the factors.
Interactive
Enumerated while enumeration is possible
Method
One factor per source of choice.
Unlimited supply gives 1/(1−x); at most one gives 1 + x; at most m gives 1 + x + ⋯ + x^m; multiples of d only gives 1/(1−x^d).
The product's coefficients count the combined selections, by the convolution argument above.
By expansion, by a known series, or by partial fractions. This is where the algebra lives.
For small n the answer should match an enumeration. A generating function set up wrongly produces a confident wrong series.
Pennies, nickels and dimes, unlimited supply.
For 25 cents the case split is quicker than the algebra. The generating function earns its place when the target is symbolic — it gives the answer for every n at once, and the cases would have to be redone for each.
Write the generating function for making n cents from pennies, nickels and quarters with at most three of each, and extract the coefficient for n = 30. The factors are where the constraints live.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.