On this page
Exponential generating functions (EGFs) are the tool for counting problems where labelled pieces are shared out. Below: why the n! belongs, then three well-known sequences derived in a few lines.
What is an exponential generating function?
The exponential generating function of a sequence a₀, a₁, a₂, … is A(x) = Σ aₙxⁿ/n!, as defined in the Wikipedia article on generating functions. The same article says EGFs are "generally more convenient than ordinary generating functions for combinatorial enumeration problems that involve labelled objects".
Labelled means each atom carries its own name, 1 to n, so moving labels around gives a different structure. Permutations and partitions of {1, …, n} are labelled; sharing out identical sweets is not.
Two basic EGFs:
All permutations: there are n! of them, so the EGF is Σ n!xⁿ/n! = 1/(1 − x).
Sets (one way to put n labels in a bag): the EGF is Σ xⁿ/n! = eˣ.
Why does multiplying EGFs split the labels?
Take two kinds of structure with counts aₖ and bₖ. To build a pair on n labels, choose which k labels go to the first structure, build it in aₖ ways, and build the second on the other n − k labels in bₙ₋ₖ ways. The total is cₙ = Σ C(n, k) aₖ bₙ₋ₖ.
The coefficient of xⁿ in A(x)B(x) is Σ aₖbₙ₋ₖ / (k!(n − k)!). Multiply by n! and you get exactly Σ C(n, k) aₖ bₙ₋ₖ. The product of EGFs counts every way of splitting the labels between two parts.
For an unordered collection of pieces you get the exponential formula: the EGF of structures on finite sets is the exponential of the EGF of the connected pieces, as the exponential formula page states; the k! in exp forgets the order of k pieces.
How do you derive the derangement formula with EGFs?
A derangement is a permutation with no fixed point. OEIS A000166 lists the counts 1, 0, 1, 2, 9, 44, 265 for n = 0 to 6 and gives the EGF exp(−x)/(1 − x).
Every permutation splits uniquely into its set of fixed points and a derangement of the rest.
So, by the product rule, eˣ · D(x) = 1/(1 − x).
Hence D(x) = e^(−x)/(1 − x).
Reading off the coefficient gives Dₙ = n!(1 − 1/1! + 1/2! − … + (−1)ⁿ/n!). For n = 4 that is 24 × 9/24 = 9: nine of the 24 ways to put four letters into four addressed envelopes put every letter wrongly, a classic JEE question. The bracket is the start of the series for e^(−1), so the share of permutations that are derangements approaches 1/e.
Why is the Bell number EGF e^(eˣ − 1)?
A set partition of {1, …, n} cuts it into non-empty blocks. OEIS A000110 calls the counts the Bell numbers, the "number of ways to partition a set of n labeled elements", starts them 1, 1, 2, 5, 15, 52, 203, and gives the EGF exp(exp(x) − 1).
One block is a non-empty set: EGF eˣ − 1.
A partition is a set of blocks: apply exp, so B(x) = e^(eˣ − 1).
To check it, differentiate: B′(x) = eˣB(x), so Bₙ₊₁ = Σ C(n, k)Bₖ. With B₀ to B₃ = 1, 1, 2, 5, you get B₄ = 1 + 3 + 6 + 5 = 15. Grouping partitions by their number of blocks gives the Stirling numbers of the second kind, whose rows add up to the Bell numbers.
How do you count involutions with e^(x + x²/2)?
An involution is a permutation that undoes itself. OEIS A000085 describes them as partitions of n distinguishable elements "into sets of size 1 and 2", lists 1, 1, 2, 4, 10, 26, 76, and gives the EGF exp(x + x²/2).
A fixed point is a 1-cycle: EGF x.
A swap is a 2-cycle:EGF x²/2.
An involution is a set of these cycles: I(x) = e^(x + x²/2).
Differentiating gives I′(x) = (1 + x)I(x), so Iₙ₊₁ = Iₙ + nIₙ₋₁: label n + 1 either stays fixed or swaps with one of the other n. From 1, 1, 2 you get 4, 10, 26. Allowing cycles of every length leads to the Stirling numbers of the first kind.
A four-step checklist for any EGF problem
Confirm the atoms are labelled; if they are identical, use an ordinary generating function.
Describe the object as a split (product) or a set of pieces (exp), subtracting banned cases such as empty blocks.
Write the EGF of the smallest piece: x for one label, x²/2 for a pair, eˣ − 1 for a non-empty block.
Check the first few coefficients by hand, or differentiate to get a recurrence.
If a definition is unclear, the Fermi Concept Library covers every concept in mathematics, so you can settle the definition first. For derangement-style practice, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer.



