Fiveable

🧮Combinatorics Unit 6 Review

QR code for Combinatorics practice questions

6.3 Operations on generating functions

6.3 Operations on generating functions

Written by the Fiveable Content Team • Last updated August 2025
Written by the Fiveable Content Team • Last updated August 2025
🧮Combinatorics
Unit & Topic Study Guides

Generating functions operations

Operations on generating functions let you build new sequences from old ones using algebra. Addition, multiplication, and composition each have a direct combinatorial meaning, and mastering these operations is what makes generating functions so useful for counting.

Addition and Multiplication

Addition combines two generating functions by adding coefficients of like powers. If A(x)=anxnA(x) = \sum a_n x^n and B(x)=bnxnB(x) = \sum b_n x^n, then A(x)+B(x)=(an+bn)xnA(x) + B(x) = \sum (a_n + b_n) x^n.

(1+2x+3x2)+(4+5x+6x2)=5+7x+9x2(1 + 2x + 3x^2) + (4 + 5x + 6x^2) = 5 + 7x + 9x^2

Combinatorially, this corresponds to counting the union of two disjoint sets. If ana_n counts one type of object of size nn and bnb_n counts another, then an+bna_n + b_n counts both types together.

Multiplication is more interesting. The product A(x)B(x)A(x) \cdot B(x) has coefficients given by the Cauchy product (also called convolution):

cn=k=0nakbnkc_n = \sum_{k=0}^{n} a_k \, b_{n-k}

This formula says: to build an object of size nn, choose some size kk for the first part and size nkn - k for the second, then multiply the number of choices. For example:

(1+2x)(3+4x)=3+4x+6x+8x2=3+10x+8x2(1 + 2x)(3 + 4x) = 3 + 4x + 6x + 8x^2 = 3 + 10x + 8x^2

The coefficient of x1x^1 is 14+23=101 \cdot 4 + 2 \cdot 3 = 10, which is exactly the Cauchy product at n=1n = 1.

A classic application: if you roll two dice, the generating function for a single die is x+x2+x3+x4+x5+x6x + x^2 + x^3 + x^4 + x^5 + x^6. Squaring this gives a generating function whose coefficient of xnx^n counts the number of ways to roll a sum of nn.

Composition and Advanced Operations

Composition means substituting one generating function into another. Given F(x)F(x) and G(x)G(x) with G(0)=0G(0) = 0 (this condition matters for convergence in the formal power series setting), you form F(G(x))F(G(x)) by replacing every xx in FF with G(x)G(x).

For example, if F(x)=1+x+x2F(x) = 1 + x + x^2 and G(x)=2xG(x) = 2x, then:

F(G(x))=1+2x+(2x)2=1+2x+4x2F(G(x)) = 1 + 2x + (2x)^2 = 1 + 2x + 4x^2

Composition is especially useful for nested or hierarchical combinatorial structures, like placing objects into groups that are themselves arranged in some pattern.

All of these operations live inside the formal power series ring R[[x]]\mathbb{R}[[x]], which is closed under addition, multiplication, and (with the right conditions) composition. "Formal" means you don't worry about whether the series converges numerically. You treat anxn\sum a_n x^n as a purely algebraic object. That said, when you do want numerical answers (e.g., using 11x=n0xn\frac{1}{1-x} = \sum_{n \geq 0} x^n), convergence for x<1|x| < 1 becomes relevant.

Solving counting problems

Addition and Multiplication, combinatorics - A problem in Combinatorial Analysis - Mathematics Stack Exchange

Application of Basic Operations

Each operation translates a combinatorial idea into algebra:

  • Addition handles disjoint unions. If set AA has generating function A(x)A(x) and set BB has B(x)B(x), and AB=A \cap B = \emptyset, then ABA \cup B has generating function A(x)+B(x)A(x) + B(x).
  • Multiplication handles Cartesian products (independent choices). Choosing a shirt from 3 options and pants from 2 options gives 3×2=63 \times 2 = 6 outfits. In generating function terms, you're multiplying the two functions.
  • Composition handles substitution into structures. For instance, counting ways to partition objects into groups, where each group is itself structured, often requires composing the generating function for the group structure into the one for the overall arrangement.

Coefficient extraction is how you read off answers. The notation [xn]F(x)[x^n] F(x) means "the coefficient of xnx^n in F(x)F(x)." For example, [xn]11xx2[x^n] \frac{1}{1 - x - x^2} gives the nnth Fibonacci number (with appropriate initial conditions), since the Fibonacci recurrence fn=fn1+fn2f_n = f_{n-1} + f_{n-2} translates directly into that rational generating function.

Advanced Techniques

Partial fraction decomposition breaks a rational generating function into simpler pieces whose coefficients you can read off directly.

For example, to extract coefficients from 1(1x)(12x)\frac{1}{(1-x)(1-2x)}:

  1. Decompose: 1(1x)(12x)=A1x+B12x\frac{1}{(1-x)(1-2x)} = \frac{A}{1-x} + \frac{B}{1-2x}
  2. Solve for AA and BB: you get A=1A = -1, B=2B = 2
  3. Expand each fraction as a geometric series: [xn]=11n+22n=2n+11[x^n] = -1 \cdot 1^n + 2 \cdot 2^n = 2^{n+1} - 1

The Lagrange inversion theorem handles implicit equations where a generating function is defined in terms of itself. If T(x)=xϕ(T(x))T(x) = x \, \phi(T(x)) for some known function ϕ\phi, Lagrange inversion gives you a formula for [xn]T(x)[x^n] T(x). This is particularly powerful for tree enumeration. For instance, the equation T(x)=x(1+T(x))2T(x) = x(1 + T(x))^2 counts a family of rooted trees, and Lagrange inversion extracts the coefficients without needing to solve for TT explicitly.

