# Two questions about generating functions

I'm very interested in the topic of generating functions, so I have two questions:

1. I just realized that when I have exponential generating function for example $F(x)=e^{e^x-1}$, I can take n-th derivative and count the value in $x=0$ to get n-th element of sequence that this function represents. It's very useful I think :-) but are the ordinary generating functions that useful too? Is there any operation on ordinary generating function that can help me count the n-th element of sequence that this function represents?
2. Here: http://en.wikipedia.org/wiki/Generating_function#Examples we have got exponential generating function for sequence $a_n=n^2$. It's simple to find the ordinary generating function for this sequence (taking derivatives and subtracting something) but how can I deduce that $\displaystyle \sum_{n=0}^{+\infty}n^2\frac{x^n}{n!}=x(x+1)e^x$?
-

## 2 Answers

(1) Just do the same and divide by $n!$ then.

(2) We have \begin{align*} \sum_{n=0}^{\infty} n^2 \frac{x^n}{n!} &= \sum_{n=1}^\infty n \frac{x^n}{(n-1)!}\\ &= x \sum_{n=1}^\infty n\frac{x^{n-1}}{(n-1)!}\\ &= x \sum_{n=1}^\infty \bigl((n-1)+1\bigr)\frac{x^{n-1}}{(n-1)!}\\ &= x\sum_{n=2}^\infty \frac{x^{n-1}}{(n-2)!} + x\exp(x)\\ &= x^2\exp(x) + x\exp(x)\\ &= x(x+1)\exp(x). \end{align*}

HTH, AB,

-
brilliant! thanks a lot :-) – xan Mar 22 '12 at 13:46

Another way. Note that for any sequence $a_n$, with $A(z) = \sum_{n \ge 0} a_n \frac{z^n}{n!}$

\begin{align} z \frac{\mathrm{d}}{\mathrm{d} z} A(z) &=z \sum_{n \ge 0} a_n \frac{z^{n - 1}}{(n - 1)!} \\ &= \sum_{n \ge 0} n a_n \frac{z^n}{n!} \end{align}

Thus you get what you want by doing the above twice to $\mathrm{e}^z$:

\begin{align} z \frac{\mathrm{d}}{\mathrm{d} z} \left( z \frac{\mathrm{d}}{\mathrm{d} z} \mathrm{e}^z \right) &= z \frac{\mathrm{d}}{\mathrm{d} z} \left( z \mathrm{e}^z \right) \\ &= z \left( \mathrm{e}^z + z \mathrm{e}^z \right) \\ &= (z + z^2) \mathrm{e}^z \end{align}

-