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).A generating function is "a clothesline on which we hang up a sequence of numbers for display" (Wilf). Formally, given a sequence , its ordinary generating function is the formal power series , and its exponential generating function is . They matter because combinatorial relations among sequences become closed-form algebraic relations among their generating functions: a hard counting problem becomes power-series algebra. The surprising fact is that we often never need convergence — the series is treated formally as a bookkeeping device — yet the same object can be analyzed as a genuine analytic function to extract precise asymptotics. The choice between OGF and EGF is dictated by whether the objects being counted are unlabeled (OGF) or labeled (EGF).
The Core Insight
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
Ordinary Generating Function (OGF)
For a sequence of real or complex numbers, its ordinary generating function is the formal power series
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.
Exponential Generating Function (EGF)
For a sequence , its exponential generating function is
The factor is exactly what is needed so that multiplying two EGFs counts ways to interleave labels of two labeled structures.
The Two Convolutions
The defining algebraic properties. If as OGFs, and as EGFs, then
Operational Dictionary
Let . The following equivalences hold in :
For EGFs, differentiation shifts:
Why It Holds / Derivation
The geometric series and partial fractions, the master tools
Step 1 — The fundamental OGF. Consider . In , because all terms cancel telescopically. HenceSolving for yields a rational function . Step 4 — Partial fractions. Factor the denominator and write . By [8], . This is the closed form.
Leonhard Euler | 1707–1783
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.
OGF vs EGF: the two convolution products
Worked Examples
Fibonacci numbers via OGF
Given: . Find a closed form. Step 1. Let . Using the recurrence (template [10] with ):Counting set partitions / derangements via EGF
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: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
- Algorithm analysis. Average-case complexity of Quicksort, hashing, and tries is computed by setting up an EGF/OGF recurrence and extracting coefficients (Knuth, TAOCP; Flajolet–Sedgewick).
- Probability — moment & probability generating functions. (a PGF, an OGF) turns sums of independent random variables into products; and branching-process extinction probabilities are fixed points of .
- Coding theory. Weight enumerators of error-correcting codes are generating polynomials; the MacWilliams identity relates a code's enumerator to its dual's.
- Statistical mechanics. The grand partition function is literally an OGF in the fugacity ; thermodynamic quantities are its log-derivatives.
- Population genetics & queueing theory. Birth–death and queue state probabilities are solved through generating-function transforms of the balance equations.
- Signal processing. The -transform is an OGF of a discrete signal; system poles are the partial-fraction roots.
- Computational biology. RNA secondary-structure counting and sequence-alignment statistics use OGF recurrences (Catalan-like dynamic programming).
Historical Development
- 1730s–1748 — Euler introduces generating functions for integer partitions; proves the Pentagonal Number Theorem and the product formula for .
- 1751 — Euler studies the Catalan numbers via the polygon-triangulation generating function .
- 1812 — Laplace, in Théorie analytique des probabilités, develops the fonction génératrice as a central tool of probability; the Laplace transform is its continuous analogue.
- 1830s–1850s — Cayley and Sylvester use generating functions in invariant theory and tree enumeration.
- 1889 — Cayley's formula for labeled trees; later given EGF proofs via the tree function .
- 1927 — George Pólya's enumeration theorem (cycle index series) systematizes counting under symmetry — a deep OGF construction.
- 1973 — Foata & Schützenberger's combinatorial theory of formal power series cements the formal viewpoint.
- 1981 — André Joyal introduces the theory of species, giving EGFs a rigorous categorical foundation.
- 1990 — Herbert Wilf publishes generatingfunctionology, the standard undergraduate text; 2009 — Flajolet & Sedgewick's Analytic Combinatorics unifies the symbolic and asymptotic theory.