Q:

What's the sum of the series $\sum _{n=0}^{\infty }\left(n^2a^n\right)$

$\sum _{n=0}^{\infty }\left(n^2a^n\right)$, I have seen a similar sum with just $n$ instead of the $n^2$, yet I'm not sure how to solve this one.

A:

I assume $0<|a|<1$. Let $S = \sum_n a^n$, $T = \sum_n n^2 a^n$. Observe that $S(n) = \frac{1}{1-a}$ (geometric series) which implies $\frac{d}{da} S = \frac{1}{(1-a)^2}$ and $\frac{d}{da} S = \frac{-2}{(1-a)^3}$. Then 
$$\frac{d^2}{da^2} S = \sum_n n(n-1)a^{n-2} = \frac{1}{a^2} \underbrace{\sum_n n^2 a^n}_{=T}- \frac{1}{a}\underbrace{\sum_n n a^{n-1}}_{=\frac{d}{da} S} = \frac{1}{a^2} T-\frac{1}{a} \frac{d}{da}S.$$ Now let us replace $\frac{d}{da} S$ and $\frac{d^2}{da^2} S$ with the terms we calculated above and we get:
$$\frac{-2}{(1-a)^3} = \frac{1}{a^2} T - \frac{1}{a} \frac{1}{(1-a)^2}$$
This can now easily be solved for $T$.

