Ordinary Generating Functions

How many ways can you make change for a dollar using pennies, nickels, dimes, and quarters? How many sequences of coin flips of length nn avoid two consecutive heads? Both questions are counting problems in disguise. Both dissolve almost effortlessly once the counting sequence is repackaged. That repackaging turns it into a single algebraic object: a formal power series whose coefficients are the numbers we want. This repackaging is the ordinary generating function, one of the most powerful ideas in enumerative combinatorics. The idea matters because it converts combinatorial operations into algebraic operations on power series. Choosing, arranging, splitting into parts, restricting counts — all become addition, multiplication, substitution, and differentiation. A combinatorial construction that would require an intricate inductive argument or a clever bijection often becomes simple. It becomes a two-line computation with power series. After that, a closed form or an asymptotic estimate can be extracted. This is done by standard algebraic manipulation, such as partial fractions. The big picture is this. A sequence (an)n≥0(a_n)_{n \ge 0} of numbers and a formal power series A(x)=∑n≥0anxnA(x) = \sum_{n \ge 0} a_n x^n carry exactly the same information. But the series form supports operations that have no easy description on the sequence level. For example, multiplying two series corresponds to a specific convolution of the sequences. Generating functions turn a "sequence problem" into a "function problem." There, the immense toolkit of algebra becomes available, and later, complex analysis too. This article develops the ordinary generating function rigorously. It covers the formal definition as an element of a power series ring, with no convergence required. It covers the algebra of sums, products, and compositions. It covers the product rule for combinatorial classes built by disjoint union and Cartesian product. It also gives a full worked derivation of the generating function for linear recurrences and for Combinations with Repetition. It closes with the machinery's reach toward Exponential Generating Functions, Catalan Numbers, and Integer Partitions.

Key takeaways
  • An ordinary generating function (OGF) for (an)n≥0(a_n)_{n\ge0} is the formal power series A(x)=∑n≥0anxnA(x)=\sum_{n\ge 0}a_n x^n; convergence is irrelevant.
  • OGFs are elements of the ring of formal power series R[[x]]\mathbb{R}[[x]], with addition and multiplication defined coefficientwise/by convolution.
  • The Product Rule: if a combinatorial object decomposes uniquely into an ordered pair of independent pieces, the OGF of the whole is the product of the OGFs of the pieces.
  • Multiplying by 11−x\frac{1}{1-x} takes partial sums; multiplying two OGFs computes a convolution — this is the algebraic engine behind almost every application.
  • Rational OGFs (ratios of polynomials) correspond exactly to sequences satisfying a linear recurrence with constant coefficients, extractable via Partial Fractions.
  • Key idea: encode a whole sequence as one formal power series, so combinatorial constructions become algebraic operations on that series.

Where this lives today

Ordinary generating functions are the working language of enumerative combinatorics: counting lattice paths, set partitions, compositions of integers, and the coefficients of the Catalan Numbers (via the quadratic equation C(x)=1+xC(x)2C(x) = 1 + xC(x)^2) all reduce to algebraic manipulation of an OGF. In Integer Partitions, infinite products such as ∏k(1−xk)−1\prod_k (1-x^k)^{-1} generate the partition function p(n)p(n), and Euler's pentagonal number theorem is proved by manipulating the reciprocal product. In computer science, OGFs analyze the running time of divide-and-conquer algorithms whose recurrences (e.g. T(n)=2T(n/2)+nT(n) = 2T(n/2) + n in disguise, or more directly integer sequence recurrences) are solved exactly as in Example 2 above, and they underlie automatic complexity analysis in the "symbolic method" of analytic combinatorics. In probability and statistics, OGFs specialize to probability generating functions E[xX]=∑kP(X=k)xk\mathbb E[x^X] = \sum_k P(X=k)x^k, whose derivatives at x=1x=1 recover moments and whose products encode independence of sums of random variables. In cryptography and coding theory, generating functions count weight distributions of linear codes and track the structure of feedback shift registers. In physics, OGFs (and their exponential cousins) organize partition functions in statistical mechanics, where the formal variable becomes a fugacity or Boltzmann weight — a direct descendant of Euler's original partition-counting insight.

:::quiz[If A(x)A(x) is the OGF of (an)(a_n) with a0≠0a_0 \ne 0, when does A(x)A(x) have a multiplicative inverse in R[[x]]\mathbb R[[x]]?]

  • Never, formal power series are never invertible
  • Only if A(x)A(x) is a polynomial
  • Always, precisely because a0≠0a_0 \ne 0 ✓
  • Only if all an>0a_n > 0

Ask the tutor: How does the functional equation C(x)=1+xC(x)2C(x) = 1 + xC(x)^2 for the Catalan numbers get derived and solved using the Product Rule?

