# Calculus of generating functions

This lesson assumes you have a working knowledge of the topics presented in the following lessons: Introduction to generating functions |

The main idea behind the **calculus of generating functions** is to figure out how to compute the generating function of a sequence that is the product (or sum, etc.) of two other sequences whose generating functions are known. There are different rules for dealing with different types of generating functions; for instance, the rules that hold for manipulating ordinary generating functions may have analogues with their exponential generating function counterparts, but the rules are often not the same. Hence, we must be careful when manipulating formal power series, and note which type of generating function we're working with.

## Ordinary generating functions

[edit | edit source]Similar to differentiation in the subject of calculus, we have a lot of rules we can use to manipulate ordinary power series. We'll start with the **shift rule**.

### Shift rule

[edit | edit source]To start, let's consider an easy example. Suppose we have that

- ,

and we want to find the generating function for the sequence . Formally, we want the function *g*(*x*) that has power series representation

- .

Since we know that

- ,

We have that

- ,

and reindexing gives

- .

Finally, dividing both sides by *x*, we achieve

- ,

which was precisely the function we wanted. Setting , we now have

- , as desired.

From this example, we can derive a rule.

- Shift rule

If , then the ordinary generating function for the sequence is the function

### Polynomial multiplier rule

[edit | edit source]Again, let

- .

Suppose we want the generating function for . How can we get this to come about?

Here, we have to be a bit more clever than we were with the shift rule above. Notice that if then

which is *almost* what we want. If we multiply both sides by *x*, we get

which is *exactly* what we want. So, if

then

Immediately, we see the use for some operator notation; notation that will tell us to perform the operation "differentiate *f* once with respect to *x*, then multiply the result by *x*".

We elect to use notation similar to Euler's differential operator (for ease); that is, *D*. To express this more precisely, we'll stipulate that

and that

Applying a similar idea to the one above, if we want to find the OPS for given the generating function for , we would apply the "*xD*" operator twice. Notation for this would be

and in words means "differentiate *f*, multiply by *x*, differentiate again, and then multiply by *x*". This leads to the intermediate rule that
whenever *f* is the generating function for the sequence . Now that we have a rule for multiplying a sequence by *n*^{k}, by default we have a rule for multiplying a sequence by any polynomial in *n*.

- Polynomial multiplier rule

If

and *p* is any polynomial, then