Hi everyone!

There is a concept that is sometimes mentioned here and there. The Lagrange inversion theorem.

Let $$$x = f(y)$$$. We want to solve this equation for $$$y$$$. In other words, we want to find a function $$$g$$$ such that $$$y = g(x)$$$.

The Lagrange inversion theorem gives an explicit formula for the coefficients of $$$g(x)$$$ as a formal power series over $$$\mathbb K$$$:

In a special case $$$y = x \phi(y)$$$, that is $$$f(y) = \frac{y}{\phi(y)}$$$, which is common in combinatorics, it can also be formulated as

Finally, to avoid division by $$$k$$$ one may use (see the comment by Elegia) the following formula:

which may be formulated for $$$y = x \phi(y)$$$ as

## Prerequisites

Familiarity with the following:

It is required to have knowledge in the following:

- Polynomials, formal power series and generating functions;
- Basic notion of analytic functions (e.g. Taylor series);
- Basic concepts of graph theory (graphs, trees, etc);
- Basic concepts of set theory (describing graphs, trees, etc as sets, tuples, etc).

I mention the concept of fields, but you're not required to know them to understand the article. If you're not familiar with the notion of fields, assume that we're working in real numbers, that is, $$$\mathbb K = \mathbb R$$$.

It is recommended (but not required) to be familiar with combinatorial species, as they provide lots of intuition to how the equations on generating functions below are constructed.

## Motivational examples

In my practice, most obvious use cases of the inversion theorem are related to the enumeration of trees.

### Ordered trees

An ordered tree is a rooted tree in which an ordering of children is specified for each vertex.

*All ordered trees on $$$n \in \{1,2,3,4\}$$$ vertices.*

The task is, given $$$k$$$, to find the number of ordered trees on $$$n$$$ vertices such that *every* vertex is either a leaf or has at least $$$k$$$ children.

Ordered tree can be described recursively in the following manner:

In other words, as a set-theoretic object, an ordered tree can be represented as a $$$(k+1)$$$-tuple, such that the first element is its root and the next $$$k$$$ elements are its subtrees, which are also objects of the ordered tree class.

We can enumerate ordered $$$n$$$-tuples of arbitrary objects from class $$$A$$$ as $$$A^n(x)$$$. And to enumerate them for every $$$n \geq k$$$, we would need to sum up the functions, obtaining the generating function for *the ordered sets of ordered trees*:

Let $$$T(x)$$$ be the generating function of ordered trees. Then it might be represented as

For $$$k = 1$$$, the solution is generated by

and for $$$k=2$$$, the solution is generated by

But as $$$k$$$ grows, the explicit formula for $$$T(x)$$$ gets more and more complicated (see the solution Wolfram found for $$$k=4$$$).

Alternate approach is to express $$$x=f(T)$$$. Then the Lagrange inversion theorem would still allow us to compute coefficients.

### $$$k$$$-ary trees

Another task of interest is to enumerate the $$$k$$$-ary trees.

*A ternary tree*

A $$$k$$$-ary tree is a tree in which every vertex is either a leaf or has *exactly* $$$k$$$ ordered children.

The generating function for $$$k$$$-ary trees adheres to the identity $$$T(x) = x \cdot (1+T^k)$$$.

### Labeled trees

Yet another task is to enumerate labeled rooted trees. While an ordered tree is represented as a pair of the *root vertex* and the *list of subtrees*, unordered tree may be represented as a pair of the *root vertex* and the *set of subtrees*. In other words, the generating function of the rooted trees adheres to the equation $$$T(x) = x \cdot e^{T(x)}$$$.

The later follows from the exponential formula which states that the generating function for the class of *sets of $$$T$$$* is $$$e^{T(x)}$$$.

Note that this equation only works for *labeled* trees, and their *exponential* generating function:

where $$$a_k$$$ is the number of labeled trees.

## Inversion theorem

Let $$$x = f(y)$$$. We want to solve this equation for $$$y$$$. In other words, we want to find a function $$$g$$$ such that $$$y = g(x)$$$.

This means that $$$x = f(g(x))$$$ and $$$y = g(f(y))$$$, so what we really want to find here is the functional inverse of $$$f$$$.

As it stands with generating functions, we're more interested in finding some expression for $$$g(x)$$$ as a formal power series, rather than closed elementary form (which may not exist). In doing so, we may use the Lagrange inversion theorem.

### Formulation

Let $$$f,g$$$ be formal power series, such that $$$f(g(x)) = x$$$ and $$$f(0) = g(0) = 0$$$, then

where $$$[x^k] f(x)$$$ denotes the coefficient near $$$x^k$$$ in $$$f(x)$$$. In particular the $$$g(x)$$$ itself is found as

$$$x^{-n}$$$ in the formulas above expects negative power of $$$x$$$ and $$$f^{-k}$$$ expects the existence of the multiplicative inverse for arbitrary formal power series $$$f(x)$$$, which is problematic. To mitigate this, we expand the domain of functions we're working with to formal Laurent series.

