<s>[INST] 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.
 [/INST] 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$$
</s>