
7.1: What is a Generating Function?


A generating function is a formal structure that is closely related to a numerical sequence, but allows us to manipulate the sequence as a single entity, with the goal of understanding it better. Here’s the formal definition.

Definition: Generating Function

For a sequence $$a_0, a_1, . . . , a_n, . . .$$ the corresponding generating function $$f(x)$$ is the series

$f(x) = a_0 + a_1x + . . . + a_nx^n + . . . = \sum_{i=0}^{\infty} a_ix^i$

So $$a_n$$, the $$n^{\text{th}}$$ term of the sequence, is the coefficient of $$x^n$$ in $$f(x)$$.

Example $$\PageIndex{1}$$

Here are a number of basic examples.

1) $$1, 1, 1, 1, 1, 1, 0, 0, 0, . . .$$ has generating function

$1 + x + x^2 + x^3 + x^4 + x^5$

2) $$1, 4, 6, 4, 1, 0, 0, 0, . . .$$ has generating function

$1 + 4x + 6x^2 + 4x^3 + x^4 = (1 + x)^4$

3) $$\binom{n}{0} , \binom{n}{1}, . . . , \binom{n}{n}, 0, 0, 0, . . .$$ has generating function

$\binom{n}{0} + \binom{n}{1}x + . . . + \binom{n}{n}x^n = (1+x)^n$

4) $$1, 1, 1, 1, . . .$$ has generating function

$f(x) = 1 + x + x^2 + x^3 + . . . = \sum_{i=0}^{\infty} x^i$

These generating functions can be manipulated. For example, if $$f(x)$$ is as in Example 7.1.2 (4), suppose we take the product $$(1 − x)f(x)$$. We have

$$$\begin{split} (1 − x)f(x)&= (1-x)(1 + x + x^2 + x^3 + x^4 + ...) \\ &= (1 + x + x^2 + x^3 + x^4 + ...) - ( x + x^2 + x^3 + x^4 + x^5 + ...) \\ &= 1 \end{split}$$$

Dividing through by $$1 − x$$, we see that $$f(x) = \dfrac{1}{(1 − x)}$$.

This may seem artificial and rather nonsensical since the generating function was defined as a formal object whose coefficients are a sequence that interests us. In fact, although we won’t delve into the formalities in this course, algebraic manipulation of generating functions can be formally defined, and gives us exactly these results.

A reasonable question at this point might be, what use is this? Even if we agree that $$f(x) = \dfrac{1}{(1 − x)}$$, what we really want is the coefficient of $$x^n$$ (in order to retrieve $$a_n$$, the $$n^{\text{th}}$$ term of our sequence). If we have an expression like $$\dfrac{1}{(1 − x)}$$, how can we work out the coefficient of $$x^n$$?

Exercise $$\PageIndex{1}$$

For each of the following sequences, give the corresponding generating function.

1. $$1, 3, 5, 0, 0, 0, . . .$$
2. $$1, 2, 2 2 , 2 3 , 2 4 , . . .$$
3. $$1, 5, 10, 15, 10, 5, 1, 0, 0, 0, . . .$$
4. $$1, 5, 10, 10, 5, 1, 0, 0, 0, . . .$$