<s>[INST] Show the closed form of the sum $\sum_{i=0}^{n-1} i x^i$ Can anybody help me to show that when $x\neq 1$
$$\large \sum_{i=0}^{n-1} i\, x^i = \frac{1-n\, x^{n-1}+(n-1)\,x^n}{(1-x)^2}$$
 [/INST] The following chain of identities gives the closed form without using calculus.
$$\sum_{i=1}^n i x^i= \sum_{k=0}^{n-1} x^{n-k} \sum_{i=0}^k x^i=$$ $$=\sum_{k=0}^{n-1} x^{n-k} \frac{x^{k+1}-1}{x-1}=\frac{1}{x-1}\sum_{k=0}^{n-1}(x^{n+1}-x^{n-k})=$$ $$=\frac{x^n}{x-1}\sum_{k=0}^{n-1}(x-x^{-k})=\frac{x^n}{x-1}(n x-\frac{\frac{1}{x^n}-1}{\frac{1}{x}-1})=$$ $$=\frac{1}{x-1}(n x^{n+1}-\frac{x-x^{n+1}}{1-x})=\frac{nx^{n+2}-(n+1)x^{n+1}+x}{(x-1)^2}$$
In response to comments: I have indexed the sum in a slightly different manner than in the question asked. To derive the formula asked for, just notice that $$\sum_{i=0}^{n-1} i x^i=\sum_{i=1}^n i x^i -n x^n=\frac{nx^{n+2}-(n+1)x^{n+1}+x}{(x-1)^2}-nx^n=\frac{nx^{n+2}-(n+1)x^{n+1}+x-n x^n(x-1)^2}{(x-1)^2}=\frac{nx^{n+2}-(n+1)x^{n+1}+x-nx^{n+2}+2nx^{n+1}-nx^n}{(x-1)^2}=\frac{(n-1)x^{n+1}-nx^{n}+x}{(x-1)^2}$$
</s>