DefinitionOrdinary Generating Function

Let (an)n≥0=(a0,a1,a2,… )(a_n)_{n\ge0} = (a_0, a_1, a_2,\dots) be a sequence of real (or complex) numbers. The ordinary generating function (OGF) of this sequence is the formal power series

A(x)  =  ∑n=0∞anxn  =  a0+a1x+a2x2+⋯ .A(x) \;=\; \sum_{n=0}^{\infty} a_n x^n \;=\; a_0 + a_1 x + a_2 x^2 + \cdots.

Here xx is a formal indeterminate: A(x)A(x) is regarded as an element of the ring R[[x]]\mathbb{R}[[x]] of formal power series, i.e. as the sequence of coefficients (a0,a1,a2,… )(a_0,a_1,a_2,\dots) itself, packaged with a bookkeeping device that tracks the "weight" (or size) nn of each term. No claim is made, or needed, about whether the series converges for any nonzero value of xx. Two formal power series A(x)=∑anxnA(x)=\sum a_n x^n and B(x)=∑bnxnB(x) = \sum b_n x^n are equal iff an=bna_n = b_n for every n≥0n \ge 0. Addition and multiplication are defined by

A(x)+B(x)=∑n≥0(an+bn) xn,A(x)B(x)=∑n≥0(∑k=0nakbn−k)xn.A(x) + B(x) = \sum_{n\ge 0} (a_n + b_n)\, x^n, \qquad A(x) B(x) = \sum_{n \ge 0} \left(\sum_{k=0}^{n} a_k b_{n-k}\right) x^n.

The multiplication rule is called the Cauchy product or convolution of the two sequences. With these operations, R[[x]]\mathbb{R}[[x]] is a commutative ring with identity 1=1+0x+0x2+⋯1 = 1 + 0x + 0x^2 + \cdots, and A(x)A(x) has a multiplicative inverse in R[[x]]\mathbb{R}[[x]] if and only if a0≠0a_0 \ne 0.

Intuition

Think of A(x)=∑anxnA(x) = \sum a_n x^n as a clothesline: the exponent nn is a peg, and ana_n is the item hanging from it. The variable xx carries no numeric meaning by itself; its powers are just labels that keep the sequence's terms from getting mixed up. This is why we can add and multiply these objects with total disregard for convergence — a formal power series is really just a sequence with a multiplication rule attached, and the notation ∑anxn\sum a_n x^n is a convenient way to remember which coefficient goes where. The convolution formula is the heart of every application. If A(x)A(x) counts the number of ways, ana_n, to build an object of "size" nn from parts of type-1, and B(x)B(x) counts ways bnb_n to build a size-nn object from parts of type-2, then the coefficient of xnx^n in A(x)B(x)A(x)B(x) is ∑k=0nakbn−k\sum_{k=0}^n a_k b_{n-k}: the number of ways to split nn into a type-1 piece of size kk and a type-2 piece of size n−kn-k, and build each piece independently. This is exactly the count of ordered pairs (type-1 object, type-2 object) whose sizes sum to nn — the combinatorial content behind the algebra. A second key move is division by 1−x1-x. Since 11−x=∑n≥0xn\frac{1}{1-x} = \sum_{n\ge0} x^n formally (check: (1−x)∑n≥0xn=∑n≥0xn−∑n≥0xn+1=1(1-x)\sum_{n\ge0}x^n = \sum_{n\ge 0}x^n - \sum_{n\ge0}x^{n+1} = 1), multiplying any A(x)A(x) by 11−x\frac{1}{1-x} replaces each coefficient ana_n by the partial sum a0+a1+⋯+ana_0+a_1+\cdots+a_n. This single algebraic fact recovers, instantly, formulas that would otherwise need induction.

Figure
Convolution: splitting size n=4n=4 between two independent constructions
Coefficient of x⁴ in A(x)·B(x) = Σ a_k b_(4−k) k=0:a₀·b₄ k=1:a₁·b₃ k=2:a₂·b₂ k=3:a₃·b₁ k=4:a₄·b₀ Every split k + (4−k) = 4 is counted exactly once.

Central results

TheoremProduct Rule for Combinatorial Classes

Let C\mathcal{C} be a set of combinatorial objects equipped with a size function ∣⋅∣:C→Z≥0|\cdot|: \mathcal{C} \to \mathbb{Z}_{\ge 0} such that for every n≥0n \ge 0 the number

cn=#{ γ∈C:∣γ∣=n }c_n = \#\{\, \gamma \in \mathcal{C} : |\gamma| = n \,\}

is finite. Suppose C\mathcal{C} is in size-preserving bijection with the Cartesian product A×B\mathcal{A} \times \mathcal{B} of two such classes, where the size function on A×B\mathcal{A}\times\mathcal{B} is defined by

