A generating function is a mathematical expression that represents a sequence by placing its terms in the coefficients of a series. The most common form associates a sequence with the power series . Operations on this single expression translate into operations on the sequence, making generating functions important tools in combinatorics, probability theory, and the analysis of algorithms. Depending on the purpose, the series can be treated as a purely formal algebraic object or as a convergent function. (aofa.cs.princeton.edu)
Definition and interpretation
The ordinary generating function (OGF) of a sequence is
The notation means “the coefficient of in ,” so that . For a counting sequence, the exponent records an object's size and the coefficient records how many objects have that size. A finite sequence gives a polynomial, with subsequent coefficients understood to be zero. (aofa.cs.princeton.edu)
For example, the sequence has generating function
using the geometric series identity. Likewise,
These compact expressions retain every coefficient of the original sequences. (aofa.cs.princeton.edu)
Formal and analytic viewpoints
A formal power series is specified by its coefficients, without requiring numerical convergence. Equality means coefficient-by-coefficient equality. Over a field, a formal series has a multiplicative inverse precisely when its constant coefficient is nonzero. Thus is meaningful formally, independently of whether a numerical value is assigned to . (math.cmu.edu)
The distinction matters for rapidly growing sequences. The series
has radius of convergence zero, but remains a valid formal generating function. If a series does converge near zero, methods of complex analysis become available, including coefficient extraction through contour integration and estimates based on singularities. (math.cmu.edu)
Algebraic operations
Let and . Their operations have direct coefficient interpretations:
| Operation | Coefficient interpretation |
|---|---|
| Termwise addition: | |
| , | Shift by positions, inserting initial zeros |
| Weight the -th term by | |
| Partial sums: |
Multiplication therefore implements discrete convolution, while taking a derivative implements index-dependent weighting. These rules explain why relations involving sums and shifts often become simpler equations for generating functions. (math.cmu.edu)
Main types
Exponential generating functions
The exponential generating function (EGF) of a sequence is
where is the factorial. For the constant sequence , the EGF is the exponential function , rather than . (aofa.cs.princeton.edu)
EGFs are especially useful for counting structures on distinct labels. Their product encodes
The binomial coefficient chooses which labels belong to the first component. This distinguishes labelled products from ordinary products, which do not include that allocation factor. (aofa.cs.princeton.edu)
Multivariate generating functions
A generating function can record several parameters:
Here might mark size and a secondary statistic, such as the number of leaves in a tree. When the substitution is well-defined, counts objects by size alone. Differentiating with respect to weights objects by their secondary statistic, allowing averages and higher moments to be recovered. (ac.cs.princeton.edu)
Other generating series
Other coefficient encodings suit different operations. A Dirichlet generating series,
is useful in number theory because multiplication combines indices through divisors rather than addition:
Choosing a generating series is therefore partly a choice of which sequence operations should become multiplication, differentiation, or another simple transformation. (math.cmu.edu)
Solving recurrence relations
Generating functions turn many recurrence relations into algebraic or differential equations. The usual procedure is to multiply the recurrence by , sum over its valid indices, account for initial terms, and solve the resulting equation. (aofa.cs.princeton.edu)
For the Fibonacci sequence, take
Writing gives
hence
Factoring the denominator and expanding its partial fractions yields an explicit expression for . The initial conditions are essential: the recurrence alone does not determine the numerator. (math.mit.edu)
Counting combinatorial structures
Generating functions express ways of building objects. Disjoint alternatives correspond to addition; ordered pairs of components, with sizes added, correspond to multiplication. If counts components and , arbitrary finite sequences of components have generating function
The condition excludes zero-size components, which could otherwise produce infinitely many sequences of a fixed size. (aofa.cs.princeton.edu)
A classical example is the Catalan numbers, which count ordered full binary trees by their number of internal nodes. A tree is either a single leaf or an internal root with two subtrees, giving
Selecting the solution with constant coefficient gives
The first coefficients are . This illustrates how a recursive structural description becomes an equation and then a counting formula. (aofa.cs.princeton.edu)
Probability generating functions
For a random variable taking nonnegative integer values, its probability generating function is
Its coefficients form the probability mass function. For a binomial distribution with parameters and ,
The coefficient of is the probability of exactly successes. (math.mit.edu)
Differentiation generates factorial moments:
When the relevant moments are finite, the mean and variance follow from
Generating-function representations also support exact inference for some discrete probabilistic models. (math.cmu.edu)
Analytic methods and limitations
Analytic combinatorics connects structural counting equations with analytic properties of their generating functions. Singularities can determine both exponential growth and polynomial corrections in the coefficients. For example, the square-root singularity in the Catalan generating function leads to
Here means that the ratio of the two expressions tends to . General singularity-transfer results require appropriate analyticity conditions; knowing only the radius of convergence is not enough to determine a full asymptotic formula. (aofa.cs.princeton.edu)
Encoding a sequence does not guarantee an easily usable closed form. An equation for its generating function may be harder to solve than the original recurrence, and extracting coefficients can remain difficult. Formal manipulations also do not automatically justify numerical substitutions or analytic arguments: convergence must be established separately. The usefulness of the method depends on matching the series type and its operations to the structure of the problem. (math.cmu.edu)
The modern subject combines formal series algebra, combinatorial construction rules, and complex-analytic estimates. Herbert S. Wilf's generatingfunctionology, first published in 1990, presents these techniques through sequence and counting problems; Philippe Flajolet and Robert Sedgewick's Analytic Combinatorics develops the systematic connection between combinatorial specifications and asymptotic analysis. (www2.math.upenn.edu)
References
- Generating Functionsaofa.cs.princeton.edu
- Generating Function Notesmath.mit.edu
- generatingfunctionologymath.cmu.edu
- Generating Functions lecture slidesaofa.cs.princeton.edu
- Analytic Combinatoricsaofa.cs.princeton.edu
- Analytic Combinatorics — Philippe Flajolet and Robert Sedgewickac.cs.princeton.edu
- Exact Bayesian Inference on Discrete Models via Probability Generating Functions: A Probabilistic Programming Approacharxiv.org
- Download generatingfunctionologywww2.math.upenn.edu