**Def. 1**. The set of **formal Laurent series** $$$\mathbb K((x))$$$ over $$$\mathbb K$$$ is defined as

In other words, formal Laurent series is a formal power series, which is also allowed to have finitely many terms $$$x^k$$$ with $$$k < 0$$$.

When $$$\mathbb K$$$ is a field, $$$\mathbb K((x))$$$ also form up a field. In particular, it means that for a formal Laurent series $$$A(x) \neq 0$$$ there always is a multiplicative inverse $$$A^{-1}(x)$$$ such that $$$A(x) A^{-1}(x) = 1$$$.

**Explanation**

Now that the formula is properly formulated, you may find the detailed proof below:

**Proof**

**Note**. Using the same reasoning, we can deduce it in even more general form for any analytic function $$$h(x)$$$:

### In combinatorics

Quite often the equation that you deal with in combinatorics is formulated as $$$y = x \phi(y)$$$.

It is possible to get a simpler expression for such cases.

Equivalently, $$$y = x \phi(y)$$$ rewrites as

Since

we have a formula for $$$y = g(x)$$$:

It is especially convenient due to the fact that we don't need to actually deal with Laurent series.

More general result for this case is known as the **Lagrange–Bürmann formula**:

for any analytic function $$$h(x)$$$.

## Cracking up the examples

### Ordered trees

The equation is

It means that $$$n [x^n] T(x) = [T^{n-1}] \phi^n(T)$$$, where $$$\phi(T) = 1+\frac{T^k}{1-T}$$$. To compute it, we use the binomial formula:

Note that $$$[T^a]T^b f(T) = [T^{a-b}] f(T)$$$. And, knowing the expansion

we may rewrite it as

Indeed, computing first few terms for different $$$k$$$ we see that

- $$$k=1$$$ yields Catalan numbers,
- $$$k=2$$$ yields Riordan numbers,
- $$$k=3$$$ yields the sequence A114997,
- $$$k=4$$$ yields the sequence A215341.

Further $$$k$$$ are seemingly not present on OEIS.

### $$$k$$$-ary trees

The equation is $$$T = x \cdot (1 + T^k)$$$. So, for this case $$$\phi(T) = 1+T^k$$$ and we need to find

The expression on the right only has coefficient near $$$T^{n-1}$$$ when $$$k$$$ divides $$$n-1$$$, in which cases the number of trees is

for $$$n=kt+1$$$. Let's look on the generated sequences for different $$$k$$$:

- $$$k=1$$$ yields $$$\frac{1}{t+1} \binom{t+1}{t}=1$$$. Indeed, there is only one $$$1$$$-ary tree (bamboo) for each possible number of vertices;
- $$$k=2$$$ yields $$$\frac{1}{2t+1} \binom{2t+1}{t}$$$. This is actually the $$$t$$$-th Catalan number and another neat formula for them!
- $$$k=3$$$ yields the number of ternary trees (A001764);
- $$$k=4$$$ yields the number of quartic trees (A002293).

### Labeled trees

The equation is $$$T = x e^T$$$. Let's find the coefficients with $$$\phi(T) = e^T$$$:

From this follows that

Note that we were specifically considering the *exponential* generating functions, thus the actual number of trees is $$$n! [x^n] T(x) = n^{n-1}$$$.

The function $$$T(x)$$$ can be expressed as $$$T(x) = -W(-x)$$$, where $$$W(x)$$$ is the Lambert W function (see e.g. here).

Ok this has always bothered me. Why is the formal Laurent series defined as having only a finite number of negative terms while a Laurent series in complex analysis can have infinite negative terms?

The idea behind formal power/Laurent series, compared to regular series, is to not care at all about convergence issues.

We generally define the multiplication in formal Laurent series as

If we don't make the number of negative terms finite, we potentially have infinite sums near $$$x^k$$$ and bad things happen.

To work with such sums, we'd need to introduce a notion of convergence and it kind of defeats the whole purpose.

Actually there is a variant form:

Remarks:

Looks nice! Is there a simple proof to it? Is it also proven with residues?

So, for $$$y = x \phi(y)$$$, we have $$$F' F^{-n-1}=\frac{\phi - x \phi'}{\phi^2} \frac{\phi^{n+1}}{x^{n+1}}$$$ and the formula for $$$y=g(x)$$$ would look like

Neat! Let's test it for Catalan numbers with $$$\phi(x) = 1+x^2$$$:

For $$$n = 2k+1$$$, we get

This is, indeed, another known formula for Catalan numbers, and this time without division.

And for the fuss Catalan numbers with $$$\phi(x) = 1 + x^k$$$, it would be

I've seen this sequence (table) of numbers named as "Fuss Catalan numbers" in the book Concrete Mathematics where a combinatorial proof of the formula is given. And actually they are in OEIS at A062993.

There are several sequences mentioned in the article... As I understand, you mean the table

which is related to $$$k$$$-ary trees with $$$t$$$ vertices.

Yeah sorry, for k-ary trees. And btw, in the book it is mentioned that the generating function is really hard to solve, which always bugged me a bit. So thanks for this blog :)