Please show me how to calculate the sum of this infinite series:
$$\sum_{n=1}^{\infty}n^2 q^{n-1}$$
I should have included the condition $\mid q\mid$<1
And I was able to solve the infinite series of $$S_n=\sum_{n=1}^{\infty}n q^{n-1}=1+2q+3 q^2+4q^3...$$ The trick is to calculate $$q S_{n}=\sum_{n=1}^{\infty}n q^{n}=q+2q^2+3q^3+...$$ And find out that $$S_{n}-q S_{n}=\sum_{n=1}^{\infty}=1+q+q^2+q^3+...=\sum_{n=1}^{\infty}q^n=\frac{1}{1-q}$$ And thus $$S_{n}=\frac{\frac{1}{1-q}}{1-q}=\frac{1}{(1-q)^2}$$
But I was not able to use same trick on the series I want to solve.
P.S. @user17762 has provided a genius way to handle this kind of series and his approach could simplify the calculation of $\sum_{n=1}^{\infty}n q^{n-1}$ too. Just watch the first two steps he used.