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

1
⟳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.

Exponential Generating Function (EGF)

For a sequence , its exponential generating function is

2
⟳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 Two Convolutions

The defining algebraic properties. If as OGFs, and as EGFs, then

3
⟳Multiply and collect the coefficient of over all .
4
⟳The coefficient of in is .

Operational Dictionary

Let . The following equivalences hold in :

5
⟳First: drop and divide by to shift indices down by one. Second: differentiate term-by-term () and multiply by .
6
⟳Partial-sum sequence is the convolution of with the constant sequence , whose OGF is .

For EGFs, differentiation shifts:

7
⟳, so differentiation maps the EGF of to the EGF of .

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. Hence
8
⟳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
9
⟳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 :
10
⟳ 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.

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

Multiplying generating functions = convolving sequences OGF product A(x)B(x) cₙ = Σ aₖ bₙ₋ₖ split n into k + (n−k) EGF product Â(x)B̂(x) cₙ = Σ C(n,k) aₖ bₙ₋ₖ choose which k labels go left unlabeled / positional labeled / permutational 1/(1−x) = Σ xⁿ ↔ eˣ = Σ xⁿ/n! "all-ones" OGF "all-ones" EGF SEQ construction (OGF) ↔ SET construction (EGF)

Worked Examples

Fibonacci numbers via OGF

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: . ✓

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:
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

  1. 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).
  2. 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 .
  3. Coding theory. Weight enumerators of error-correcting codes are generating polynomials; the MacWilliams identity relates a code's enumerator to its dual's.
  4. Statistical mechanics. The grand partition function is literally an OGF in the fugacity ; thermodynamic quantities are its log-derivatives.
  5. Population genetics & queueing theory. Birth–death and queue state probabilities are solved through generating-function transforms of the balance equations.
  6. Signal processing. The -transform is an OGF of a discrete signal; system poles are the partial-fraction roots.
  7. 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.

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

Before this

Where this leads