Generating functions of sequences
Definition and properties
A generating function encodes an entire sequence of numbers into a single algebraic expression. If you have a sequence , its ordinary generating function (OGF) is the formal power series:
The key idea: the coefficient of in is exactly , the th term of your sequence. This means all the information about the sequence lives inside one function.
A few things worth knowing upfront:
- Generating functions are treated as formal power series, meaning you don't always need to worry about whether the series converges. You're manipulating algebraic objects, not computing actual sums.
- The series can be finite or infinite depending on the sequence.
- Other types exist (exponential, Dirichlet), but for solving recurrence relations, ordinary generating functions are the standard tool.
Common examples
Building intuition with a few standard generating functions helps a lot:
- The constant sequence gives , from the geometric series.
- The geometric sequence gives .
- The sequence gives . You can derive this by differentiating and multiplying by .
- More generally, , which shows up constantly.
These building blocks reappear throughout the method, so recognizing them on sight saves time.
Deriving generating functions from recurrence relations
The core technique is to convert a recurrence relation into an algebraic equation for . Here's the general process:
Step-by-step process
-
Define the generating function. Let .
-
Multiply both sides of the recurrence by and sum over all valid values of (typically from the order of the recurrence to infinity).
-
Rewrite each sum in terms of using shift properties. The most important ones:
- More generally, shifting by introduces a factor of .
-
Incorporate initial conditions. When the summation range doesn't start at , you'll need to peel off the first few terms and substitute the known initial values.
-
Solve the resulting algebraic equation for .
Worked example: Fibonacci sequence
The Fibonacci recurrence is with , .
- Define .
- Multiply the recurrence by and sum from to :
-
Rewrite each side. The left side is . The right side is .
-
So: .
-
Solve for :
This is the generating function for the Fibonacci numbers. The next step is extracting a closed form from it.

Another example: , ,
Following the same steps, you'd arrive at:
The denominator factors as , which sets up nicely for partial fractions.
Manipulating generating functions
Algebraic operations on generating functions
Once you have a generating function, algebraic operations on correspond to specific operations on the underlying sequence:
- Addition/Subtraction: If encodes and encodes , then encodes . Term-by-term.
- Multiplication by : Shifts the sequence by positions (prepends zeros).
- Multiplication of two generating functions: Produces the convolution of the two sequences. The coefficient of in is .
- Differentiation: , so . Differentiation effectively multiplies the th coefficient by .
- Integration: , which divides each coefficient by and shifts the sequence.
Useful identities to recognize
- (the central binomial coefficients)
- The generating function for Catalan numbers:
Recognizing when your matches one of these forms lets you read off the coefficients directly.
Extracting coefficients from generating functions
Getting is only half the job. You still need to pull out , the coefficient of .

Methods for coefficient extraction
Direct expansion. If is a known generating function (like ), you can read off the coefficients using the corresponding formula.
Partial fraction decomposition. This is the most common method for rational generating functions (where is a ratio of polynomials). You decompose into simpler fractions, each of which corresponds to a recognizable series. See the next section for details.
Binomial series expansion. For generating functions involving fractional or negative exponents, use the generalized binomial theorem:
$$$(1+x)^\alpha = \sum_{n=0}^{\infty} \binom{\alpha}{n} x^n$$
where .
For example, extracting the coefficient of from gives .
Taylor expansion. When other methods don't apply cleanly, you can compute derivatives: . This is rarely practical for finding a general closed form, but it's useful for computing specific terms.
Partial fraction decomposition for recurrence relations
Partial fractions are the workhorse for extracting closed-form solutions from rational generating functions. If is a ratio of polynomials and the degree of the numerator is less than the degree of the denominator, you can decompose it.
The method
- Factor the denominator of completely.
- Write the partial fraction form. For distinct linear factors , write:
-
Solve for the constants by clearing denominators and comparing coefficients (or plugging in convenient values of ).
-
Expand each fraction as a geometric series: .
-
Read off the closed form:
-
Verify by checking the initial conditions and substituting back into the recurrence.
Special cases
- Repeated roots. If the denominator has a factor , the decomposition includes terms . The expansion of involves , so the closed form will include polynomial factors multiplied by .
- Complex conjugate roots. These arise from irreducible quadratic factors. The resulting terms can be rewritten using trigonometric functions (sines and cosines with specific amplitudes and phases), though this is less common in introductory problems.
Worked example: , ,
- Deriving the generating function (following the earlier process) gives:
-
Factor the denominator: .
-
Decompose:
Clearing denominators: .
Setting : , so .
Setting : , so .
- So , and expanding:
- Check: ✓, ✓, ✓.
This same approach works for any linear recurrence with constant coefficients, as long as you can factor the denominator. The generating function method and the characteristic equation method will always give the same answer, but generating functions generalize more easily to non-constant-coefficient and non-homogeneous recurrences.