Generating Functions — Ordinary and Exponential
Generating functions encode a sequence as the coefficients of a formal power series. The ordinary generating function (OGF) is ; the exponential generating function (EGF) is . They convert combinatorial operations (sums, shifts, products, compositions) into algebraic operations, letting you solve recurrences, count structures, and prove identities. Core toolkit of combinatorics; popularized by Euler (18th c.) and Wilf's generatingfunctionology (1990).
Translate operations on sequences into operations on functions.
- Shifting a sequence ↔ multiplying/dividing by .
- Adding sequences ↔ adding functions.
- The convolution of two sequences ↔ the product of their OGFs.
- The binomial convolution of two sequences ↔ the product of their EGFs.
- Combinatorial constructions (union, pairing, sequence-of, set-of) ↔ sum, product, , .
Once you know the dictionary, counting reduces to algebra and calculus.
Formal Statement
For a sequence of real or complex numbers, its ordinary generating function is the formal power series
Derivation hint: Definitional — , the coefficient of . The symbol is a formal indeterminate; no value is substituted unless convergence is invoked. Here denotes "the coefficient of in ." The set of all formal power series over a field , denoted , forms a commutative ring under coefficientwise addition and Cauchy-product multiplication.
For a sequence , its exponential generating function is
Derivation hint: Definitional — . The weight is chosen so that products of EGFs implement binomial (labeled) convolution. The factor is exactly what is needed so that multiplying two EGFs counts ways to interleave labels of two labeled structures.
The defining algebraic properties. If as OGFs, and as EGFs, then
Derivation hint: Multiply and collect the coefficient of over all .
Derivation hint: The coefficient of in is .
Let . The following equivalences hold in :
Derivation hint: First: drop and divide by to shift indices down by one. Second: differentiate term-by-term () and multiply by .
Derivation hint: Partial-sum sequence is the convolution of with the constant sequence , whose OGF is . For EGFs, differentiation shifts:
Derivation hint: , so differentiation maps the EGF of to the EGF of .
Why It Holds / Derivation
Step 1 — The fundamental OGF. Consider . In , because all terms cancel telescopically. Hence
Derivation hint: Multiply by ; the coefficient of for is , and the constant term is .
Step 2 — Scaling and the negative binomial. Substituting gives . Differentiating times and normalizing gives
Derivation hint: Apply to [8]; the -th derivative of is , and term-by-term it produces .
Step 3 — Solving a linear recurrence (template). Suppose for . Multiply by , sum over :
Derivation hint: and ; substitute and isolate . Solving for yields a rational function . Step 4 — Partial fractions. Factor the denominator and write . By [8], . This is the closed form.
∎Euler was the first to wield generating functions as a systematic instrument. In Introductio in analysin infinitorum (1748) he used them to study partitions of integers, deriving the product formula as the OGF for the partition function , and discovering the Pentagonal Number Theorem . He treated power series with fearless formal manipulation, anticipating modern formal-power-series rigor by two centuries. His genius lay in seeing that an infinite catalogue of combinatorial facts could be compressed into a single analytic expression and then operated upon.
Building Intuition
Think of a generating function as a single object holding an entire sequence, where the variable is a "tag" marking position . Multiplication by pushes every tag up by one — a shift. Multiplying two OGFs is like asking: in how many ways can I split a budget of size between two activities? That is exactly the convolution . The EGF's has a precise meaning. If you are counting labeled objects on (graphs, permutations, set partitions), then combining a structure on a -subset with a structure on the complementary -subset requires choosing which labels go where — the in [4]. The weights bake this choosing directly into the product. Rule of thumb: unlabeled/positional ⟶ OGF; labeled/permutational ⟶ EGF.
Worked Examples
Given: . Find a closed form.
Step 1. Let . Using the recurrence (template [10] with ):
Step 2. Solve: .
Step 3. Factor where , . Partial fractions:
Step 4. Read off coefficients with [8]:
Check: . ✓
Given: = number of permutations of labeled items with no fixed point (derangements). A permutation decomposes into fixed points (each a singleton) and a derangement of the rest:
This is a binomial convolution [4] of with the all-ones sequence.
Step 1. In EGF language: , i.e. .
Step 2. Solve: .
Step 3. Multiply the series and ; the coefficient of is . Then :
Check: . ✓ And .
Common Misconceptions
Convergence is not required for formal manipulation. The series has radius of convergence , yet it is a perfectly legitimate element of and can be added, multiplied, and differentiated formally. Convergence is only needed when you substitute a number for or extract asymptotics via complex analysis. Conversely, you may NOT freely substitute to "sum a sequence" unless the series actually converges there.
Do not confuse OGF and EGF coefficients. From an OGF, . From an EGF, — forgetting the is the single most common error.
Naively using the OGF product for labeled objects fails. Suppose you count labeled structures and try the ordinary product. The number of ways to 2-color the labels of (each element either red or blue) is . Its EGF is — correct. If you instead used the OGF product , you would get , the count of unlabeled compositions into two parts — a completely different, wrong answer for the labeled problem. The mismatch is precisely the missing choices of label placement.
Connections
Generating functions sit at the crossroads of several areas. Solving Linear Recurrence Relations becomes routine partial-fraction extraction. The Symbolic Method in Combinatorics (Flajolet–Sedgewick) systematizes the OGF/EGF dictionary into "admissible constructions" — SEQ, SET, CYC, MSET — translating combinatorial classes directly into functional equations. The EGF formalism is the analytic shadow of Species of Structures (Joyal), a category-theoretic foundation for labeled enumeration. Extracting asymptotically from a generating function is the subject of Analytic Combinatorics, using Cauchy's Integral Formula and singularity analysis. The Binomial Theorem and Catalan Numbers both fall out as special cases, and the multiplicative structure on Dirichlet series mirrors the OGF story for number-theoretic functions.
Real-World Applications
Historical Development
Subtleties & Limits
When does a generating function have a "nice" closed form? A power series is D-finite (holonomic) if it satisfies a linear ODE with polynomial coefficients — equivalently its coefficients are P-recursive. Algebraic ⊂ D-finite, but many natural sequences are non-holonomic, and deciding holonomicity for a combinatorially defined class can be subtle. A deeper question: for a given lattice-walk model in a quadrant, when is the OGF algebraic, D-finite, or neither? The Bousquet-Mélou–Mishna classification (2010) resolved the 79 small-step quadrant models using a group-of-the-walk invariant, but extensions to higher dimensions, weighted steps, and three-quarter-plane walks remain active research. Separately, effective asymptotics from generating functions (transfer theorems, multivariate singularity analysis) is well developed for meromorphic/algebraic singularities but still open in full generality for functions with complicated singular structure.
See Also
Catalan Numbers · Partition Function (Number Theory) · Pólya Enumeration Theorem · Formal Power Series · Dirichlet Series · Bell Numbers · Stirling Numbers