∣(α,β)∣=∣α∣+∣β∣for all (α,β)∈A×B,|(\alpha,\beta)| = |\alpha| + |\beta| \quad \text{for all } (\alpha,\beta) \in \mathcal A\times\mathcal B,

and where A\mathcal A and B\mathcal B each have finitely many objects of every size (so their counting sequences an, bna_n,\,b_n and OGFs A(x), B(x)A(x),\,B(x) are well defined). Then the OGF of C\mathcal C is

C(x)=A(x) B(x).C(x) = A(x)\, B(x).

More generally, if C=A⊔B\mathcal C = \mathcal A \sqcup \mathcal B is a disjoint union with the size function restricting on each part to the given one, then C(x)=A(x)+B(x)C(x) = A(x) + B(x).

Proof

Proof technique: direct computation of coefficients via bijection and Fubini-type counting (rearranging a finite double sum).

Disjoint union. If C=A⊔B\mathcal C = \mathcal A \sqcup \mathcal B (disjoint as sets), then every object of size nn in C\mathcal C lies in exactly one of A\mathcal A or B\mathcal B, so

cn=#{γ∈C:∣γ∣=n}=#{α∈A:∣α∣=n}+#{β∈B:∣β∣=n}=an+bn,c_n = \#\{\gamma \in \mathcal C : |\gamma|=n\} = \#\{\alpha \in \mathcal A : |\alpha|=n\} + \#\{\beta \in \mathcal B : |\beta| = n\} = a_n + b_n,

using that the two sets {γ∈C:∣γ∣=n}∩A\{\gamma \in \mathcal C : |\gamma|=n\} \cap \mathcal A and ∩ B\cap\,\mathcal B partition {γ∈C:∣γ∣=n}\{\gamma\in\mathcal C:|\gamma|=n\} with no overlap. Summing cnxnc_n x^n over nn termwise gives C(x)=∑ncnxn=∑nanxn+∑nbnxn=A(x)+B(x)C(x) = \sum_n c_n x^n = \sum_n a_n x^n + \sum_n b_n x^n = A(x)+B(x), where termwise addition of formal power series is legitimate because equality of formal series means equality coefficient by coefficient, which we have just shown.

Cartesian product. Since C\mathcal C is in size-preserving bijection with A×B\mathcal A \times \mathcal B, it suffices to prove the claim for C=A×B\mathcal C = \mathcal A\times \mathcal B itself, because a size-preserving bijection carries objects of size nn to objects of size nn and hence preserves the counting sequence exactly: cn=#{(α,β)∈A×B:∣α∣+∣β∣=n}c_n = \#\{(\alpha,\beta)\in\mathcal A\times \mathcal B : |\alpha|+|\beta| = n\}. Fix n≥0n \ge 0. Partition the finite set {(α,β)∈A×B:∣α∣+∣β∣=n}\{(\alpha,\beta) \in \mathcal A \times \mathcal B : |\alpha|+|\beta|=n\} according to the value k=∣α∣∈{0,1,…,n}k = |\alpha| \in \{0,1,\dots,n\} (note k≤nk \le n since ∣β∣≥0|\beta|\ge 0, and n−k≥0n - k \ge 0 similarly). For fixed kk, the objects α\alpha with ∣α∣=k|\alpha|=k number aka_k, and the objects β\beta with ∣β∣=n−k|\beta| = n-k number bn−kb_{n-k}; by the multiplication principle there are exactly akbn−ka_k b_{n-k} pairs (α,β)(\alpha,\beta) with ∣α∣=k, ∣β∣=n−k|\alpha|=k,\ |\beta|=n-k. These n+1n+1 classes (k=0,…,nk=0,\dots,n) are disjoint and exhaust all pairs of total size nn, so

cn=∑k=0nak bn−k.c_n = \sum_{k=0}^{n} a_k\, b_{n-k}.

This is finite since each ak,bn−ka_k, b_{n-k} is finite by hypothesis and the sum has finitely many (n+1n+1) terms — this finiteness is exactly what was assumed about A,B\mathcal A, \mathcal B having finitely many objects of each size, and it is needed for cnc_n itself to be a well-defined finite count. Now compare with the definition of the Cauchy product: A(x)B(x)=∑n≥0(∑k=0nakbn−k)xnA(x)B(x) = \sum_{n\ge0}\left(\sum_{k=0}^n a_k b_{n-k}\right)x^n. The coefficient of xnx^n in A(x)B(x)A(x)B(x) is exactly ∑k=0nakbn−k=cn\sum_{k=0}^n a_k b_{n-k} = c_n, the coefficient of xnx^n in C(x)C(x). Since this holds for every n≥0n \ge 0, and equality of formal power series is equality of all coefficients, C(x)=A(x)B(x)C(x) = A(x)B(x). ■\blacksquare

