Evaluate $$\sum_{n=1}^\infty \frac{n}{2^n}$$
My Work:
$$\sum_{n=1}^\infty \frac{n}{2^n} = \sum_{n=1}^\infty n \left(\frac{1}{2}\right)^n$$
If we denote $f(x) = \sum_{n=1}^\infty nx^n$ then we wish to evaluate $f(1/2)$.
Now, $$\sum_{n=1}^\infty nx^n = x \sum_{n=1}^\infty nx^{n-1} = x\sum_{n=1}^\infty (x^n)' = x\left(\sum_{n=1}^\infty x^n\right)' = x \left(\frac{-x}{1-x}\right)' = \frac{-x}{(1-x)^2}$$
Applying $x=1/2$ we get the wrong result of $-2$.
Where is my mistake?