<s>[INST] Solve $\sum nx^n$ 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?
 [/INST] Here's a solution that use neither differentiation nor integraion.  Since this question is marked as the duplicate target of How do I compute $\sum_{k=1}^{\infty} k \cdot p^k$, which no longer accepts new solution, I'm posting mine for fun.
Use summation by parts
$$S_N = \sum_{n=0}^N a_nb_n = a_N B_N - \sum_{n=0}^{N-1} B_n(a_{n+1}-a_n),$$
where $B_n = \sum_{k=0}^n b_k$ with $a_n = n$ and $b_n = x^n$ for all $n \in \Bbb{N}\cup\{0\}$ and $\lvert x\rvert<1$.
Use geometric sum formula to calculate $S_N$.
\begin{align}
B_n &= \sum_{k=0}^n x^k = \frac{1-x^{n+1}}{1-x} \\
a_{n+1}-a_n &= 1 \\
S_N &= N \cdot \frac{1-x^{N+1}}{1-x} - \sum_{n=0}^{N-1} \frac{1-x^{n+1}}{1-x} \\
&= \frac{1}{1-x} \left[(N- Nx^{N+1}) - \sum_{n=0}^{N-1} (1-x^{n+1}) \right] \\
&= \frac{1}{1-x} \left(- Nx^{N+1} + x\sum_{n=0}^{N-1} x^n\right) \\
&= \frac{1}{1-x} \left(- Nx^{N+1} + x \cdot \frac{1-x^N}{1-x} \right) \\
&= \frac{x}{(1-x)^2} - \frac{N(1+x)x^{N+1} + x^{N+1}}{(1-x)^2} \label{eqn} \tag{$\star$}
\end{align}
Take $N\to+\infty$ to kill the second term in \eqref{eqn}.
Hence $$\boxed{S = \lim_{N\to+\infty} S_N = \frac{x}{(1-x)^2}.}$$
</s>