Geometric Summation and Roblox
03 October 2022

Intro

The formula for the summation of a geometric progression is one of my favourite bits of maths (that I can still remember). It would not be if it was not for a lecturer who faced is as slightly annoyed student in the class I was in responded in such a nice way. This student, with some frustration, said to the lecture we can't keep remembering all these equations. We had all done used the formula years before but for some they had not stuck in their heads as well as it should.

The lecturer, unperturbed, just quietly said no one is expecting you to sit and memorised them. He said you can usually look them but really the simpler ones you should be able to derive. He then proceed to derive the formula for the summation of a geometric progression.

It usually takes me a little while to remember how to derive it these days. I probably only do it once every 5 years of so, but since that day it has been one of my favourite derivations. So lets take a look at it.

The derivation

We want to work the the summation of \(n\) terms of geometric progression. Starting with

\[ S_n = a + ar^1 + ar^2 ... ar^{n-1} + ar^n \]

Multiply by sides by \(r\) to give us

\[ rS_n = ar^1+ ar^2 ... ar^{n-1} + ar^n + ar^{n+1} \]

The next step is too work out what \(S_n - rS_n\) is

\[ S_n - rS_n = a +ar^{n+1} \]

It helps if you do this on paper and with \(S_n\) on one line and \(rS_n\) on the other. Make the columns line up on the powers of \(r\) then hopefully make this above step quite clear. If not play with it some more, or brush up on the taking one equation away from another equation skills.

Now lets factor out the \(r\) on the left hand side and the \(a\) on the right hand side.

\[(1-r)S_n = a(1-r^{n+1})\]

and divide by \((1-r)\) to give us the summation formula

\[S_n = \frac{a(1-r^{n+1})}{(1-r)}\]

Obviously this assumes \(r != 1\) if \(r=1\) then \(r^n\) is one. so the summation becomes \(S_n=na\)

Usually at school geometric summations often begin with n being infinite and \(|r| < 1\). In this case \(r^{n+1}\) goes to zero leaving us with

\[ S_\infty = \frac{a}{(1-r)}\]

And to Roblox.

One of my children likes to make Button Simulator Games in Roblox. It is fairly niche and really take the ideas of RPG grind back to it's very raw elements. The cost of things often goes up as a geometric series.

The question arose where he wanted to know how many items a player could buy if the price increases after each purchase following a geometric progression.

\(S_n\) is the total money the player has than we want to know what value of \(n\), the number of items they can buy. He had found an solution online but didn't quite understand it at the time. The game configures \(a\) and \(r\) so the only unknown is \(n\).

Lets start with

\[S_n = \frac{a(1-r^{n+1})}{(1-r)}\]

Rearranging

\[S_n (1-r) = a - ar^{n+1} \]

and then \[\frac{S_n(1-r) - a}{a} = r^{n+1}\]

To recap the only unknown is n. So we now need to take the \(log\) of both sides.

\[log(\frac{S_n(1-r) - a}{a}) = (n+1)log(r) \]

A final bit of rearranging and we get

\[ n = \frac{log(\frac{S_n(1-r) - a}{a}) }{log(r)} - 1 \]

\(n\) is the number of items that can be purchased. Well you will want to take the floor of the value (round down to nearest integer) to get the number. The total cost can be calculated with the summation formula above and you are good to go.

In the UK students would normally hit this in their 16-18 year old education in maths, probably the early part of that age range. Or at least have developed the skills to understand it. Assuming they elect to take Maths during those years.

While Roblox games can often be fairly simple that is certainly not always the case. The demographic of the creators is young but that is not to say what they are creating is simple or relying on simplistic maths. I don't currently feel this group of game developers gets enough credit for what they do.