# Summing with Generating Functions

A nice challenge puzzle via Reddit:

Find $\sum_{n=1}^{\infty} \frac{n2^n}{(n+2)!}$

There was a video attached to it that I didn’t watch, something about telescoping sums, but the moment I saw this, I thought: *generating functions*!

### Why would I think such a thing?

The thing that jumped out at me was the $n$ on top: that looks to me like its something I could integrate and divide away. It looks like an infinite sum with factorials on the bottom, which will be related to $e^{something}$. Let’s have a look, shall we?

I’m going to call the whole thing $s$, and write it as $s(x) = 2 \sum_{n=1}^{\infty} \frac{n x^{n-1}}{(n+2)!}$, and we’re eventually going to evaluate it at $x=2$.

But first, I’ll integrate term by term to get $S = \int s(x) \dx = 2\sum_{n=1}^{\infty} \frac{ x^n }{(n+2)!}$, or $C+\frac{x}{3!} + \frac{x^2}{4!} + \dots$. (I’m going to ignore the constant, reasoning that it’ll differentiate away in good time.)

So what is this function? Well, $e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \dots$, and I’m mainly interested in matching up the bottoms. So, if I want to something starting with $\frac{x}{3!}$, I’m going to need to subtract the first three terms and divide by $x^2$ to get $S(x) = \frac{2}{x^2}\left( e^x - \frac{1}{2}x^2 - x - 1\right)$.

Now to differentiate, using product rule, to get $s(x) = \frac{2}{x^2}\left(e^x - x - 1\right) - \frac{4}{x^3}\left(e^x - \frac{1}{2}x^2 - x - 1\right)$.

We can evaluate that at $x=2$ to get $\frac{2}{4}\left(e^2 - 3\right) - \frac{4}{8}\left(e^2 - 5\right)$… which is $-\frac{3}{2} + \frac{5}{2}$, which is 1!

Reassuringly, that’s what the video got, too.