How to fit $\sum{n^{2}x^{n}}$ into a generating function?

I do have somewhat of a reasoning for this.

$$S = 1 + x + x^{2} + x^{3} +.. + x^{n} $$

Denoting the derivative of $S$ as $T$

$$T = 1 + 2x + 3x^{2} + 4x^{3} +... + nx^{n-1}$$

$$xT = x + 2x^{2} + 3x^{3} +... + nx^{n}$$

Writing the derivative of this series as $V$

$$V = 1 + 2^{2}x + 3^{2}x^{2} +... + n^{2}x^{n-1}$$

$$xV = x + 2^{2}x^{2} + 3^{2}x^{2} +... + n^{2}x^{n}$$

Which is ${\sum{n^{2}x^{n}}}$

However, I am unable to start from $\sum{n^{2}}$and finish where I started. Can someone give me systematic steps on how to manipulate ${\sum{n^{2}x^{n}}}$into a generating function?

The answers are a little different from what I expected.

Let me explain with $\sum nx^{n}$. This function is not the series of any known function but with one slight manipulation, we can change it.

$$\sum x\frac {d x^{n}}{dx}$$ $$=x \frac{d}{dx} {\sum x^{n}} = x\frac {d}{dx} \frac{1}{1-x}$$ $$=\frac {x}{ (1-x)^2 }$$

I wanted a similar trick for evaluating $\sum n^{2}x^{n}$ $$=\sum nx \frac{d}{dx} x^{n}$$ And, then what ? How can I finish this ? I know how to start at $S$ and finish here, but I'm having trouble doing the algebra of starting with this sum and finishing where I started.


Following the comment from Did, we go $$\sum_nn^2x^n=\sum_nx{d\over dx}x{d\over dx}x^n=x{d\over dx}x{d\over dx}\sum_nx^n$$ and you know what to do from there.


If you have:

$\begin{align} A(z) = \sum_{n \ge 0} a_n z^n \end{align}$

then it is easy to see that:

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

To multiply each coefficient by $n^r$, apply the above $r$ times.

Furthermore, it is easy to check that:

$\begin{align} \frac{A(z)}{1 - z} \sum_{n \ge 0} \left(\sum_{0 \le k \le n} a_n \right) z^n \end{align}$

In your case:

$\begin{align} \frac{1}{1 - z} &= \sum_{n \ge 0} z^n \\ z \frac{\mathrm{d}}{\mathrm{d} z} \left( z \frac{\mathrm{d}}{\mathrm{d} z} \frac{1}{1 - z} \right) &= z \frac{\mathrm{d}}{\mathrm{d} z} \frac{z}{(1 - z)^2} \\ &= \frac{z (1 + z)}{(1 - z)^3} \end{align}$

It is easy to extract the coefficient of $z^n$ of this divided by $1 - z$:

$\begin{align} [z^n] \frac{z + z^2}{(1 - z)^4} &= [z^n] (z + z^2) \sum_{k \ge 0} (-1)^k \binom{-4}{k} z^k \\ &= ([z^{n - 1}] + [z^{n - 2}]) \sum_{k \ge 0} \binom{k + 4 - 1}{4 - 1} z^k \\ &= \binom{n - 1 + 3}{3} + \binom{n - 2 + 3}{3} \\ &= \binom{n + 2}{3} + \binom{n + 1}{3} \\ &= \frac{(n + 2) (n + 1) n}{3!} + \frac{(n + 1) n (n - 1)}{3!} \\ &= \frac{(n + 1) n (2 n + 1)}{6} \end{align}$

Another way, as you state, is to start with:

$\begin{align} 1 + z + \dotsb + z^n = \frac{1 - z^{n + 1}}{1 - z} \end{align}$

mangle it twice as above, and evaluate for $z = 1$. That requires using l'Hôpital to compute a limit, the resulting expression isn't defined at $z = 1$.