I describe a useful trick for computing geometric series without closed-form solutions.
Published
02 September 2021
I can never remember the closed-form solution for the sum of an infinite geometric series,
a+ar+ar2+ar3+…(1)
However, there is actually a rather elegant way to quickly re-derive this result, which I discovered while working on probability puzzles in (Joshi et al., 2013). Let s be the infinite sum in Equation 1. Now subtract rs from s:
srss−rs=a+ar+ar2+ar3+…=ar+ar2+ar3+ar4+…⇓=a.(2)
That’s it. All the terms cancel except for a, and we’re left with
s=1−ra.(3)
Of course, this logic still applies when the series is finite:
When I discovered this well-known result, I was trying to re-derive the variance of a geometric random variable, since I could not remember it. In fact, computing both the mean and variance of a geometric random variable can be done using the same trick to construct the closed-form expression in Equation 3.
Let’s setup the problem. Imagine I flip a coin with bias p until I get a heads. Let q≜1−p, and let N denote the number of tosses until I get a heads. Then N is a geometric random variable with parameter p. Let’s derive E[N] and V[N] without relying on basic properties of the geometric distribution, i.e. let’s use the trick in Equation 2.
Mean
To compute the expectation, we write down all possible outcomes, weighted by their probabilities. The probability of flipping a heads in N=1 flips is p; the probability of flipping a heads in N=2 flips is qp; and so forth. This gives us
E[N]=p+qp2+q2p3+q3p4+…(6)
Now let’s apply the above trick, subtracting qE[N] from the series:
This is promising. We’ve greatly simplified Equation 4. Now let’s just apply our trick again:
E[N]qE[N]E[N](1−q)E[N]=1+q+q2+q3+q4+…=q+q2+q3+q4+q5+…⇓=1⇓=p1.(8)
And we’re done.
Variance
To compute the variance, V[N], we just need to compute the second moment E[N2] since
Since a2−b2=(a+b)(a−b), we can simplify the squared differences as just a+b since a−b=1 when a=b−1, as in Equation 10. So the last line of Equation 10 can be written as
Finally, we just plug this second moment into the equation for variance (Equation 9), and simplify:
V[N]=E[N2]−(E[N])2=p21+q−p21=p21−p.(14)
And we’re done.
Note that if you do remember Equation 3 but do not remember the mean or variance of the geometric distribution, you can use Equation 3 after one application of the trick for the mean (Equation 7) or after two applications of the trick for the variance (Equation 12). The mean calculation is straightforward. To compute the variance, you simply add 2/p to both sides of the equation to get a series of the form in Equation 1:
E[N2]−p1+p2=p2+p2q+p2q2+p2q3+…2/p2(15)
This can be easily solved to derive the last line of Equation 13.
Die rolling game
Let’s look at another example. Imagine that Alice and Bob play a simple dice game. They take turns rolling a fair die, with Alice going first. Whoever rolls a 6 first wins. What is the probability that Bob wins? We can express this probability as an infinite series, and use our trick to re-write it as a geometric series.
The probability that Bob wins on the first roll is the probability that Alice does not roll a 6, but then Bob does. The probability that Bob wins on the second roll is the probability that neither Alice nor Bob win on the first round, Alice does not roll a 6 on the second round, but then Bob does. And so forth. We can express this probability, call it p, as
p=(65)61+(65)361+(65)561+…(16)
This isn’t quite a geometric series, but notice what happens if we multiply p by 5/6:
(65)p=(65)261+(65)461+(65)661+…(17)
Now we have two infinite series, one with odd powers and one with even powers. We can add them together to get a geometric series:
This isn’t quite the form of Equation 1, but we can get it there easily by adding 1/6 to both sides. We could, if we’d like, “turn the crank” of this trick on more time, but I’ll spare the reader and just use Equation 2:
p+(65)p+61p=1−5/61/6⇓=115.(19)
This makes intuitive sense. The game is almost fair, but Alice has an advantage by going first.
Conclusion
This is a useful trick for quickly solving a geometric series if you do not remember the closed-form solution. The above derivations are a bit tedious, but they’re conceptually straightforward.
Acknowledgements
I thank Mattia Mariantoni for pointing out a typo near Equation 10.
Joshi, M. S., Denson, N., & Downes, A. (2013). Quant job interview questions and answers. Pilot Whale Press Parkville.