I know this isn't technically plugin development, though I came across this problem while developing a plugin and has been bugging me for a while now. How could you non-programatically resolve the common ratio of a geometric series when provided the sum, initial and number in sequence? Relevant equation: S=a((1-r^n)/(1-r)) S: Sum of series a: Initial value r: Common ratio n: Number in sequence to count up to In this case, we need to resolve the equation for "r".

S, a and n. I am aware this could be worked out programmatically, though I would really like to know if there is anything out there to resolve the common ratio in one short but sweet equation.

That is what I have been attempting, and what I'm asking for in this thread. Apologies if my original post was hard to deconstruct. I would appreciate if you or anyone else could help try to work that out for me.

I think he's trying to find what "r" would equal to, so you are solving for "r" and in order to do that it needs to equal to "s" @novucs Don't we need to know what these variables are storing what values so we know what's what?

No, all I need is the equation above to be written to solve "r" instead of "S". It's an algebra question.

You wrote the equation incorrectly. You wrote Code (Text): s=a*((1/r^n)/(1/r)) for r when it should be Code (Text): s=a*((1-r^n)/(1-r)) for r When you try and put the correct equation in, it times out and says you need pro, which I don't have

From what I'm seeing, there is no possible way to solve the equation for just r. You can get r^n and r on one side of the equation, but since those are two different things, you can't factor out the r and they are left separate. The smallest you can simplify it is: -ar^n + sr = -a + s

The fact that you have the r as a divisor and dividend and both of them contain two terms (1 and negative r) on the right side of the equation is the issue.

Thanks! I've managed to take it a little further than yours and I think I might have solved it if I'm not missing anything. Workings: Code (Text): s = a((1-r^n)/(1-r)) s/a = (1-r^n)/(1-r) (s-sr)/a = 1 - r^n s-sr = a - ar^n s + ar^n = a + sr ar^n = a + sr - s r^n = (a + sr -s)/a n * log(r) = log((a + sr - s) / a) log(r) = log((a + sr - s) / a) / n r = 10^(log((a + sr - s) / a) / n) Edit: Oh I'm dumb, I still have "r" on the other side...

how did you even get this? There's no way you get -a on the right side. @novucs don't you happen to have the series instead of the sum? That would probably help a lot.

Initially I required it for a closed source level-up plugin I created for a client. The idea was that it costs a % more each time to level up, so my system allowed you to set the level up % cost and the initial price. After creating this, the client told me they wanted a total cost for all levels so I thought it'd be easier to calculate the increment ratio and use that in the config. It turns out that task was not exactly simple with normal maths, so I quickly whipped up a script to calculate the increment ratio. Now that issue is past, I cannot stop thinking about a mathematical way around this. So I created this thread more for my curiosity than anything and hoped someone else could find an equation that'll calculate the increment ratio.