∎
CorollaryGeometric series and repeated combination

The all-ones sequence an=1a_n = 1 for all n≥0n\ge 0 has OGF 11−x\dfrac{1}{1-x}, and more generally the sequence an=(n+k−1k−1)a_n = \binom{n+k-1}{k-1} (the number of multisets of size nn from a kk-element set, i.e. Combinations with Repetition) has OGF 1(1−x)k\dfrac{1}{(1-x)^k}.

Proof

Proof technique: telescoping for the base case, then induction using the Product Rule.

Base case k=1k=1: Let A(x)=∑n≥0xnA(x) = \sum_{n\ge0} x^n. Then

(1−x)A(x)=∑n≥0xn−∑n≥0xn+1=(1+∑n≥1xn)−∑n≥1xn=1,(1-x)A(x) = \sum_{n\ge0}x^n - \sum_{n\ge0}x^{n+1} = \left(1 + \sum_{n\ge1}x^n\right) - \sum_{n\ge1}x^n = 1,

where the middle equality reindexes the second sum (m=n+1m = n+1) and the terms ∑n≥1xn\sum_{n\ge1}x^n cancel exactly, term by term, since it is a formal identity (each coefficient of xnx^n for n≥1n\ge1 appears once with +1+1 and once with −1-1, and the constant term is 11). Hence A(x)A(x) is the multiplicative inverse of 1−x1-x in R[[x]]\mathbb{R}[[x]], i.e. A(x)=11−xA(x) = \frac{1}{1-x}. This A(x)A(x) is precisely the OGF of the constant sequence an=1a_n=1, which counts multisets of size nn from a 11-element set (there is exactly one such multiset for each nn), confirming the k=1k=1 case of the general claim, since (n+1−11−1)=(n0)=1\binom{n+1-1}{1-1}=\binom{n}{0}=1.

Inductive step: Suppose the claim holds for kk: the class Mk\mathcal{M}_k of size-nn multisets from a kk-set has OGF (1−x)−k(1-x)^{-k}. A size-nn multiset from a (k+1)(k+1)-element set {1,…,k+1}\{1,\dots,k+1\} is equivalent to a choice of the number of times j≥0j \ge 0 that the element k+1k+1 appears, together with a size-(n−j)(n-j) multiset from {1,…,k}\{1,\dots,k\}; this is a size-preserving bijection between Mk+1\mathcal M_{k+1} and N×Mk\mathcal N \times \mathcal M_k, where N\mathcal N is the class of nonnegative integers jj with size function ∣j∣=j|j|=j (one object of each size, OGF 11−x\frac{1}{1-x} by the base case), because specifying the multiset is equivalent to specifying both pieces independently and the sizes add: ∣j∣+(n−j)=n|j| + (n-j) = n. By the Product Rule, the OGF of Mk+1\mathcal M_{k+1} is

11−x⋅1(1−x)k=1(1−x)k+1.\frac{1}{1-x}\cdot \frac{1}{(1-x)^k} = \frac{1}{(1-x)^{k+1}}.

By induction, the OGF of Mk\mathcal M_k is (1−x)−k(1-x)^{-k} for every k≥1k \ge 1. Finally, the coefficient of xnx^n in (1−x)−k(1-x)^{-k} is (n+k−1k−1)\binom{n+k-1}{k-1}; this is the standard Combinations with Repetition identity, itself provable independently by a stars-and-bars bijection, so the two derivations agree. ■\blacksquare

∎

Worked examples

Example 1: Making change with four coin denominations (an asymmetric convolution). Suppose we have unlimited supplies of pennies (1¢), nickels (5¢), dimes (10¢), and quarters (25¢), and we ask for cnc_n, the number of ways to make exactly nn cents using these coins, where order does not matter (a "way" is a choice of how many of each coin to use). We build the generating function using the Product Rule for four independent choices — how many pennies, how many nickels, how many dimes, how many quarters — whose contributed values must sum to nn. The class of "some number of pennies contributing value vv" has one object for each multiple of 11, so its OGF (in the variable xx tracking value, not count of coins) is 11−x\frac{1}{1-x}. Similarly, a choice of nickels contributing value a multiple of 55 has OGF 11−x5\frac{1}{1-x^5} (one way to contribute value 5j5j for each j≥0j \ge 0, none otherwise); dimes give 11−x10\frac{1}{1-x^{10}}; quarters give 11−x25\frac{1}{1-x^{25}}. By the Product Rule (applied three times, since choices of different coin types are independent and their values add):

C(x)=1(1−x)(1−x5)(1−x10)(1−x25).C(x) = \frac{1}{(1-x)(1-x^5)(1-x^{10})(1-x^{25})}.

