Introduction
A generating function packs an entire sequence into one power series. Algebra on the series (adding, multiplying, shifting, differentiating) then corresponds to combinatorial operations on the sequence. This gives a uniform way to count selections with constraints ("how many ways to make 25 rupees from 1, 2 and 5 rupee coins?") and to solve recurrence relations. The working tasks are finding the sequence of a given generating function, the generating function of a given sequence, or a single coefficient.
Prerequisites
- Counting: binomial coefficients, combinations with repetition, stars and bars.
- Recurrence Relations: linear recurrences and initial conditions.
- Geometric series and partial fractions.
Core concepts
Definition
The (ordinary) generating function (OGF) of the sequence is the formal power series
is a placeholder: we manipulate the series formally and do not need it to converge. When a closed form like is used, it means the series whose product with is 1. The coefficient of in is written .
A finite sequence has a polynomial generating function: the sequence has .
Standard generating functions
| Sequence () | Generating function |
|---|---|
| = | |
| (first terms), then 0 | |
The row is the extended binomial theorem: the coefficient of is the number of multisets of size from types, the stars-and-bars count.
Operations
If and :
| Operation on series | Effect on sequence |
|---|---|
| shift right: ( zeros) | |
| shift left: | |
| partial sums | |
| convolution |
The product rule is the key counting fact: if counts ways to choose items of one kind and ways to choose items of another, then counts ways to choose items in total.
Counting with generating functions
To count selections of objects from several types, write one factor per type, listing the allowed quantities as powers of , multiply, and read off .
Example: coins. Ways to pay rupees with any number of 1 and 2 rupee coins (order irrelevant):
Example: bounded quantities. Ways to choose 6 fruits with at most 2 apples, at least 1 banana, and any number of cherries:
of is 6 (sequence ), so of the product is .
Example: dice. The number of ways to roll a total of 10 with three six-sided dice is the coefficient of in , which is the coefficient of in . Expanding and using (coefficients ): .
Example: a parity constraint. Non-negative integer solutions of with even: the generating function is . Choosing (even) leaves solutions for , so the coefficient of is .
Solving recurrences
Procedure.
- Multiply the recurrence by and sum over all for which it holds.
- Express every sum through , using shifts; insert the initial conditions.
- Solve the resulting equation for .
- Split into partial fractions and read off from the standard table.
Example 1: first order
for , .
Check: .
Example 2: Fibonacci
for , , . The same steps give
Factoring with and splitting into partial fractions yields Binet's formula .
Example 3: reading a sequence from a function
Find for . Partial fractions: , so . Equivalently is divided by : partial sums of , which are .
Example 4: Catalan numbers
The recurrence , , is a convolution, so . Solving the quadratic and choosing the root that is finite at :
Exponential generating functions (for reference)
The exponential generating function (EGF) of is . EGFs suit labelled structures (including linear orders on labelled objects), because the product of EGFs counts ways to split a set of labels between two structures (). Examples: the EGF of is ; permutations () have EGF ; derangements have EGF .
Important properties and observations
- Generating functions are formal: equal series have equal coefficients, so comparing coefficients is always valid.
- is the key coefficient formula.
- A rational generating function with corresponds exactly to a sequence satisfying a linear recurrence with constant coefficients, read from . For , the recurrence is for large enough .
- The reciprocals of the roots of are the roots of the characteristic equation of that recurrence.
GATE examination perspective
- Sequence from function. Expand with the standard table and partial fractions; check and directly by series expansion.
- Function from sequence. Recognise shifts and scalings of the table entries (for example has ).
- Coefficient extraction. Products of geometric series for bounded counting; for "at most ".
- Trap: off-by-one in shifts: gives , gives .
- Trap: the generating function equation must use the recurrence only for the where it holds; the initial terms enter separately.
Summary
Sources
- K. H. Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012: Section 8.4 (Generating Functions).
- H. S. Wilf, generatingfunctionology, 2nd ed., Academic Press, 1994: Chapters 1 (Introductory ideas and examples) and 2 (Series). The author offers the second edition free on his download page, (consulted 2026-11-11).