Pattern recognition also saves work. Knowing common generating functions lets you spot answers quickly:

  • 1(1x)2=n0(n+1)xn\frac{1}{(1-x)^2} = \sum_{n \geq 0} (n+1) x^n, generating the sequence 1,2,3,4,1, 2, 3, 4, \ldots
  • 1(1x)k\frac{1}{(1-x)^k} generates (n+k1k1)\binom{n+k-1}{k-1}, which counts multisets of size nn from kk types

Deriving generating functions

Addition and Multiplication, combinatorics - Permutation Theorem - Mathematics Stack Exchange

Modification Techniques

These techniques let you transform a known generating function into one for a related sequence.

Shifting (multiplying by xmx^m) shifts the sequence by mm positions. If F(x)=n0anxnF(x) = \sum_{n \geq 0} a_n x^n, then xF(x)=n1an1xnx \cdot F(x) = \sum_{n \geq 1} a_{n-1} x^n. This is useful when a recurrence involves shifted indices.

Differentiation produces weighted sequences. Since:

F(x)=n1nanxn1F'(x) = \sum_{n \geq 1} n \, a_n \, x^{n-1}

differentiating 11x\frac{1}{1-x} gives 1(1x)2=n0(n+1)xn\frac{1}{(1-x)^2} = \sum_{n \geq 0} (n+1) x^n. Differentiation corresponds combinatorially to "marking" or distinguishing one element in a structure. Integration reverses this, dividing coefficients by n+1n+1, which can be thought of as "unmarking" a distinguished element.

Variable substitution transforms indices. Replacing xx with x2x^2 in 11x=xn\frac{1}{1-x} = \sum x^n gives 11x2=x2n\frac{1}{1-x^2} = \sum x^{2n}, which generates the sequence 1,0,1,0,1,1, 0, 1, 0, 1, \ldots (nonzero only at even indices).

Multiplying by a geometric series can also be useful. For instance:

(1+x)11x2=1+x(1x)(1+x)=11x(1 + x) \cdot \frac{1}{1 - x^2} = \frac{1+x}{(1-x)(1+x)} = \frac{1}{1-x}

This recovers the all-ones sequence from the alternating-index sequence.

Advanced Derivation Methods

The Hadamard product A(x)B(x)=anbnxnA(x) \odot B(x) = \sum a_n b_n x^n gives the term-by-term product of two sequences. Unlike ordinary multiplication (which gives convolution), the Hadamard product multiplies corresponding coefficients directly. It's less common but useful when you need element-wise combination of sequences.

Functional equations translate recurrences into generating function equations. The classic example is the Catalan numbers, defined by C0=1C_0 = 1 and Cn+1=k=0nCkCnkC_{n+1} = \sum_{k=0}^{n} C_k C_{n-k}. The convolution in that recurrence becomes ordinary multiplication:

C(x)=1+xC(x)2C(x) = 1 + x \, C(x)^2

Solving this quadratic in C(x)C(x) gives C(x)=114x2xC(x) = \frac{1 - \sqrt{1 - 4x}}{2x}.

Exponential generating functions (EGFs) require adjusted rules. If A^(x)=anxnn!\hat{A}(x) = \sum a_n \frac{x^n}{n!}, then multiplication of EGFs corresponds to the binomial convolution cn=k=0n(nk)akbnkc_n = \sum_{k=0}^{n} \binom{n}{k} a_k b_{n-k}, which counts ways to split a labeled set of size nn into two parts and apply separate structures to each. The exponential formula F^(x)=exp(G^(x))\hat{F}(x) = \exp(\hat{G}(x)) connects the EGF for connected structures GG to the EGF for sets of those structures FF. For example, this relates connected graphs to all graphs, or cycles to permutations.

Operations vs combinatorial interpretations

Combinatorial Meanings of Basic Operations

Each algebraic operation on generating functions has a precise combinatorial counterpart:

OperationAlgebraic EffectCombinatorial Meaning
AdditionAdd coefficientsDisjoint union of counted sets
Multiplication (OGF)Cauchy product / convolutionCartesian product; independent choices
CompositionSubstitute one series into anotherSubstitution into structures (e.g., distributing objects into groups)
DifferentiationMultiply nnth coefficient by nnMarking / distinguishing one element
IntegrationDivide nnth coefficient by nnUnmarking / forgetting a distinguished element

Convolution deserves extra emphasis. When you multiply two OGFs, the coefficient cn=kakbnkc_n = \sum_{k} a_k b_{n-k} counts ways to partition nn into two parts and independently choose structures on each part. This is exactly what happens when distributing nn indistinguishable objects into two distinct bins with constraints encoded by A(x)A(x) and B(x)B(x).

Advanced Interpretations and Applications

The exponential formula is one of the deepest connections between operations and combinatorics. If C^(x)\hat{C}(x) is the EGF for connected structures, then exp(C^(x))\exp(\hat{C}(x)) is the EGF for sets of those structures. This single identity lets you count labeled forests from labeled trees, permutations from cycles, and set partitions from blocks.

Functional equations reveal recursive structure. The equation C(x)=x+C(x)2C(x) = x + C(x)^2 for (a shifted version of) binary trees says: a binary tree is either a single node (xx) or a pair of binary trees joined at a root (C(x)2C(x)^2). The algebraic equation directly mirrors the recursive definition of the combinatorial object. Reading functional equations this way often provides the most intuitive route to setting them up correctly.