To find c100c_{100} — the number of ways to make a dollar — one option is to extract the coefficient via partial fractions or a computer algebra system; here we illustrate the method by computing a smaller, fully explicit case, c30c_{30}, by hand using the structure of the product. Write C(x)=11−x⋅11−x5⋅11−x10⋅11−x25C(x) = \frac{1}{1-x}\cdot \frac{1}{1-x^5}\cdot\frac{1}{1-x^{10}}\cdot\frac{1}{1-x^{25}}. We want [x30]C(x)[x^{30}]C(x). First combine the two "coarse" factors:

1(1−x10)(1−x25)=(∑i≥0x10i)(∑j≥0x25j).\frac{1}{(1-x^{10})(1-x^{25})} = \left(\sum_{i\ge0}x^{10i}\right)\left(\sum_{j\ge0}x^{25j}\right).

The exponents 10i+25j≤3010i+25j \le 30 with i,j≥0i,j\ge0 are: (i,j)=(0,0)→0(i,j)=(0,0)\to 0, (1,0)→10(1,0)\to10, (2,0)→20(2,0)\to20, (3,0)→30(3,0)\to30, (0,1)→25(0,1)\to25. So up to degree 3030,

1(1−x10)(1−x25)≡1+x10+x20+x25+x30(modx31).\frac{1}{(1-x^{10})(1-x^{25})} \equiv 1 + x^{10}+x^{20}+x^{25}+x^{30} \pmod{x^{31}}.

Next we need 1(1−x)(1−x5)\frac{1}{(1-x)(1-x^5)} up to degree 3030; its coefficient of xmx^m is the number of ways to write m=a+5bm = a + 5b with a,b≥0a,b\ge0, i.e. bb ranges over 0,1,…,⌊m/5⌋0,1,\dots,\lfloor m/5\rfloor and aa is determined, so [xm]1(1−x)(1−x5)=⌊m/5⌋+1[x^m]\frac{1}{(1-x)(1-x^5)} = \lfloor m/5\rfloor + 1. Now c30=[x30]C(x)c_{30} = [x^{30}]C(x) is obtained by convolving the coefficient sequence um=⌊m/5⌋+1u_m = \lfloor m/5\rfloor+1 (from pennies+nickels) against the finite sequence vm∈{1 at m=0,10,20,25,30}v_m \in \{1 \text{ at } m=0,10,20,25,30\} (from dimes+quarters), restricted to m≤30m \le 30:

c30=u30+u20+u10+u5+u0,c_{30} = u_{30} + u_{20} + u_{10} + u_{5} + u_{0},

matching m+{0,10,20,25,30}=30m + \{0,10,20,25,30\} = 30, i.e. m=30,20,10,5,0m = 30,20,10,5,0. Compute each: u30=⌊30/5⌋+1=7u_{30}=\lfloor30/5\rfloor+1=7, u20=4+1=5u_{20}=4+1=5, u10=2+1=3u_{10}=2+1=3, u5=1+1=2u_{5}=1+1=2, u0=0+1=1u_0=0+1=1. Sum: 7+5+3+2+1=187+5+3+2+1 = 18. So there are 1818 ways to make 3030 cents from pennies, nickels, dimes, and quarters — a fact one can sanity-check directly (quarters used ∈{0,1}\in\{0,1\}; if 11 quarter, remaining 55 cents needs u5=2u_5=2 ways; if 00 quarters, remaining 3030 cents from pennies/nickels/dimes needs enumerating 10j+u10j+u, matching the computation above), confirming the generating-function method.

Example 2: A linear recurrence with non-constant-free initial data. Let (an)n≥0(a_n)_{n\ge0} satisfy a0=3a_0 = 3, a1=1a_1 = 1, and for n≥2n\ge 2,

an=5an−1−6an−2.a_n = 5a_{n-1} - 6a_{n-2}.

We find a closed form for ana_n using its OGF. Let A(x)=∑n≥0anxnA(x) = \sum_{n\ge0}a_n x^n. Multiply the recurrence by xnx^n and sum over n≥2n\ge2:

∑n≥2anxn=5∑n≥2an−1xn−6∑n≥2an−2xn.\sum_{n\ge2}a_n x^n = 5\sum_{n\ge2}a_{n-1}x^n - 6\sum_{n\ge2}a_{n-2}x^n.

The left side is A(x)−a0−a1x=A(x)−3−xA(x) - a_0 - a_1x = A(x) - 3 - x. On the right, ∑n≥2an−1xn=x∑n≥2an−1xn−1=x∑m≥1amxm=x(A(x)−a0)=x(A(x)−3)\sum_{n\ge2}a_{n-1}x^n = x\sum_{n\ge2}a_{n-1}x^{n-1} = x\sum_{m\ge1}a_m x^m = x(A(x)-a_0) = x(A(x)-3), and ∑n≥2an−2xn=x2∑m≥0amxm=x2A(x)\sum_{n\ge2}a_{n-2}x^n = x^2\sum_{m\ge0}a_m x^m = x^2 A(x). Substituting:

