Derive an explicit formula for a power series $\sum_{n=1}^\infty n^2x^n$
Solution 1:
We know that the power series for:
$$\sum_{n=1}^\infty nx^n = \frac{x}{(1-x)^2} \qquad |x| <1 $$
In order to find the power series for:
$$ \sum_{n=1}^\infty n^2x^n $$
We differentiate the first summation above:
$$\left(\sum_{n=1}^\infty nx^n\right)' = \sum_{n=1}^\infty n^2x^{n-1} = -\frac{x+1}{{(x-1)}^3} \qquad |x| <1$$
Finally, we multiply by $x$:
$$x\sum_{n=1}^\infty n^2x^{n-1} = \sum_{n=1}^\infty n^2x^{n} = -\frac{x(x+1)}{{(x-1)}^3}$$
Solution 2:
What if we didn't know $$ \sum_{n=1}^\infty n x^n = \frac{x}{(1-x)^2}, |x| < 1 \text{?} $$
Note that $n^2 = (n+2)(n+1)-3(n+1) + 1$. (Where did this come from? We'll get to that.) So $$ S(z) = \sum_{n=1}^\infty \left( (n+2)(n+1)-3(n+1) + 1 \right) z^n \text{.} $$ Assuming each of these converges on the same interval as the given series (which we will check later) we can rewrite this $$ S(z) = \sum_{n=1}^\infty (n+2)(n+1)z^n - 3 \sum_{n=1}^\infty (n+1)z^n + \sum_{n=1}^\infty z^n \text{.} $$ From back to front: \begin{align*} \sum_{n=1}^\infty z^n &= -1 + \sum_{n=0}^\infty z^n \\ &= -1 + \frac{1}{1-z} \text{,} \\ - 3 \sum_{n=1}^\infty (n+1)z^n &= - 3 \sum_{n=1}^\infty \frac{\mathrm{d}}{\mathrm{d}z} z^{n+1} \\ &= - 3 \frac{\mathrm{d}}{\mathrm{d}z} \sum_{n=1}^\infty z^{n+1} \\ &= - 3 \frac{\mathrm{d}}{\mathrm{d}z} \sum_{n=2}^\infty z^n \\ &= - 3 \frac{\mathrm{d}}{\mathrm{d}z} \left( -1-z + \sum_{n=0}^\infty z^n \right) \\ &= - 3 \frac{\mathrm{d}}{\mathrm{d}z} \left( -1-z + \frac{1}{1-z} \right) \\ &= - 3 \left( 0 -1 + \frac{1}{(1-z)^2} \right) \\ &= 3 + \frac{-3}{(1-z)^2} \text{, and} \\ \sum_{n=1}^\infty (n+2)(n+1)z^n &= \sum_{n=1}^\infty \frac{\mathrm{d}^2}{\mathrm{d}z^2} z^{n+2} \\ &= \frac{\mathrm{d}^2}{\mathrm{d}z^2} \sum_{n=1}^\infty z^{n+2} \\ &= \frac{\mathrm{d}^2}{\mathrm{d}z^2} \sum_{n=0}^\infty z^{n+3} \\ &= \frac{\mathrm{d}^2}{\mathrm{d}z^2} \left(z^3 \sum_{n=0}^\infty z^{n} \right) \\ &= \frac{\mathrm{d}^2}{\mathrm{d}z^2} \frac{z^3}{1-z} \\ &= \frac{2(z^3 - 3z^2 + 3z)}{(1-z)^3} \\ &= \frac{6z}{1-z} + \frac{6z^2}{(1-z)^2} + \frac{2z^3}{(1-z)^3} \text{.} \end{align*} Adding up the three pieces, $$ S(z) = \frac{z(1+z)}{(1-z)^3} \text{.} $$ In each case, we used the geometric series $\frac{1}{1-z} = \sum_{n=0}^\infty z^n$, which converges on $(-1,1)$. By the ratio test, the given series also converges on $(-1,1)$. At $z = -1$ and at $z = 1$, the terms of the series don't converge to zero so neither endpoint is in the interval of convergence. Therefore, the resulting function agrees with the series on its interval of convergence.
So where did $n^2 = (n+2)(n+1)-3(n+1) + 1$ come from? I hope from the above it is obvious that we wanted the coefficients to be "constants time increasing products of $n+1$, $n+2$, ... of whatever length was needed" so that we could replace the "$(n+k)\cdots(n+1)z^{n}$" with $\frac{\mathrm{d}^k}{\mathrm{d}z^k} z^{n+k}$, exchange differentiation and summation, adjust the index, cancel the missing terms from the geometric series, then replace with the geometric series.
(An alert reader will notice I haven't said where the identity came from, only why it was useful.) Notice that we want coefficients that are "rising factorials" in the index $n$ (strictly in $n+1$). This is a job for Stirling numbers. And there is a lot of fun structure to discover in those numbers. However, we might be thinking "isn't this a little too hard?". Maybe. We can go another way without seeing the cool set of numbers doing the work for us. \begin{align*} S(z) &= \sum_{n=1}^\infty n^2 z^n \\ &= \sum_{n=1}^\infty n(n+1-1) z^n \\ &= \sum_{n=1}^\infty \left( n(n+1) z^n - n z^n \right) \\ &= \sum_{n=1}^\infty \left( \frac{\mathrm{d}}{\mathrm{d}z} n z^{n+1} - n z^n \right) \\ &= \sum_{n=1}^\infty \left( \frac{\mathrm{d}}{\mathrm{d}z} (n+2-2) z^{n+1} - n z^n \right) \\ &= \sum_{n=1}^\infty \left( \frac{\mathrm{d}}{\mathrm{d}z} (n+2) z^{n+1} - \frac{\mathrm{d}}{\mathrm{d}z} 2 z^{n+1} - n z^n \right) \\ &= \sum_{n=1}^\infty \left( \frac{\mathrm{d}^2}{\mathrm{d}z^2} z^{n+2} - 2 \frac{\mathrm{d}}{\mathrm{d}z} z^{n+1} - (n+1-1) z^n \right) \\ &= \sum_{n=1}^\infty \left( \frac{\mathrm{d}^2}{\mathrm{d}z^2} z^{n+2} - 2 \frac{\mathrm{d}}{\mathrm{d}z} z^{n+1} - (n+1) z^n + z^n \right) \\ &= \sum_{n=1}^\infty \left( \frac{\mathrm{d}^2}{\mathrm{d}z^2} z^{n+2} - 2 \frac{\mathrm{d}}{\mathrm{d}z} z^{n+1} - \frac{\mathrm{d}}{\mathrm{d}z} z^{n+1} + z^n \right) \\ &= \sum_{n=1}^\infty \left( \frac{\mathrm{d}^2}{\mathrm{d}z^2} z^{n+2} - 3 \frac{\mathrm{d}}{\mathrm{d}z} z^{n+1} + z^n \right) \text{,} \end{align*} where our new friends, the Stirling numbers have reappeared as the coefficients (the same coefficients in the identity starting this Answer). You should be able to split thisinto three sums, exchange differentiation and summation in two of them, adjust the index in all three, cancel the missing terms from the geometric series, then replace with the geometric series, as was done in the work shown above.
That's great and all, but surely there's a way to avoid so much writing? Having done all the above, we now know what we are trying to do -- replace the two copies of $n$ in "$n^2$" with a sum of constant multiples of derivatives, so just start there, the same as we start with the correct form for partial fractions and solve for the coefficients. We require (starting with the power of $z$ we have in the general term and incrementing the power in parallel with incrementing the repetition of the derivative) \begin{align*} n^2 z^n &= A z^n + B \frac{\mathrm{d}}{\mathrm{d}z} z^{n+1} + C \frac{\mathrm{d}^2}{\mathrm{d}z^2} z^{n+2} \\ &= A z^n + B (n+1) z^{n} + C(n+2)(n+1) z^{n} \\ &= \left( A + B (n+1) + C(n+2)(n+1) \right) z^{n} \\ &= \left( A + Bn + B + Cn^2 + 3Cn + 2C \right) z^{n} \\ &= \left( (A + B + 2C) + (B + 3C)n + Cn^2 \right) z^{n} \text{.} \end{align*} For two polynomials to agree, they agree in each coefficient, so $C = 1$, $B+3C = 0$, so $B = -3$, and $A+B+2C = 0$, so $A = 1$. And, surprise(?) we immediately get the Stirling numbers again. And, using the methods shown above, we know what to do with the sums obtained from each term in the first line.