Overview
When solving combinatorial problems, it may be hard to brute-force or manipulate case-work by using words. By using generating functions, you can translate the words and descriptions into algebraic objects , which can help you easily manipulate them. Even simple applications can simplify counting and recurrence problems.
Key Ideas
- The coefficient of in counts solutions to with nonnegative integers.
- Finite options become finite polynomials like .
- Multiplying series corresponds to combining choices.
Core Skills
Notation
When you want to extract the coefficient of the generating function , use the notation
Translate Choices to Factors
Each variable contributes a factor or a finite polynomial depending on constraints.
Extract Coefficients
Use known expansions like or binomial coefficients to read off coefficients.
Use the geometric series: .
Use Truncation
When only low-degree terms matter, ignore higher powers after expansion. For example, when you want the coefficient of the term , you can ignore multiplying by as it will only produce powers .
Representations
Represent numbers such as cost or amount in the power. (e.g. an apple that costs 50 is represented as )
Recurrence Formula (ADVANCED)
When given a recurrence formula that is to be solved by using generating functions, use the following method:
Make sure that the values of the variable (e.g. ) such that the recurrence relation is true, is clearly described.
Give a name to the generating function that you will look for, andwrite out that function in terms of the unknown sequence (e.g., call it ).
Multiply both sides of the recurrence by , and sum over all values of for which the recurrence holds.
Express both sides of the resulting equation explicitly in terms of your generating function .
Solve the resulting equation for the unknown generating function .
If you want an exact formula for the sequence that is defined by the given recurrence relation, then attempt to get such a formula by expanding into a power series by any method you can think of. In particular, if is a rational function (quotient of two polynomials), then success will result from expanding in partial fractions and then handling each of the resulting terms separately.
Worked Example
Count solutions to with .
The generating function is . The coefficient of is .
(Brute Force Method: Since we only need the term, we can let the 'generating function' as and then brute force expand this. NOT RECOMMENDED)
More Examples
Example 1: Bounded Variables
Count solutions to with .
Use and extract the coefficient.
Example 2: Distinct Parts
Count partitions of into distinct parts.
Use the generating function .
Example 3: Counting Word Problem
Alice went to a store and saw three items: an apple (cost: 9 cents), a banana (cost: 14 cents), and an orange (cost: 17 cents). She has exactly 2 dollars and doesn't want any change. In how many ways can she achieve this?
Convert this problem into equations: let be the number of apples, be the number of bananas, be the number of oranges. Then . So constraints is . So we wish to find the coefficient of
Example 4: Recurrence Extraction (ADVANCED)
Find the general term of where
By using the above method, we let By manipulating the given recurrence relation (multiply by and sum over ),
Remember that and .
Then,
By manipulating this, we get:
By doing partial fractions, we can let this be:
Where and (Notice that , the golden ratio). Now, using the geometric series .
By substituting the values of and ,
When comparing this to Binet's formula for Fibonacci numbers, this is equal to
Example 5: Interesting Sum
Your goal is to evaluate the following expression:
First, we let
Then
Using
we get that
And factoring,
Then, we see that partial fractions gives us the following:
And consequently,
Example 6: Classic Gen. Functions Problem (remember this!)
Let denote the number of ordered compositions of whose parts are only or . Your job is to find .
First, notice that each part contributes the following:
Thus, we have that
Next, we can multiply through to get:
And comparing the coefficients gives us our answer:
Example 7: Only Even-Sized Subsets (also very common! Remember this!)
How many subsets of contain an even number of elements (solve using generating functions)?
First, notice that the generating function is simply:
Realize that the sum of the even coefficients is
And consequently, we get
Which makes the answer:
Example 8: More binomial expressions!
Your job is to show that the following expression is true:
First, recall that
Then, squaring the expression, we get:
Notice that the coefficient of on the left is simply
while the coefficient on the right is
Thus, we have:
Example 9: Catalan Numbers (very famous and fun numbers with many applications!)
Your goal is to find a generating function for the Catalan numbers , which are defined by
First, we let
Then, using the recurrence relation, we get that
Solving the quadratic equation,
Since , we can simply choose the negative one
Thus,
Example 10: Derangements
Let denote the number of permutations of with no fixed points.
First, notice that the exponential generating function for all permutations is
Next, notice that for each element, either it is fixed (contributing ) or not fixed (contributing ), so we can simply remove fixed points by multiplying by .
Hence the exponential generating function for derangements is
Therefore,
Strategy Checklist
- Translate each constraint into a factor.
- Use binomial series for .
- Use the geometric series .
- Truncate when only a few coefficients are needed.
- Convert the amount of an item into a power of .
- Use the above 'method' to solve for the recurrence relation.
- Describe variables
- Name Generating Functions
- Sum over all that the relation holds
- Express equation in generating functions from Step 2
- Solve equation
- Expand generating function into power series to extract coefficients.
(This module was based on generating functionology: https://www2.math.upenn.edu/~wilf/gfologyLinked2.pdf )
Practice Problems
| Status | Source | Problem Name | Difficulty | Tags | ||
|---|---|---|---|---|---|---|
| MathNet | Hard | Show TagsGenerating functions, Sums and products | ||||
| Harvard-MIT Math Tournament | Hard | Show TagsGenerating functions, Recurrence relations | ||||
| USA IMO | Hard | Show TagsGenerating functions, Sums and products, Telescoping series | ||||
| USA IMO | Hard | Show TagsCounting two ways, Generating functions, Modular Arithmetic, Pigeonhole principle | ||||
| Harvard-MIT Math Tournament | Hard | Show TagsGenerating functions, Sums and products | ||||
| Harvard-MIT Mathematics Tournament | Hard | Show TagsGenerating functions, Recurrence relations | ||||
| USA IMO | Hard | Show TagsComplex numbers, Enumeration with symmetry, Generating functions, Inclusion-exclusion, Roots of unity | ||||
| Harvard-MIT Mathematics Tournament | Hard | Show TagsGenerating functions, Polynomial operations | ||||
| Harvard-MIT Mathematics Tournament | Hard | Show TagsGenerating functions, Roots of unity | ||||
| Harvard-MIT Mathematics Tournament | Hard | Show TagsGenerating functions, Recurrence relations, Sums and products | ||||
| Harvard-MIT Mathematics Tournament | Hard | Show TagsGenerating functions | ||||
| 10th Annual Harvard-MIT Mathematics Tournament | Hard | Show TagsCounting two ways, Generating functions | ||||
| 11th Annual Harvard-MIT Mathematics Tournament | Hard | Show TagsGenerating functions | ||||
| 11th Annual Harvard-MIT Mathematics Tournament | Hard | Show TagsCatalan numbers, partitions, Generating functions, Sums and products | ||||
| Harvard-MIT Mathematics Tournament | Hard | Show TagsGenerating functions | ||||
| Harvard-MIT Mathematics Tournament | Hard | Show TagsGenerating functions, Recurrence relations, Sums and products | ||||
| Team Selection Test 2010 | Hard | Show TagsCounting two ways, Generating functions, Inclusion-exclusion, Induction / smoothing | ||||
| Harvard-MIT Mathematics Tournament | Hard | Show TagsAlgebraic properties of binomial coefficients, Generating functions, Sequences and Series | ||||
| Team Selection Test | Hard | Show TagsGenerating functions, Modular Arithmetic, Polynomial operations | ||||
| HMMT | Hard | Show TagsFermat / Euler / Wilson theorems, Generating functions, Greatest common divisors (gcd), Multiplicative order, Other | ||||
| USAMO | Hard | Show TagsAlgebraic properties of binomial coefficients, Generating functions, Induction / smoothing, Recursion, bijection | ||||
| HMMT 2013 | Hard | Show TagsEnumeration with symmetry, Generating functions | ||||
| HMMT | Hard | Show TagsGenerating functions, Sums and products | ||||
| HMMT 2014 | Hard | Show TagsComplex numbers, Generating functions, Recurrence relations, Roots of unity, φ (Euler's totient) | ||||
| HMMT February 2016 | Hard | Show TagsGenerating functions, Polynomial operations, Ring Theory | ||||
| February 2017 | Hard | Show TagsExpected values, Generating functions, Sums and products | ||||
| February 2017 | Hard | Show TagsGenerating functions, Roots of unity | ||||
| USA TSTST | Hard | Show TagsAlgebraic properties of binomial coefficients, Coloring schemes, extremal arguments, Expected values, Generating functions, Induction / smoothing, Invariants / monovariants, Roots of unity | ||||
| HMMT November 2019 | Hard | Show TagsExpected values, Generating functions, Inclusion-exclusion | ||||
| HMMT February 2019 | Hard | Show TagsGenerating functions, Other, Prime numbers, Recurrence relations | ||||
| HMMT February 2020 | Hard | Show TagsAlgebraic properties of binomial coefficients, Expected values, Generating functions | ||||
| HMMT February 2020 | Hard | Show TagsAlgebraic properties of binomial coefficients, Catalan numbers, partitions, Generating functions | ||||
| HMIC | Hard | Show TagsAlgebraic properties of binomial coefficients, Fermat / Euler / Wilson theorems, Generating functions, Polynomials mod p, Quadratic residues | ||||
| HMMT Spring 2021 Team Round | Hard | Show TagsAlgebraic properties of binomial coefficients, Counting two ways, Generating functions, Induction / smoothing, Recursion, bijection | ||||
| HMIC | Hard | Show TagsDecimals, Generating functions, Sums and products | ||||
| AIME II | Hard | Show TagsGenerating functions, Polynomials, Techniques: modulo, size analysis, order analysis, inequalities | ||||
| HMIC | Hard | Show TagsGenerating functions, Induction / smoothing, Sums and products | ||||
| USA TSTST | Hard | Show TagsColoring schemes, extremal arguments, Generating functions | ||||
| HMMT November 2023 | Hard | Show TagsCounting two ways, Generating functions, Sums and products | ||||
| USA TST | Hard | Show TagsGenerating functions, Greatest common divisors (gcd), Induction / smoothing, Roots of unity, Vectors | ||||
Module Progress:
Join the Discord Community!
Stuck on a problem, or don't understand a module? Join the Discord and get help with your doubts while making more math friends.
