How to calculate: $\sum_{n=1}^{\infty} n a^n$ I've tried to calculate this sum:
$$\sum_{n=1}^{\infty} n a^n$$
The point of this is to try to work out the "mean" term in an exponentially decaying average.
I've done the following:
$$\text{let }x = \sum_{n=1}^{\infty} n a^n$$
$$x = a + a \sum_{n=1}^{\infty} (n+1) a^n$$
$$x = a + a (\sum_{n=1}^{\infty} n a^n + \sum_{n=1}^{\infty} a^n)$$
$$x = a + a (x + \sum_{n=1}^{\infty} a^n)$$
$$x = a + ax + a\sum_{n=1}^{\infty} a^n$$
$$(1-a)x = a + a\sum_{n=1}^{\infty} a^n$$
Lets try to work out the $\sum_{n=1}^{\infty} a^n$ part:
$$let y = \sum_{n=1}^{\infty} a^n$$
$$y = a + a \sum_{n=1}^{\infty} a^n$$
$$y = a + ay$$
$$y - ay = a$$
$$y(1-a) = a$$
$$y = a/(1-a)$$
Substitute y back in:
$$(1-a)x = a + a*(a/(1-a))$$
$$(1-a)^2 x = a(1-a) + a^2$$
$$(1-a)^2 x = a - a^2 + a^2$$
$$(1-a)^2 x = a$$
$$x = a/(1-a)^2$$
Is this right, and if so is there a shorter way?
Edit:
To actually calculate the "mean" term of a exponential moving average we need to keep in mind that terms are weighted at the level of $(1-a)$. i.e. for $a=1$ there is no decay, for $a=0$ only the most recent term counts.
So the above result we need to multiply by $(1-a)$ to get the result:
Exponential moving average "mean term" = $a/(1-a)$
This gives the results, for $a=0$, the mean term is the "0th term" (none other are used) whereas for $a=0.5$ the mean term is the "1st term" (i.e. after the current term).
 A: First, you need to assume that the sum exists, which it might not. For example, if $a\geq 1$, then the sum is infinite.
