# Find parameters of short geometric series

I occasionally host D&D~ish game and having a way to do this will definitely improve my ability to serve better games, so when they want to upgrade their fireball 5 times, I can do it without the game getting out of hand :)

There are four related numbers: Base $B = 100$, Start $S = 0.4$, Count $C = 4$, and Multiplier $M = 0.64448$, for example. I need to be able to find $M$ by having $B$, $S$ and $C$. Also I need to find $S$ by having $B$, $C$ and $M$.

The way these four numbers are related is through a geometric series. Let $r_0 = B\times S$, and let $r_{i+1} = M\times r_i$ for $0 \le i \lt C$ define $r_1,\ldots,r_C$. It is desired that $B \approx r_0 + r_1 + \ldots + r_C$, where an error in approximation less than one is tolerable.

In the sample figures shown above:

(B) 100 × (S) 0.4 = 40 (r0)
(r0) 40 × (M) 0.64448 = 25.7788368 (r1) .... (counting 1)
(r1) 25.7788368 × (M) 0.64448 = 16.61371067 (r2) .... (counting 2)
(r2) 16.61371067 × (M) 0.64448 = 10.7070534 (r3) .... (counting 3)
(r3) 10.7070534 × (M) 0.64448 = 6.900384555 (r4) .... (counting 4)


Adding $r_0 + r_1 + r_2 + r_3 + r_4$ should give $B$ or close to it (with the above numbers the sum is about $100.001$).

Keep in mind $B$, $S$ and $C$ aren't always the same. Last time I needed it, $B = 1319143$, $S = 0.156048362$ , $M=0.85$, $C=19$ and the sum of $r_0 + r_1 + \ldots + r_{19}$ was about $1319142.86296796$ (within our margin of $\pm 1$).

Please use algebra, since my math knowledge if quite limited.