A(x)−3−x=5x(A(x)−3)−6x2A(x).A(x) - 3 - x = 5x\big(A(x)-3\big) - 6x^2 A(x).

Expand and collect A(x)A(x) terms:

A(x)−3−x=5xA(x)−15x−6x2A(x),A(x) - 3 - x = 5xA(x) - 15x - 6x^2A(x),
A(x)(1−5x+6x2)=3+x−15x=3−14x.A(x)\big(1 - 5x + 6x^2\big) = 3 + x - 15x = 3 - 14x.

So

A(x)=3−14x1−5x+6x2=3−14x(1−2x)(1−3x).A(x) = \frac{3 - 14x}{1 - 5x + 6x^2} = \frac{3-14x}{(1-2x)(1-3x)}.

Apply partial fractions: seek A(x)=P1−2x+Q1−3xA(x) = \frac{P}{1-2x} + \frac{Q}{1-3x}. Clearing denominators, 3−14x=P(1−3x)+Q(1−2x)3 - 14x = P(1-3x) + Q(1-2x). Setting x=12x = \tfrac12: 3−7=P(1−32)=−12P3 - 7 = P(1 - \tfrac32) = -\tfrac12 P, so −4=−12P⇒P=8-4 = -\tfrac12 P \Rightarrow P = 8. Setting x=13x = \tfrac13: 3−143=Q(1−23)=13Q3 - \tfrac{14}{3} = Q(1-\tfrac23) = \tfrac13 Q, so 9−143=−53=13Q⇒Q=−5\tfrac{9-14}{3} = -\tfrac53 = \tfrac13 Q \Rightarrow Q = -5. Check the constant term: P+Q=8−5=3P + Q = 8 - 5 = 3, matching the constant term of 3−14x3-14x at x=0x=0 — consistent. So A(x)=81−2x−51−3x=8∑n≥02nxn−5∑n≥03nxnA(x) = \dfrac{8}{1-2x} - \dfrac{5}{1-3x} = 8\sum_{n\ge0}2^n x^n - 5\sum_{n\ge0}3^n x^n, using 11−cx=∑ncnxn\frac{1}{1-cx}=\sum_n c^n x^n (the geometric series with xx replaced by cxcx, valid formally by the same telescoping argument as the Corollary above). Reading off the coefficient of xnx^n:

an=8⋅2n−5⋅3n.a_n = 8\cdot 2^n - 5\cdot 3^n.

Check: a0=8−5=3a_0 = 8-5=3 ✓. a1=16−15=1a_1 = 16 - 15 = 1 ✓. a2=5a1−6a0=5−18=−13a_2 = 5a_1-6a_0 = 5-18=-13; formula gives 8⋅4−5⋅9=32−45=−138\cdot4 - 5\cdot9 = 32-45=-13 ✓. a3=5(−13)−6(1)=−65−6=−71a_3 = 5(-13)-6(1) = -65-6=-71; formula gives 8⋅8−5⋅27=64−135=−718\cdot8-5\cdot27=64-135=-71 ✓. The closed form matches on all four checked terms.

CounterexampleDropping "finitely many objects of each size"

