On this page
A tree is a root plus some smaller trees, so its generating function T appears on both sides of its own equation. Lagrange inversion turns that equation straight into a formula for the coefficients, without solving for T.
What does the Lagrange inversion formula say?
Suppose φ(t) is a power series with φ(0) ≠ 0, and T(x) is the power series with no constant term that satisfies T = x·φ(T). Then, for every n ≥ 1, [xⁿ]T = (1/n)[tⁿ⁻¹]φ(t)ⁿ, where [xⁿ] means "the coefficient of xⁿ in". This is the form given in the Wikipedia article on the Lagrange inversion theorem, which also records that Lagrange submitted the paper in 1768, that it was published in 1770, and that Hans Heinrich Bürmann generalised it in the late 18th century.
The formula also holds for formal power series, so convergence never gets in the way while counting. Ira Gessel's survey Lagrange inversion (Journal of Combinatorial Theory, Series A, 2016, DOI 10.1016/j.jcta.2016.06.018) collects its versions, proofs and uses in combinatorics and power series identities.
The recipe has three steps:
Write your counting problem as T = x·φ(T) and read off φ.
Raise φ(t) to the power n.
Take the coefficient of tⁿ⁻¹ and divide by n.
How do you get the Catalan numbers from T = x(1 + T)²?
A binary tree with at least one node is a root with a left slot and a right slot, and each slot is either empty or holds a smaller binary tree. If T(x) counts non-empty binary trees by number of nodes, the root contributes x and each slot contributes (1 + T). So T = x(1 + T)², and φ(t) = (1 + t)².
Follow the recipe. φ(t)ⁿ = (1 + t)²ⁿ, and by the binomial theorem the coefficient of tⁿ⁻¹ is C(2n, n − 1). So the number of binary trees with n nodes is (1/n)·C(2n, n − 1), which simplifies to C(2n, n)/(n + 1), the nth Catalan number.
For n = 3: (1/3)·C(6, 2) = 15/3 = 5, the five trees drawn in the diagram above. For n = 4 you get (1/4)·C(8, 3) = 56/4 = 14. Both match the start of the Catalan sequence 1, 1, 2, 5, 14, 42, 132 in OEIS A000108. The Narayana numbers split the Catalan count by peaks.
Why are there nⁿ⁻¹ labelled rooted trees?
For labelled objects, use exponential generating functions: the count tₙ sits in T as tₙxⁿ/n!. A rooted tree on labelled vertices is a root joined to a set of smaller rooted trees, and "a set of" becomes the exponential. So T = x·eᵀ and φ(t) = eᵗ. New to these? Start with our explainer on exponential generating functions for labelled structures.
Apply the recipe. φ(t)ⁿ = eⁿᵗ, whose coefficient of tⁿ⁻¹ is nⁿ⁻¹/(n − 1)!. Divide by n to get [xⁿ]T = nⁿ⁻¹/n!, so tₙ = n!·[xⁿ]T = nⁿ⁻¹. OEIS A000169 lists 1, 2, 9, 64, 625 as the number of labelled rooted trees with n nodes and notes that T(x) = x·exp(T(x)).
Each unrooted tree on n vertices can be rooted at any of its n vertices, so dividing by n gives nⁿ⁻² unrooted trees, which is Cayley's formula for labelled trees.
What is the general power version?
Often you want a power of T, not T itself. Wikipedia states the more general Lagrange–Bürmann formula, [xⁿ]H(T) = (1/n)[tⁿ⁻¹]H′(t)φ(t)ⁿ. Putting H(t) = tᵏ gives the power version: [xⁿ]Tᵏ = (k/n)[tⁿ⁻ᵏ]φ(t)ⁿ, for 1 ≤ k ≤ n.
Two checks:
Catalan, k = 2: [x³]T² = (2/3)[t¹](1 + t)⁶ = (2/3)·6 = 4. Squaring T = x + 2x² + 5x³ + … gives x² + 4x³ + …, so it agrees.
Rooted forests, k = 2: Tᵏ/k! counts sets of k rooted trees, so the formula gives n!/k! × (k/n) × nⁿ⁻ᵏ/(n − k)!. For n = 3 that is 6. By hand: one tree is a single vertex (3 choices) and the other is a two-vertex tree rooted at either end (2 choices), so 6.
How should you practise Lagrange inversion?
Always check n = 1, 2, 3 by listing the objects. Small cases catch a wrong φ at once.
Keep T free of a constant term. If your series starts at 1, as binary trees with the empty tree do, subtract it first.
Decide early whether your objects are labelled (exponential series) or unlabelled (ordinary series).
Try new φ yourself, such as φ(t) = (1 + t)³ for trees where every node has three slots, and check it against a hand count.
If a step such as reading a coefficient from (1 + t)²ⁿ feels shaky, the Fermi Concept Library gives each mathematics concept, including the binomial theorem, its own lesson. For practice, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer.



