Calculating value of series by taking the difference Apologies if this is a basic question!
I'm trying to understand a solution to a problem I was solving. The author suggests a trick to calculate expected value by multiplying the expected value series by 0.5 (line 2) and taking the difference (line 3):

$E(X) = 0.5^1 + 2 \cdot0.5^2 + 3\cdot 0.5^3...\\$
$0.5E(X) = 0.5^2 + 2 \cdot0.5^3 + 3\cdot 0.5^4...\\$
$0.5E(X) = 0.5^1 + 0.5^2 + 0.5^3...$

My question: how did he calculate the difference on line 3?
Thanks for your help.
 A: We have $$E = 0.5^1 + 2\cdot0.5^2 + 3\cdot0.5^3 + 4\cdot0.5^4+\cdots$$
$$0.5E = 0.5^2 + 2\cdot0.5^3 + 3\cdot0.5^4+\cdots$$
Combining terms with equal powers of $0.5$,$$E - 0.5E = 0.5^1 + 0.5^2(2-1) + 0.5^3(3-2) + 0.5^4 (4-3) \cdots$$
$$\implies 0.5E = 0.5^1 + 0.5^2+0.5^3\cdots$$
A: Subtract the second line from the first line
$$0.5E(X)=E(x)-0.5E(X)=$$
$$ 0.5^1 + 2 \cdot0.5^2 + 3\cdot 0.5^3...\\$$
$$- 0.5^2 - 2 \cdot0.5^3 - 3\cdot 0.5^4...=$$
$$ 0.5^1 + 0.5^2 + 0.5^3...$$
A: Here's a more "formal" way to write what you have, so it doesn't seem like so much of a trick. Since $$E(X) = \sum_{k \geq 1} \frac{k}{2^k},$$ we have
\begin{align*}
    \frac{E(x)}{2} &= \sum_{k \geq 1} \frac{k}{2^{k + 1}} \\
                   &= \sum_{k \geq 2} \frac{k - 1}{2^k} \\
                   &= \sum_{k \geq 2} \frac{k}{2^k} - \sum_{k \geq 2} \frac{1}{2^k} \\
                   &= E(x) - \frac{1}{2} - \frac{1}{2}.
\end{align*}
From this we can see that
\begin{equation*}
    E(x) = 2E(x) - 2,
\end{equation*}
or $E(x) = 2$.
This is something like a particularly nice example of the perturbation method to evaluate sums, which you can learn more about here or in various other sources online.
