# Generating function

In mathematics a **generating function** is a formal power series whose coefficients encode information about a sequence *a*_{n} that is indexed by the natural numbers.

There are various types of generating functions, including **ordinary generating functions**, **exponential generating functions**, **Lambert series**, **Bell series**, and **Dirichlet series**; definitions and examples are given below. Every sequence has a generating function of each type. The particular generating function that is most useful in a given context will depend upon the nature of the sequence and the details of the problem being addressed.

Generating functions are often expressed in closed form as functions of a formal argument *x*. Sometimes a generating function is evaluated at a specific value of *x*. However, it must be remembered that generating functions are formal power series, and they will not necessarily converge for all values of *x*.

## Contents

## Definitions

*A generating function is a clothesline on which we hang up a sequence of numbers for display.*- — Herbert Wilf,
*generatingfunctionology*(1994)

### Ordinary generating function

The *ordinary generating function* of a sequence *a*_{n} is

When *generating function* is used without qualification, it is usually taken to mean an ordinary generating function.

If *a*_{n} is the probability mass function of a discrete random variable, then its ordinary generating function is called a probability-generating function.

The ordinary generating function can be generalised to sequences with multiple indexes. For example, the ordinary generating function of a sequence *a*_{m,n} (where *n* and *m* are natural numbers) is

### Exponential generating function

The *exponential generating function* of a sequence *a*_{n} is

### Lambert series

The *Lambert series* of a sequence *a*_{n} is

Note that in a Lambert series the index *n* starts at 1, not at 0.

### Bell series

The Bell series of an arithmetic function *f*(*n*) and a prime *p* is

### Dirichlet series generating functions

Dirichlet series are often classified as generating functions, although they are not strictly formal power series. The *Dirichlet series generating function* of a sequence *a*_{n} is

The Dirichlet series generating function is especially useful when *a*_{n} is a multiplicative function, when it has an Euler product expression in terms of the function's Bell series

If *a*_{n} is a Dirichlet character then its Dirichlet series generating function is called a Dirichlet L-series.

### Polynomial sequence generating functions

The idea of generating functions can be extended to sequences of other objects. Thus, for example, polynomial sequences of binomial type are generated by

where *p*_{n}(*x*) is a sequence of polynomials and *f*(*t*) is a function of a certain form. Sheffer sequences are generated in a similar way. See the main article generalized Appell polynomials for more information.

## Examples

Generating functions for the sequence of square numbers *a*_{n} = *n*^{2} are:

### Ordinary generating function

### Exponential generating function

### Bell series

### Dirichlet series generating function

## Another example

Generating functions can be created by extending simpler generating functions. For example, starting with

and replacing with , we obtain

## More detailed example — Fibonacci numbers

Consider the problem of finding a closed formula for the Fibonacci numbers *f*_{n} defined by *f*_{0} = 0, *f*_{1} = 1, and *f*_{n} = *f*_{n−1} + *f*_{n−2} for *n* ≥ 2. We form the ordinary generating function

for this sequence. The generating function for the sequence (*f*_{n−1}) is *Xf* and that of (*f*_{n−2}) is *X*^{2}*f*. From the recurrence relation, we therefore see that the power series *Xf* + *X*^{2}*f* agrees with *f* except for the first two coefficients. Taking these into account, we find that

(this is the crucial step; recurrence relations can almost always be translated into equations for the generating functions). Solving this equation for *f*, we get

The denominator can be factored using the golden ratio φ_{1} = (1 + √5)/2 and φ_{2} = (1 − √5)/2, and the technique of partial fraction decomposition yields

These two formal power series are known explicitly because they are geometric series; comparing coefficients, we find the explicit formula

## Applications

Generating functions are used to

- Find recurrence relations for sequences – the form of a generating function may suggest a recurrence formula.
- Find relationships between sequences – if the generating functions of two sequences have a similar form, then the sequences themselves are probably related.
- Explore the asymptotic behaviour of sequences.
- Prove identities involving sequences.
- Solve enumeration problems in combinatorics.
- Evaluate infinite sums.

## See also

## References

- Herbert S. Wilf,
*Generatingfunctionology (Second Edition)*(1994) Academic Press. ISBN 0127519564.

- Donald E. Knuth,
*The Art of Computer Programming, Volume 1 Fundamental Algorithms (Third Edition)*Addison-Wesley. ISBN 020189683-4*(Generating functions are discussed in section 1.2.9.)*

## External links

fr:Fonction génératrice he:פונקציה יוצרת it:Funzione generatrice ru:Производящая функция