Feeds:
Posts

GILA IV: The unreasonable effectiveness of generating functions in the combinatorial sciences

We’ve got everything we need to prove the Polya enumeration theorem. To state the theorem, however, requires the language of generating functions, so I thought I’d take the time to establish some of the important ideas. It isn’t possible to do justice to the subject in one post, so I’ll start with some references.

Many people recommend Wilf’s generatingfunctionology, but the terminology is non-standard and somewhat problematic. Nevertheless, it has valuable insight and examples.

I cannot recommend Flajolet and Sedgewick’s Analytic Combinatorics highly enough. It is readable, includes a wide variety of examples as well as very general techniques, and places a great deal of emphasis on asymptotics, computation, and practical applications.

If you can do the usual computations but want to learn some theory, Bergeron, Labelle, and Laroux’s Combinatorial Species and Tree-like Structures is a fascinating introduction to the theory of species that requires fairly little background, although a fair amount of patience. It also contains my favorite proof of Cayley’s formula.

Doubilet, Rota, and Stanley’s On the idea of generating function is part of a fascinating program for understanding generating functions with posets as the fundamental concept. I may have more to say about this perspective once I learn more about it.

While it is by no means comprehensive, this post over at Topological Musings is a good introduction to the basic ideas of species theory.

And a shameless plug: the article I wrote for the Worldwide Online Olympiad Training program about generating functions is available here. I tried to include a wide variety of examples and exercises taken from the AMC exams while focusing on techniques appropriate for high-school problem solvers. There are at least a few minor errors, for which I apologize. You might also be interested in this previous post of mine.

In any case, this post will attempt to be a relatively self-contained discussion of the concepts necessary for understanding the PET.

The first big trick of generating function theory is to study a sequence $s_n$ by studying the (formal or analytic) power series called its ordinary generating function (ogf) $\displaystyle \sum_{n \ge 0} s_n x^n$.

(When we call a power series formal, we are ignoring questions of convergence.) This has several advantages, some of which are obvious and some of which are quite deep.

1. If $s_n$ is the number of “constructions” of a certain type on a set with cardinality $n$, then addition and multiplication of series corresponds directly to two natural operations on constructions: addition of two series gives the number of constructions of either the first type or the other, whereas multiplication of series gives the number of constructions where part of the set is a construction of the first type and part of the set is a construction of the second type. This observation is one of the big motivations for species theory. For example, the generating function that describes the probability of rolling various sums by rolling $n$ six-sided dice simultaneously is $\displaystyle \left( \frac{x + x^2 + ... + x^6}{6} \right)^n$

in the sense that the coefficient of $x^k$ tells us the probability of rolling a sum of $k$. This is due to the fact that the additions tell us that a dice roll is either a one or a two or…, and the multiplications tell us that a sum consists of rolling the first die and the second die and…. Think carefully about why this works; it’s essentially an extension of the usual combinatorial interpretation of the binomial theorem.

2. Many natural operations on sequences, such as taking finite differences or partial sums, are easily describable in terms of generating functions. For example, taking forward differences is equivalent to multiplying by $1 - x$ and taking partial sums is equivalent to dividing by $1 - x$.
3. It’s often possible to express recursions for $s_n$ in terms of equations that its generating function must satisfy, which may involve derivatives, and so to translate the computation of $s_n$ (if you are only given a recursion) into the problem of finding a function satisfying a certain functional equation or differential equation. For example, the recursive definition of the Catalan numbers, as I have mentioned, is equivalent to the identity $C(x) = 1 + x C(x)^2$

for their ogf. Even if it doesn’t appear feasible to solve a functional equation, various analytic methods such as the Lagrange inversion theorem can still be used to extract coefficients.

4. Often a sequence does not have a nice “closed form” but still has a nice generating function. There are rather deep reasons for this phenomenon generally related to how certain well-known functions can be interpreted combinatorially. For example, the Bell numbers count the number of ways to partition a set into a disjoint union of subsets. While it does not have a particularly nice closed formula, we have the exponential generating function (egf) $\displaystyle \sum_{n \ge 0} \frac{B_n}{n!} x^n = e^{e^x - 1}$.

The distinction between exponential and ordinary generating functions occurs depending on whether we’re counting “labeled” or “unlabeled” objects, but for now the basic idea is that certain sequences grow too fast for their ogf’s to be nice. There are both high-level and low-level proofs of the above result; hopefully we’ll get into the high-level ones sooner or later.