• While it might be helpful to explain why something is needed, the biggest obstacle here is the obscurity of what is being asked. Generalizing from a single example is tricky. – hardmath Jul 30 '14 at 23:20
• I hope the extra info helps. – helena4 Jul 31 '14 at 8:30
• If you know B and S, then it is a Geometric Progression with first term (a)=B*S, n=5, common ration(r)=M(0.64448) and the formula for the sum of GP is Sum=a(1-r^n)/(1-r) – Vikram Jul 31 '14 at 9:12
• @helena4: Yes, it makes your Question much clearer, thanks. – hardmath Jul 31 '14 at 12:38
• @hardmath So does the clarified question warrant being UNHOLD (: ? – helena4 Aug 2 '14 at 12:04

Algebra can help us see the real problem to be solved.

When we have a sequence of values to sum, there is a special symbol for it, the Greek letter Sigma (uppercase):

$$\sum_{i=0}^C r_i = r_0 + r_1 + \ldots + r_C$$

In the special case described here we have terms in geometric progression. That is, term $r_i$ is multiplier $M$ times the previous term $r_{i-1}$.

Using this notation the problem can be restated as: Given $B,S,C$ find $M \gt 0$ such that

$$B = B\cdot S + B\cdot S\cdot M + \ldots + B\cdot S\cdot M^C = \sum_{i=0}^C B\cdot S\cdot M^i = B\cdot S\cdot \sum_{i=0}^C M^i$$

We now see that the "base" parameter $B$ doesn't really interact with the other parameters. We can divide both sides of the equation by $B$ and it disappears from the problem:

$$1 = S\cdot \sum_{i=0}^C M^i$$

If $C$ and $M$ are given, it's a simple matter to compute $S = (\sum_{i=0}^C M^i)^{-1}$. If $M=1$, then $S = 1/C$. Otherwise the formula for a finite geometric series gives:

$$S = \frac{M-1}{M^{C+1}-1}$$

This could be evaluated with a few calculator keypresses.

The problem of finding $M$ given $S$ and $C$ is more difficult, because it requires finding the root $M$ of a polynomial of degree $C$:

$$M^C + \ldots + M + 1 = S^{-1}$$

As a function of $M \gt 0$, the left-hand side of this polynomial equation is strictly increasing. Therefore when $S^{-1} \gt 1$, we will have exactly one positive real root for $M$. There is no simple solution "with a few calculator keypresses" but finding a numerical value (approximation) for $M$ is not difficult.

Knowing that $M=0$ is too small, we can easily find a value that is too large. For example clearly $M=S^{-1}$ is too large. The simplest root finding procedure is bisection: take an interval that brackets the unique positive root (upper bound and lower bound), and chop it in half. Evaluate the polynomial above at the midpoint of that interval, and we find out whether the midpoint value is too small or too large. We continue using the upper half or lower half of the previous interval accordingly.

There are numerical methods for solving this problem, but if calculus level math is not your strength, then this (systematic) "trial and error" approach is a pretty good approach.

With a bit of effort (and maybe help from one of your D&D'ish colleagues), an Excel spreadsheet or equivalent can be created to automate the trial-and-error.

• Thats good enough. You guys have been a great help. I just assumed the solution would be easy because I couldn't come up withe a clear and straightforward question for it. Your suggestion is basically how I'm doing it now(: I'm adjusting M manually until the numbers fit (: Down the line I'll probably get some sort of function to do it for me. Does asking questions in here after accepting an answer still notify people? – helena4 Aug 4 '14 at 13:18
• @helena4: Notification is separate from accepting answers. If you have another Question, you can post a new one. – hardmath Aug 4 '14 at 13:35
• hey, wanna check the next one in the series ;) ? You did blaze through this one after all. math.stackexchange.com/questions/1352665 – helena4 Jul 9 '15 at 12:09

let $b$ and $s$ denote the base and start variable you mention, and let $n$ be the count, and let $m$ be the multiplier.

If I understant correctly, you then commit $n$ steps to get $n$ results:

$$r_1 = b\cdot s \cdot m\\ r_2 = r_1\cdot m\\ r_3 = r_2\cdot m\\ r_4 = r_3\cdot m$$

Then you sum the results to get $100$.

Now, from my equations, it is simple to see that $r_2=b\cdot s \cdot m^2$, $r_3=b\cdot s \cdot m^3$ and $r_4=b\cdot s \cdot m^4$, so $$r_1+r_2+r_3+r_4 = b\cdot c\cdot (m + m^2 + m^3 + m^4),$$

and you want to solve the equation $r_1+r_2+r_3+r_4 = 100$ for $m$, so you are solving $$m+m^2+m^3+m^4 = \frac{100}{bc}.$$

In general, a polynomial equation of order $>2$ is hard to solve. In this case, the power sum $m+m^2+m^3+m^4$ can be simplified by using the fact that $$x+x^2+x^3+\dots + x^n = \frac{x(x^n-1)}{x-1}$$ holds for any integer $n$. This means that the equation you need to solve is $$\frac{m(m^4-1)}{m-1} = \frac{100}{bc}$$

Either way, the equation is solvable analytically for up to $4$ steps, but is (to my knowledge) not solvable analytically, but can easily be solved using numeric means.

On the other hand, you can very simply extract $s$ (the start) from this equation, as $$r_1+r_2+r_3+r_4 = 100$$ reduces to $$s\cdot b(m+m^2+m^3+m^4) = 100,$$

so $$s = \frac{100}{b(m+m^2+m^3+m^4)}$$

• The equation $m+m^2+m^3+m^4=100/(bc)$ is solvable by radicals because it has degree $<5$. There are explicit methods on Wikipedia here. – blue Jul 30 '14 at 21:19
• Note that this approach generalizes to more than 4 multiplications. In that case the numerical approach is really the only way. WolframAlpha is a very convenient tool for such things. – Semiclassical Jul 30 '14 at 21:29
• Allright @5xum I had google refresh some of my knowledge to understand so far. The last step i need "translated" - what is BC ? B+C? B×C? – helena4 Jul 31 '14 at 8:50
• @helena4 The "times" operator is optional, "plus" is not. This means that "$a\cdot b$" can be written as $ab$, but $a+b$ cannot. – 5xum Jul 31 '14 at 8:55
• Now that helena4 has clarified the Question, there are a few changes that could be made to your Answer. $B$ factors out from both sides, so it can be eliminated. – hardmath Jul 31 '14 at 20:21