TITLE: Solve $\sum nx^n$
QUESTION [13 upvotes]: I am trying to find a closed form solution for $\sum_{n\ge0} nx^n\text{, where }\lvert x \rvert<1$.
This solution makes sense to me:
$\sum_{n\ge0} x^n=(1-x)^{-1} \\
\frac{d}{d x} \sum_{n\ge0} x^n = \frac{d}{d x} (1-x)^{-1} \\
\sum_{n\ge0} nx^{n-1} = (1-x)^{-2} \\
x \sum_{n\ge0} n x^{n-1} = x(1-x)^{-2} \\
\sum_{n\ge0} nx^n=\frac x{(1-x)^2}$
However, a book I am reading used the following method:
$$\sum_{n\ge0}nx^n=\sum_{n\ge0}x\frac d{dx}x^n=
x\frac d{dx}\sum\limits_{n\ge0}x^n=x\frac d{dx}\frac1{1-x}=\frac x{(1-x)^2}$$
This seems closely related to the solution I described above, but I am having difficulty understanding it.  Can someone explain the method being used here?

REPLY [4 votes]: Both your and the book's development are the same. The advantage of the book's method is that it points at the following: If you want terms in $n x^n$, you get them by $x \dfrac{d}{dx} x^n$, to get $n^2 x^n$, you do $x \dfrac{d}{d x} \left(x \dfrac{d}{d x} x^n \right)$, and so on. If you use the notation $D$ for the operator $\dfrac{d}{d x}$, you can then write $n x^n = x D x^n$, $n^2 x^n = (x D)^2 x^n$, and in general $n^k x^n = (x D)^k x^n$, and if now $p(\cdot)$ is any polynomial, by combining several of the previous formulas you get $p(n) x^n = p(x D) x^n$.
Let $A(x) = \sum_{n \ge 0} a_n x^n$. This idea applied term by term to $A(x)$ is:
$$
\sum_{n \ge 0} p(n) a_n x^n = p(x D) A(x)
$$