5. Generating functions that correspond to analytic functions can be studied in terms of the analytic properties of the function. This is the main tool of asymptotic analysis, and in many cases it’s possible to give extremely precise estimates for values of sequences that don’t have anything approaching a nice closed form. For example, using a basic property of meromorphic functions, it’s possible to show that the fraction of permutations of $n$ elements with only cycles of length greater than or equal to $r$ is asymptotically equal to $\displaystyle e^{-\left( 1 + \frac{1}{2} + ... + \frac{1}{r} \right)}$. Flajolet and Sedgewick is the best reference I know of for such techniques.

The non-analytic benefits of using generating functions can roughly be summarized as follows: generating functions are a way to rephrase combinatorial arguments using algebraic tools.

A general way to construct a generating function is as follows: we have an infinite set $S$, such as the set of all binary trees, along with a combinatorial parameter $|s|$ sometimes called a weight taking values in, say, the non-negative integers, such that there are finitely many $s \in S$ with a particular value of $|s|$. We can then construct the weight enumerator $\displaystyle \sum_{s \in S} x^{|s|}$.

The coefficient of $x^k$ in this generating function then counts the number of $s \in S$ such that $|s| = k$. For binary trees, one usually takes $|s|$ to be the total number of vertices in the tree.

Weight enumerators behave very nicely under disjoint union and Cartesian product if one adopts two reasonable conventions:

1. The weight of an element in a disjoint union is inherited from the original set to which it belonged.
2. The weight of an element in a Cartesian product is the sum of the weights of its components.

With these two conventions, addition of series corresponds to disjoint union and multiplication of series corresponds to Cartesian product. If the sets involved are finite, one recovers “unweighted” disjoint union and Cartesian product by setting $x = 1$.

The nice thing about thinking about generating functions from this perspective is that there’s no reason to stick to one parameter. Thus we can introduce a family of parameters $|s|_1, |s|_2, ...$ and construct a multivariate generating function $\displaystyle \sum_{s \in S} x_1^{|s|_1} x_2^{|s|_2} ...$.

The coefficient of $x_1^{k_1} x_2^{k_2} ...$ then counts the number of $s \in S$ such that $(|s|_1, |s|_2, ...) = (k_1, k_2, ...)$. Introducing extra parameters is a straightforward way to generalize a known counting result. If you know how a set splits up with respect to one parameter, see how each term of the one-variable generating function splits up with respect to a second parameter.

One key to working with combinatorial parameters is this: most combinatorial arguments interact nicely with the obvious parameters. Thus the same counting argument can prove both a one-variable identity or a multivariate identity.

Now would be a good time for an example. One way to define the Fibonacci numbers is as follows: $F_{n+1}$ is the number of ways to walk a distance $n$ if you can only walk in steps of length $1, 2$. The obvious combinatorial parameter is the total length of the walk. One can compute the generating function $F(x) = \sum_{n \ge 0} F_{n+1} x^n$ as follows: every walk is either empty, consists of a step of length $1$ followed by another walk, or consists of a step of length $2$ followed by another walk. This argument is equivalent to the weighted identity $F(x) = 1 + x F(x) + x^2 F(x)$

which immediately gives $F(x) = \frac{1}{1 - x - x^2}$. An interesting combinatorial parameter to introduce now is the number of steps of length $1$. This gives the weighted identity $F(x, y) = 1 + xy F(x, y) + x^2 F(x, y)$

which immediately gives $F(x, y) = \frac{1}{1 - xy - x^2}$. The coefficient of $x^k$ is now a polynomial $F_{n+1}(y)$ called a Fibonacci polynomial; for positive integer values of $y$, it counts the number of tilings where the tiles of size $1$ can take on one of $y$ different colors. (This is another good reason to introduce combinatorial parameters.) The Fibonacci polynomials are closely related to the Chebyshev polynomials, which is characteristic of the relationship between combinatorics and the theory of special functions.

Sometimes the interesting parameters to introduce aren’t obvious. (Sometimes they become obvious only when the combinatorial object being studied is bijected to a different one; this is a good reason to like bijective combinatorics.) For example, a classical parameter to study when looking at permutations is the number of inversions of the permutation. The inversion statistic $\text{inv}(\pi)$ counts the number of pairs of letters in the word $\pi(1) \pi(2) ... \pi(n)$ that are “out of order” from the identity word $1 2 ... n$.