The Product Rule for combinatorial classes requires that ana_n and bnb_n be finite for every nn, so that the coefficient cn=∑k=0nakbn−kc_n = \sum_{k=0}^n a_k b_{n-k} is a finite sum of finite numbers, hence itself finite and well-defined as an honest count. Drop this hypothesis: let A\mathcal A be the class of all finite subsets of N\mathbb{N}, with size function ∣α∣=|\alpha| = (number of elements of α\alpha) — wait, refine the example to make the failure sharp. Instead let A=N\mathcal A = \mathbb{N} with the size function ∣α∣=0|\alpha| = 0 for every α∈N\alpha \in \mathbb N (so every natural number is declared to have "size 00"). Then a0=#{α:∣α∣=0}=#N=∞a_0 = \#\{\alpha : |\alpha| = 0\} = \#\mathbb N = \infty, and an=0a_n = 0 for n≥1n\ge1. The "OGF" one would naively write is A(x)=∞+0x+0x2+⋯A(x) = \infty + 0x+0x^2+\cdots, which is not an element of R[[x]]\mathbb R[[x]] at all — the very first coefficient fails to be a real number, so A(x)A(x) does not exist as a formal power series. Now let B\mathcal B be the one-point class {⋆}\{\star\} with ∣⋆∣=0|\star|=0, so B(x)=1B(x) = 1, a perfectly good OGF. Form C=A×B\mathcal C = \mathcal A \times \mathcal B (in bijection with A\mathcal A itself, since B\mathcal B is a single point), with size ∣(α,⋆)∣=∣α∣+∣⋆∣=0|(\alpha,\star)| = |\alpha|+|\star| = 0. Then c0=#{(α,⋆):∣α∣+0=0}=#N=∞c_0 = \#\{(\alpha,\star): |\alpha|+0=0\} = \#\mathbb N = \infty again, and the "Product Rule" C(x)A(x)B(x)C(x) \stackrel{?}{=} A(x)B(x) is meaningless because A(x)A(x) itself is not a legitimate object of R[[x]]\mathbb R[[x]]: the equation cn=∑k=0nakbn−kc_n = \sum_{k=0}^n a_kb_{n-k} used inside the proof requires each aka_k to be a finite number to even state the sum, let alone to conclude it equals a coefficient of a product of well-defined power series. This shows the finiteness hypothesis is not a technicality: without it, the counting sequence is not a sequence of natural numbers at all, the "OGF" is not an element of the ring R[[x]]\mathbb R[[x]], and the entire apparatus (addition, multiplication, coefficient extraction) collapses before the Product Rule can even be stated, let alone proved.

Scope, edge cases & common traps

SituationWhat happensWhy
a0=0a_0 = 0A(x)A(x) has no multiplicative inverse in R[[x]]\mathbb R[[x]]Inverting requires solving a0b0=1a_0 b_0 = 1 first; if a0=0a_0=0 no such b0b_0 exists
Sequence eventually zero (finite support)A(x)A(x) is literally a polynomialPower series with finitely many nonzero coefficients is a polynomial by definition
Infinitely many objects of some size nnana_n undefined as a natural number, OGF does not existSee the counterexample above; finiteness of each ana_n is a standing hypothesis
Asking "does A(x)A(x) converge at x=1x=1?"Irrelevant to the formal theoryFormal power series need no convergence; analytic questions (radius of convergence, asymptotics) are a separate, optional layer built on top of the algebra
Composing A(B(x))A(B(x))Legal only if B(0)=0B(0) = 0Otherwise the composite series' coefficients involve infinite sums, which need not be finite

The mathematician behind it

Origins · 1 minLeonhard Euler and how this was discovered
LE
Leonhard Euler
1707–1783 · 18th-century mathematical analysis and combinatorics

Euler did not invent the modern formalism of R[[x]]\mathbb R[[x]], which crystallized later, but he was the first to wield generating functions as a systematic combinatorial weapon — most famously in his treatment of Integer Partitions, where he showed that the number of partitions of nn into distinct parts equals the number of partitions of nn into odd parts, by manipulating the infinite products ∏k≥1(1+xk)\prod_{k\ge1}(1+x^k) and ∏k≥111−x2k−1\prod_{k\ge1}\frac{1}{1-x^{2k-1}}. His 1748 Introductio in analysin infinitorum laid out power-series methods that became the direct ancestor of the generating-function calculus used throughout combinatorics today.

History
- 1748 — Euler's Introductio in analysin infinitorum develops power series as a computational tool and applies them to partitions.
- 1812 — Laplace's Théorie analytique des probabilités systematizes generating functions for probability distributions, cementing the "transform" viewpoint.
- 1930s–1940s — The formal-algebraic viewpoint (power series as elements of a ring, independent of convergence) becomes standard in combinatorics texts.
- 1978 — Rota, Kahaner, and Odlyzko's foundational papers help formalize the umbral/generating-function calculus used in modern enumerative combinatorics.
- 1990s–present — Flajolet and Sedgewick's Analytic Combinatorics unifies OGFs, Exponential Generating Functions, and complex-analytic asymptotics into a single symbolic method.
Do I need the series to converge to use an OGF?

No. An OGF is defined as a formal power series, an algebraic object encoding a sequence of coefficients, with no reference to convergence at any numeric value of xx. Addition, multiplication, and even composition (when the inner series has zero constant term) are defined purely combinatorially via finite sums, so every manipulation in this article is legitimate without ever asking whether ∑anxn\sum a_n x^n converges for some real or complex xx. Convergence becomes relevant only if you want to evaluate the series at a specific point, for instance to use complex-analytic techniques (residues, singularity analysis) for asymptotic estimates of ana_n as n→∞n\to\infty. That is a genuinely separate, optional layer built on top of the purely algebraic theory presented here.

What is the difference between an ordinary and an exponential generating function?