But, assuming that the sum exists, a better way to rewrite what you are saying is
$$\begin{array} {l l l l l l l }
x & = 1a^1 & + 2a^2 &+ 3 a^3 & + \;\cdots \\
ax & =    & + 1a^2 & + 2 a^3 & + \;\cdots \\
\hline
(1-a) x &= 1a^1 & + 1a^2 & + 1 a^3 & + \;\cdots \\
\end{array}$$
[Note: This is exactly the same as your first paragraph of math, but presented in a slightly different way that makes it more obvious.]
At this stage, you can similarly show that $a + a^2 + \cdots = \dfrac{a}{1-a}$, to reach your conclusion that $x = \dfrac{a}{(1-a)^2}$.
A: Your approach is really quite good,
and a nice way of discovering the result,
as opposed to deriving an already known result.
The only change I would make is to
make the upper limit of the sum a variable,
and let that go to $\infty$ if you want.
Besides, the finite sum is often useful.
So, let
$S(a, m)=\sum_{n=0}^{m} n a^n$.
I prefer to have the sum start at $0$,
and it doesn't change the result.
Then 
$\begin{align}
S(a, m)
&=0+\sum_{n=1}^{m} n a^n\\
&= a\sum_{n=1}^{m} n a^{n-1}\\
&= a\sum_{n=0}^{m-1} (n+1) a^{n}\\
&= a\big(\sum_{n=0}^{m-1} n a^{n} + \sum_{n=0}^{m-1} a^{n}\big)\\
&=a(S(a, m-1)+T(a, m-1))\\
\end{align}
$
where
$T(a, m)= \sum_{n=0}^{m} a^{n}$.
We now do the same thing for $T$,
with the difference that the term for $n=0$ is not $0$.
$\begin{align}
T(a, m)
&=1+\sum_{n=1}^{m}  a^n\\
&= 1+a\sum_{n=1}^{m} a^{n-1}\\
&= 1+a\sum_{n=0}^{m-1} a^{n}\\
&=1+aT(a, m-1)\\
\end{align}
$
Since $T(a, m-1)
= T(a, m)-a^m$,
$T(a, m) = 1+a(T(a, m)-a^m)
=1+aT(a, m)-a^{m+1}$
so $T(a, m) = (a^{m+1}-1)/(a-1)$.
Putting this in the equation for $S$,
$S(a, m) = a(S(a, m-1)+\frac{a^m-1}{a-1})$.
Again, since $S(a, m-1) = S(a, m)-m a^m$,
$\begin{align}
S(a, m) &= a(S(a, m-1)+\frac{a^m-1}{a-1})\\
&= a(S(a, m)-m a^m+\frac{a^m-1}{a-1})\\
&= aS(a, m)+\frac{a(a^m-1)-m a^{m+1}(a-1)}{a-1}\\
&= aS(a, m)+\frac{a^{m+1}-a-m a^{m+2}+m a^{m+1}}{a-1}\\
&= aS(a, m)-\frac{m a^{m+2}+(m+1) a^{m+1}+a}{a-1}\\
\end{align}
$
so
$(a-1)S(a, m) = \frac{m a^{m+2}+(m+1) a^{m+1}+a}{a-1}$
and
$S(a, m) = \frac{m a^{m+2}+(m+1) a^{m+1}+a}{(a-1)^2}$.
If $|a| < 1$, if we let $m \to \infty$ in the expressions
for $T$ and $S$,
we get
$T(a, \infty) = 1/(1-a)$
and
$S(a, \infty) = a/(1-a)^2$.
Note that by writing
$S(a, m)$ (and, similarly, $T(a, m)$)
in two ways in terms of $S(a, m-1)$,
we avoided having to discover
the expression for $S(a, m)$.
Again, this is certainly not the best way to
$verify$ the formulas
for $S(a, m)$ and $T(a, m)$,
but it is a way to $discover$ them.
A: Yes, you're right. 
Shorter way: note your series is $$a\frac{d}{da}\frac{1}{1-a}=\frac{a}{(1-a)^2}$$
That is $$\frac{1}{1-a}=\sum_{n=0}^\infty a^n\implies a\frac{d}{da}\frac{1}{1-a}=a\sum_{n=1}^\infty na^{n-1}=\sum_{n=1}^\infty na^{n}$$
ADD. In general one can find $$\sum_{n=1}^\infty n^kx^n=\left(x\frac{d}{dx}\right)^k\frac{1}{1-x}=\frac{\varphi_k(x)}{k!}\left(\frac d{dx}\right)^k\frac 1 {1-x}= \frac{\varphi_k(x)}{k!}\frac{1}{(1-x)^{k+1}}$$
where $\varphi_k(x)$ are the Eulerian polynomials $$\varphi_1(x)=x$$ $$\varphi_{k+1}(x)=x(1-x)\varphi_{k}^\prime(x)+(k+1)x\varphi_k(x)$$
or $$\varphi_k(x)=\sum_{m=1}^k E(m,k)x^m$$ where $E(m,k)=0$ if $m\leq 0$ or $m>k$ and $$E(m,k+1)=mE(m,k)+(k-m+2)E(m-1,k)$$
A: We give a mean proof, at least for the case $0\lt a\lt 1$. Suppose that we toss a coin that has probability $a$ of landing heads, and probability $1-a$ of landing heads. Let $X$ be the number of tosses until the first tail. Then $X=1$ with probability $1-a$, $X=2$ with probability $a(1-a)$, $X=3$ with probability $a^2(1-a)$, and so on. Thus
$$E(X)=(1-a)+2a(1-a)+3a^2(1-a)+4a^3(1-a)\cdots.\tag{$1$}$$
Note that by a standard convergence test, $E(X)$ is finite.
Let $b=E(X)$. On the first toss, we get a tail with probability $1-a$. In that case, $X=1$. If on the first toss we get a head, it has been a "wasted" toss, and the expected number of tosses until the first tail is $1+b$. Thus
$$b=(1-a)(1)+a(1+b).$$
Solve for $b$. We get $b=\dfrac{1}{1-a}$.
But the desired sum $a+2a^2+3a^3+\cdots$ is $\dfrac{a}{1-a}$ times the sum in $(1)$. Thus the desired sum is $\dfrac{a}{(1-a)^2}$.
