Summing weighted geometric series
Introduction
In various applications you may be confronted with summing a series that takes on the form $$\sum_{n=0}^{\infty} np^n$$. In this post we will explore a couple different ways to sum up this series, along with some extensions.
To warm up, let's start with the geometric series $$S = \sum_{n=0}^\infty p^n$$ (for $$p<1$$). The formula for $$S$$ is well known and there are multiple ways to get to the answer. Let's look at a simple one here:
$$ S = 1 + p + p^2 + p^3 + ... = 1 + p(\underbrace{1 + p + p^2 + ...}_S) = 1 + pS$$, which simplifies to $$S = {1 \over 1-p} = S_1(p)$$.
Analysis
Now let's get back to the task at hand. Define $$S_2(p) = \sum_{n=0}^{\infty} np^n$$. The series can be expanded out as:
$$S_2(p) = p + 2p^2 + 3p^3 + ...$$. Let's multiply both sides by $$p$$ to get:
$$pS_2(p) = p^2 + 2p^3 + 3p^4 + ...$$.
If we subtract the second equation from the first we get:
$$(1-p)S_2(p) = p + p^2 + p^3 + ... = p(1+p+p^2+...) = pS_1(p)$$, implying $$S_2(p) = {p \over (1-p)^2}$$.
That was easy; let's look at an even more elegant solution, starting with $$S_1(p)$$. Recall that we previously derived:
$$\sum_{n=0}^\infty p^n = 1 + \sum_{n=1}^\infty p^n = {1 \over 1-p}$$. Let's differentiate both sides with respect to $$p$$ to get:
$$\sum_{n=1}^\infty n p^{n-1} = {1 \over (1-p)^2}$$. Multiplying both sides by $$p$$, we get:
$$\sum_{n=0}^\infty np^n = S_2(p) = {p \over (1-p)^2}$$.
We glossed over some technical details which allowed us to interchange the summation and differentiation operators in the analysis presented above.
Now, let's try the differentiation approach one more time.
$$\sum_{n=0}^\infty np^n = \sum_{n=1}^\infty np^n = {p \over (1-p)^2}$$. Differentiating with respect to $$p$$ gives:
$$\sum_{n=1}^\infty n^2p^{n-1} = {1+p \over (1-p)^3}$$, implying
$$\sum_{n=1}^\infty n^2 p^n = {p(1+p) \over (1-p)^3} = \sum_{n=0}^\infty n^2 p^n = S_3(p) $$.
We can continue the differentiation and derive expressions for $$\sum_{n=0} n^k p^n$$, though it seems hard to come up with a general expression for arbitrary $$k$$.
Addendum
Let's do a slightly different example, where we multiply $$S_2(p)$$ with $$p$$ before differentiating.
$$pS_2(p) = \sum_{n=0}^\infty np^{n+1} = {p^2 \over (1-p)^2}$$, differentiating which gives:
$$pS_2'(p) + S_2(p) = \sum_{n=0}^\infty n(n+1)p^n = S_2(p) + S_3(p) = {2p \over (1-p)^3}$$, implying
$$S_3(p) = S_2'(p)$$. It is easy to show that $$S_k(p) = S_{k-1}'(p)$$ for $$k>1$$. This can be used iteratively to express $$S_k(p)$$ as a function $$S_1(p)$$ and it's derivatives.
As a parting note, the approaches outlined above can be easily extended to sum a series of the form $$\sum_{n=0}^\infty a_n p^n$$, where $$a_n$$ is an arithmetic progress ($$a_n=n$$ is a special case) and also to address the case where the number of terms in the summation are finite (albeit at the expense of more cumbersome algebra).
Here to share a few nuggets of my math wisdom with the world and to learn from you!