An OGF encodes (an)(a_n) as ∑anxn\sum a_n x^n; an EGF encodes the same sequence as ∑anxnn!\sum a_n \frac{x^n}{n!}. The choice matters combinatorially: OGFs are natural when objects of size nn decompose into unordered or unlabeled pieces (like multisets of coins), because the Product Rule's convolution ∑kakbn−k\sum_k a_kb_{n-k} matches unlabeled composition. EGFs are natural when the size-nn objects carry a labeling of their nn atoms (like permutations or labeled trees), because the n!n! in the denominator correctly accounts for interleaving labels between two independently-labeled pieces during a "labeled product." Both live in the same formal framework; the choice of normalization is dictated by the combinatorial structure being modeled.

How does the OGF approach solve linear recurrences with constant coefficients?

Given a recurrence like an=c1an−1+⋯+ckan−ka_n = c_1a_{n-1}+\cdots+c_ka_{n-k} for n≥kn \ge k, with fixed initial values a0,…,ak−1a_0,\dots,a_{k-1}, multiply both sides by xnx^n and sum over n≥kn \ge k. Reindexing each shifted sum in terms of A(x)=∑anxnA(x) = \sum a_nx^n turns the recurrence into a single linear equation for A(x)A(x), whose solution is always a rational function P(x)/Q(x)P(x)/Q(x) with Q(x)=1−c1x−⋯−ckxkQ(x) = 1 - c_1x - \cdots - c_kx^k. Partial fractions then decompose A(x)A(x) into a sum of simple geometric-series pieces Pi1−rix\frac{P_i}{1-r_ix}, each contributing a term PirinP_i r_i^n to the closed form, exactly as carried out in Example 2 of this article.

Can generating functions handle recurrences that are not linear or not constant-coefficient?

Yes, though the algebra becomes more intricate. The Catalan Numbers satisfy the nonlinear recurrence Cn=∑k=0n−1CkCn−1−kC_n = \sum_{k=0}^{n-1}C_kC_{n-1-k}, which translates, via the Product Rule applied to a self-referential combinatorial decomposition, into the quadratic functional equation C(x)=1+xC(x)2C(x) = 1 + xC(x)^2 for the OGF, solvable by the quadratic formula to give C(x)=1−1−4x2xC(x) = \frac{1-\sqrt{1-4x}}{2x}. Recurrences with polynomial (non-constant) coefficients typically produce a differential equation for A(x)A(x) rather than an algebraic one, opening the door to the broader theory of D-finite (holonomic) generating functions, a genuinely more advanced topic.

Is every formal power series the OGF of a "nice" combinatorial sequence?

Every sequence of real numbers gives a formal power series, but not every such series arises from counting the size classes of a natural combinatorial construction with the Product Rule's finiteness hypotheses. What makes OGFs useful in enumerative combinatorics specifically is that natural set-theoretic operations (disjoint union, Cartesian product, sequences, sets, cycles) correspond to simple algebraic operations (sum, product, geometric series, exponential, logarithm-type corrections) on OGFs — this dictionary is the "symbolic method." A generic power series with no combinatorial origin can still be manipulated formally, but there is no guarantee its coefficients count anything meaningful.

Why does multiplying by 11−x\frac{1}{1-x} compute partial sums?

Because 11−x=∑n≥0xn\frac{1}{1-x} = \sum_{n\ge0}x^n and the Cauchy product coefficient of xnx^n in A(x)⋅11−xA(x)\cdot\frac{1}{1-x} is ∑k=0nak⋅1=a0+a1+⋯+an\sum_{k=0}^n a_k \cdot 1 = a_0+a_1+\cdots+a_n, using that every coefficient of 11−x\frac{1}{1-x} equals 11. This single algebraic fact instantly reproves identities like ∑k=0n(k+jj)=(n+j+1j+1)\sum_{k=0}^n\binom{k+j}{j} = \binom{n+j+1}{j+1} (multiply the OGF (1−x)−(j+1)(1-x)^{-(j+1)} of (n+jj)\binom{n+j}{j} by 11−x\frac{1}{1-x} to get (1−x)−(j+2)(1-x)^{-(j+2)}, whose coefficients are (n+j+1j+1)\binom{n+j+1}{j+1}) without induction.

What role do generating functions play beyond pure combinatorics?

Probability generating functions E[xX]=∑kP(X=k)xk\mathbb E[x^X]=\sum_kP(X=k)x^k are OGFs of a probability mass function; their product rule recovers, instantly, that the sum of two independent random variables has a PGF equal to the product of the individual PGFs, mirroring the combinatorial Product Rule exactly. In computer science, OGFs analyze algorithm running times and structure counts (e.g. binary trees via the Catalan recurrence). In physics, partition functions in statistical mechanics are literally generating functions in a fugacity variable, tracking energy levels the way an OGF tracks combinatorial size.

Before this

Where this leads