Proposition: the weight enumerator $\displaystyle \sum_{\pi \in S_n} q^{\text{inv}(\pi)}$ is equal to the $q$-factorial $(n)!_q$.

The proof is quite elegant. We build up the word of a permutation as follows: first, we write down a $1$. Next, we have a choice about where to write down the $2$. The first choice $12$ introduces no inversion and the second choice $21$ introduces one inversion. More generally, when we choose where to write down $k$, each of our $k$ chooses introduces $0, 1, 2, ... k-1$ inversions respectively. This argument is equivalent to the weighted identity $\displaystyle \sum_{\pi \in S_n} q^{\text{inv}(\pi)} = 1(1 + q)(1 + q + q^2)...(1 + q + ... + q^{n-1})$

as desired. What’s the connection to Young diagrams that fit inside a box? I should probably know this, but my first guess is that it probably has something to do with the fact that $\displaystyle \frac{1}{(1 - q)...(1 - q^n)}$

counts partitions into parts of size at most $n$, i.e. Young diagrams of width (equivalently, height) at most $n$. I would be very interested if anyone could give a direct proof relating this result to the Young diagram result.

I could go on and on, but if you understood the above examples then you’re already in a position to rediscover the PET. The question you want to ask yourself: does the argument we used to prove baby Polya interact nicely with the extra parameters “number of times this color is used”?

Exercises

(For additional exercises, consult my article or any of the other references.)

A Motzkin tree or binary-unary tree is a tree in which every non-leaf node has either one or two children. Compute the generating function $M(x)$ of the Motzkin trees indexed by the total number of vertices in the tree.

Let $f(x)$ be a generating function with no constant term. What does the generating function $\frac{1}{1 - f(x)}$ count? (Hint: two equivalent ways to think about this generating function are as $F(x) = 1 + f(x) + f(x)^2 + ...$ or as the unique generating function satisfying $F(x) = 1 + f(x) F(x)$. If it helps, think about the case that $f(x)$ is a polynomial with non-negative integer coefficients.)

Given variables $x_1, ... x_n$, the elementary symmetric functions are defined as the coefficients of the polynomial $\displaystyle \sum_{k \ge 0} e_k t^k = \prod_{i=1}^{n} (1 + tx_i)$.

The power symmetric functions are defined as the coefficients of the power series $\displaystyle \sum_{k \ge 0} p_k t^k = \sum_{i=1}^{n} \frac{1}{1 - tx_i}$.

Finally, the complete homogeneous symmetric functions are defined as the coefficients of the power series $\displaystyle \sum_{k \ge 0} h_k t^k = \prod_{i=1}^{n} \frac{1}{1 - tx_i}$.

Show that each of these sequences of polynomials can be written in terms of the others. What happens to the first and third sequences at $x_i = 1$? What are the first and third sequences generating functions of?

6 Responses

1. on March 6, 2013 at 7:38 pm | Reply isomorphismes

You probably saw this, but just in case: Coursera has a course on generating functions (analytic combinatorics) by Robert Sedgwick.

2. on December 17, 2011 at 7:17 pm | Reply Jesse

Hi again,
I am a bit in over my head here, but shouldn’t the 3rd term in the q-factorial be (1+q+q^2) instead of (1+q^2)?
Thanks again for these posts.
Best,
Jesse

3. on November 20, 2010 at 8:07 pm | Reply daniel pietrobon

Hello from Australia qchu,

It is good to see some “easily accessible” material on your blog, as I often read through your writings but more often than not do not devote the necessary time to understand them. So it is refreshing to see some mathematics of this nature here.

The book Analytic Combinatorics also looks very nice and I am excited to begin working through it.

I have a strange request, but do you have any writings or musings on transcendental number theory? I would enjoy reading them. I am only an undergrad at my institution (and it is no Cambridge – hehe) but this topic has recently sparked my interest and I am keen to digest as much as I can.

Thank you again for your writings, I follow them with much interest.

• on November 21, 2010 at 4:25 am | Reply Qiaochu Yuan

Hi Daniel,

Unfortunately I don’t know much about transcendental number theory. But now that you mention it, it wouldn’t be a bad idea to write some more accessible posts.

4. […] verify that when the Hilbert series is , and this should be familiar if you did the exercise about symmetric functions awhile back. Hilbert series behave well under the obvious operations: they are additive under […]