This question already has an answer here:

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?


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).


marked as duplicate by Martin Sleziak, azimut, Start wearing purple, Lord_Farin, Julian Kuelshammer May 29 '13 at 9:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Edited to do the summation from 0, not 1. Better reflects what I'm trying to work out. $\endgroup$ – Clinton May 29 '13 at 3:16
  • $\begingroup$ But the first term vanishes when $n=0$! What's the point of it? $\endgroup$ – Pedro Tamaroff May 29 '13 at 3:17
  • $\begingroup$ That's a good point. Rolled back. $\endgroup$ – Clinton May 29 '13 at 3:18
  • 1
    $\begingroup$ See also math.stackexchange.com/q/30732 $\endgroup$ – Jonas Meyer May 29 '13 at 3:23
  • $\begingroup$ This have been asked on this site before. You might have a look here, here or here; and also other questions linked to those questions. You will probably find more similar questions just by browsing frequent tab in the tags. sequences-and-series and summation. $\endgroup$ – Martin Sleziak May 29 '13 at 7:35

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)$$

  • $\begingroup$ Why does the start bound change from $n=0$ to $n=1$ in the second line of math? $\endgroup$ – Daniel Centore Dec 3 '15 at 8:24
  • $\begingroup$ Because if you evaluate the 0th term, it is zero, so it is simpler to start at $n=1.$ $\endgroup$ – BSplitter Oct 10 '17 at 20:34

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}$.


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}$.


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.


$\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.


Not the answer you're looking for? Browse other questions tagged or ask your own question.