<s>[INST] Find a closed form of the series $\sum_{n=0}^{\infty} n^2x^n$ The question I've been given is this:
Using both sides of this equation:
$$\frac{1}{1-x} = \sum_{n=0}^{\infty}x^n$$
Find an expression for $$\sum_{n=0}^{\infty} n^2x^n$$
Then use that to find an expression for
$$\sum_{n=0}^{\infty}\frac{n^2}{2^n}$$
This is as close as I've gotten:
\begin{align*}
\frac{1}{1-x} & = \sum_{n=0}^{\infty} x^n \\
\frac{-2}{(x-1)^3} & = \frac{d^2}{dx^2} \sum_{n=0}^{\infty} x^n \\
\frac{-2}{(x-1)^3} & = \sum_{n=2}^{\infty} n(n-1)x^{n-2} \\
\frac{-2x(x+1)}{(x-1)^3} & = \sum_{n=0}^{\infty} n(n-1)\frac{x^n}{x}(x+1) \\
\frac{-2x(x+1)}{(x-1)^3} & = \sum_{n=0}^{\infty} (n^2x + n^2 - nx - n)\frac{x^n}{x} \\
\frac{-2x(x+1)}{(x-1)^3} & = \sum_{n=0}^{\infty} n^2x^n + n^2\frac{x^n}{x} - nx^n - n\frac{x^n}{x} \\
\end{align*}
Any help is appreciated, thanks :)
 [/INST] We can write any monomial, or polynomial in $n$, as a falling factorial polynomial using Stirling numbers of the second kind or this simple algorithm.
After we can use the following identities of finite calculus
$$\Delta_n n^\underline m=(n+1)^\underline m- n^\underline m=m n^\underline{m-1},\quad \sum n^\underline m\delta n=\frac{n^\underline{m+1}}{m+1}+C\tag{1}$$
$$\Delta_n x^n=(x-1)x^n,\quad\sum x^n\delta n=\frac{x^n}{x-1}+C\tag{2}$$
$$\sum f(n)\Delta_n g(n)\delta n=f(n)g(n)-\sum \Delta_n f(n)\mathrm E_n g(n)\delta n\tag{3}$$
$$\sum_{n=0}^h f(n)=\sum\nolimits_0^{h+1} f(n)\delta n\tag{4}$$
where $\mathrm E_n g(n):=g(n+1)$ is the shift operator and $C$ is any $1$-periodic function. This case is particularly easy, we have that $n^2=n^\underline 2+n^\underline 1$, hence
$$\sum n^2 x^n\delta n=\sum n^\underline 2 x^n\delta n+\sum n^\underline 1 x^n\delta n=\frac{n^\underline 2x^n}{x-1}-\frac2{x-1}\sum n^\underline 1x^{n+1}\delta n+\sum n^\underline 1 x^n\delta n+C=\\=\frac{n^\underline 2x^n}{x-1}+\left(1-\frac{2x}{x-1}\right)\left(\frac{n^\underline1 x^n}{x-1}-\frac1{x-1}\sum x^{n+1}\delta n\right)+C=\\=\frac{n^\underline 2x^n}{x-1}-\frac{x+1}{(x-1)^3}\left((n+1)x^{n+1}-nx^n\right)+C$$
Then for $|x|<1$ from above we have that
$$\sum_{n=0}^\infty n^2x^n=\sum\nolimits_0^\infty n^2x^n\delta n=\frac{(x+1)x}{(x-1)^3}$$
</s>