It’s been at least 25 years since I have done any sort of math more complicated than simple derivatives, so I just don’t know how to even go about tackling this situation.

Let’s say that there is a game that allows you to earn coins at a certain rate, and the ability to spend coins to increase that rate. Is there an overall formula to suggest when reinvestment should take place and when it should cease?

Specifics;

1) You begin earning 1c(oin) per minute

2) You can reinvest to earn an additional 1c per minute.

Example-1; Assuming a single coin investment always earns you additional 1c/m

1) Without doing anything, you would earn 1,000c in 1,000 minutes.

2) A single investment at round 99 would;

..2a) Cost all your coins (from 99 to 0)

..2b) Make your per minute gain 100c (1+99)

..2c) Earn 1,000+ at round 109

For the above example, I show that a single investment at round 26 gets the player to over 1,000 the earliest at round 64.

EDIT: Invest at 26 is incorrect (see subsequent posts)

Q-1) Is there a single formula to find out;

How to most quickly reach a T(otal)

Given a certain C(oins per minute)

If I(nvesting) is (increase 1C for 1coin)?

Example-2; Assuming the same, but allowing investment whenever one wants.

1) Unsurprisingly, the best strategy is to reinvest each round and earn 1,000+ at round 11.

Example-3) Closer to how the game actually is.

Investing costs 2 more each time.

You start out earning 1c/m.

If you reinvest 1, you start earning 2c/m, but it will cost 3 coins to increase again.

If you then reinvest 3, you start earning 3c/m, but it will cost 5 coins to increase again.

Assuming my IF-THEN formulas are correct, the quickest way to reach 1,000 is reinvesting each round until round 40 to break 1,000 at round 86

Q-2) Is there a formula that can calculate the fastest way to reach T with I increasing by a particular R(ate)? I assume that it involves squares at some point (or factoring by R(ate). Might even use P=e^rt for all I know.

Thanks for any insight.

## Maximizing Targeted Return

**Moderators:** jestingrabbit, Moderators General, Prelates

### Maximizing Targeted Return

Last edited by MRR on Fri Dec 30, 2016 5:56 pm UTC, edited 1 time in total.

### Re: Maximizing Targeted Return

MRR wrote:It’s been at least 25 years since I have done any sort of math more complicated than simple derivatives, so I just don’t know how to even go about tackling this situation.

Let’s say that there is a game that allows you to earn coins at a certain rate, and the ability to spend coins to increase that rate. Is there an overall formula to suggest when reinvestment should take place and when it should cease?

Specifics;

1) You begin earning 1c(oin) per minute

2) You can reinvest to earn an additional 1c per minute.

Example-1; Assuming a single coin investment always earns you additional 1c/m

1) Without doing anything, you would earn 1,000c in 1,000 minutes.

2) A single investment at round 99 would;

..2a) Cost all your coins (from 99 to 0)

..2b) Make your per minute gain 100c (1+99)

..2c) Earn 1,000+ at round 109

For the above example, I show that a single investment at round 26 gets the player to over 1,000 the earliest at round 64.

Q-1) Is there a single formula to find out;

How to most quickly reach a T(otal)

Given a certain C(oins per minute)

If I(nvesting) is (increase 1C for 1coin)?

If you invest everything you have on round r, your money on round n > r will be M = (n-r)(r+1). We want M to equal some constant T. This will happen when T = (n-r)(r+1)

n(r + 1) - r^2 - r - T = 0

n = (r^2 + r + T)/(r + 1)

We now have a polynomial describing n in terms of r. If we find the inflection points (is that the right word? It's been a while since I did this) they are where waiting longer to invest switches from useful to harmful and vice versa. For example, setting T = 1000, we get approximatly r - 30.6 and r = -32.6. Since round are discreet, the closest sensible values would be (31, 63) and (30, 63). These are both smaller than your solution of (26, 64).

MRR wrote:Example-2; Assuming the same, but allowing investment whenever one wants.

1) Unsurprisingly, the best strategy is to reinvest each round and earn 1,000+ at round 11.

Example-3) Closer to how the game actually is.

Investing costs 2 more each time.

You start out earning 1c/m.

If you reinvest 1, you start earning 2c/m, but it will cost 3 coins to increase again.

If you then reinvest 3, you start earning 3c/m, but it will cost 5 coins to increase again.

Assuming my IF-THEN formulas are correct, the quickest way to reach 1,000 is reinvesting each round until round 40 to break 1,000 at round 86

Q-2) Is there a formula that can calculate the fastest way to reach T with I increasing by a particular R(ate)? I assume that it involves squares at some point (or factoring by R(ate). Might even use P=e^rt for all I know.

Thanks for any insight.

Using the same methodology as above, modified for the new rules:

Let i be the number of investments made

r = 2*i(i+1)/2 - i

r = i^2

I feel silly for not realizing that earlier.

T = (n-i^2)(i+1)

n(i+1) - i^3 - i^2 - T = 0

n = (i^3 + i^2 + 0*i + T)/(i+1)

n' = ((i+1)(3i^2 + 2i) - (i^3 + i^2 + T)(1)) / (i+1)^2

3i^3 + 5i^2 + 2i - i^3 - i^2 - T = 0

2i^3 + 4i^2 + 2i - T = 0

let T = 1000

i^3 + 2i^2 + i - 500 = 0

Eyeballing it, there should be a root near i = 8, and the other two are negative.

For i = 7, r = 49, n = 125 + 49 = 174

For i = 8, r = 64, n = 112 + 64 = 176

So the best strategy when only allowed a single investment should be to invest on round 49, if I haven't made any mistakes.

### Re: Maximizing Targeted Return

Tirear wrote:we get approximatly r - 30.6 and r = -32.6. Since round are discreet, the closest sensible values would be (31, 63) and (30, 63). These are both smaller than your solution of (26, 64).

You are absolutely correct. Not sure what I did incorrectly with my spreadsheet the other day, but I WAS altering things often and may have put something in an incorrect row.

EDIT: Actually, my spreadsheet says "Round 28"

Invest 27 coins at the end of round 27, earn 28 and the end of round 28 and 28 coins each round thereafter.

Tirear wrote:So the best strategy when only allowed a single investment should be to invest on round 49, if I haven't made any mistakes.

I have no reason to doubt you, but that wasn't quite the question.

The actual question was being able to invest at the end of each round, with the cost of investment going up by a certain amount (in this case, 2 coins each time).

### Re: Maximizing Targeted Return

MRR wrote:The actual question was being able to invest at the end of each round, with the cost of investment going up by a certain amount (in this case, 2 coins each time).

Yeah, I was avoiding that because applying my method to repeated investment results in compound interest on fractional investments, so the time required has no resemblance to reality. Still, if I ignore the round and just look at how many times I should invest, it should get close to the right number.

**Spoiler:**

So this suggests you should invest 20-23 times. A quick check shows that after investing 21 times you would generate 1012c in 46 rounds, which matches how long your answer said there was between stopping investment and reaching 1000.

EDIT: Actually, now that I look at it the pattern is really simple. 1st investment happens on round 1, then every two round you get enough to invest + 1c. The cost to invest rises faster than the spare change, so it never lets you reinvest after just 1 turn and you are always left with #investments - 1 c after investing. So to invest 21 times, the last investment would be on turn 41, leaving you with 20c. 45 turns later, your total would be 22*45 + 20 = 1010c, for a turn 86 finish.

EDIT2: Incorporating that into the formula:

**Spoiler:**

That narrows it down to 22 investments or maybe 21, instead of 4 possibilities (of course, you end up at over 1000 at turn 86 for as wide a range of values as the error bar was anyways). To invest 22 times, last investment occurs on turn 43. 43 turns later, you have 23*43 + 21 c = 1010c for a turn 86 finish, same as 21 investments.

- Soupspoon
- You have done something you shouldn't. Or are about to.
**Posts:**3719**Joined:**Thu Jan 28, 2016 7:00 pm UTC**Location:**53-1

### Re: Maximizing Targeted Return

This reminds me of something I saw when I was maybe 11 or 12 (from knowing where I saw it), a question brought back from some sort of Maths Olympiad, or so I gathered from the attached notes, and left lying around in a classroom from a prior lesson for another year's students (not given to us to do, just found during an idle moment, and I often had idle momnts).

The trouble being that while I understood the question and the principle in the attached clue at the time, I can't remember any of the details. But it was a similar (if inverted) situation with a pipeline whose pressure reduces by some non-linear formula, to which a couple of booster-pumps could be inserted at points that you had to define that would re-energise (double? something else?) the pressure at that point onwards. There were obviously optimal locations to put the pumps, and for some reason it was not both together at either end, one at each end or at ⅓rd and ⅔rds points, obvious solutions for some of the more obvious

But I theorise that the pressure-drop formula was based upon an inverted quadratic (too-early intervention being counter-productive as more 'leakage' was encouraged) and the pump boost was "mx-c"-ish (too-late intervention and the "-c" takes the curve negative).

Still, an interesting scenario, that I've (necessarily) loosely plagiarised on occasion, since.

The trouble being that while I understood the question and the principle in the attached clue at the time, I can't remember any of the details. But it was a similar (if inverted) situation with a pipeline whose pressure reduces by some non-linear formula, to which a couple of booster-pumps could be inserted at points that you had to define that would re-energise (double? something else?) the pressure at that point onwards. There were obviously optimal locations to put the pumps, and for some reason it was not both together at either end, one at each end or at ⅓rd and ⅔rds points, obvious solutions for some of the more obvious

^{1}setups.But I theorise that the pressure-drop formula was based upon an inverted quadratic (too-early intervention being counter-productive as more 'leakage' was encouraged) and the pump boost was "mx-c"-ish (too-late intervention and the "-c" takes the curve negative).

Still, an interesting scenario, that I've (necessarily) loosely plagiarised on occasion, since.

^{1}Both at the start would be best if the simple boost multiple was greater than the simple drop-off factor by distance, getting the benefit in first. Both at the end if the drop-off was steeper, just take what asymptotically gets there and boost, rather than lose more boost at the begining, without backup. Either end offers a compromise, and equidistant streteches between ends and pumps is a compromise that might work better in another scenario. And there's also the "it doesn't matter where they are" curve, for the simplest of setups...### Re: Maximizing Targeted Return

Tirear wrote:MRR wrote:Yeah, I was avoiding that because applying my method to repeated investment results in compound interest on fractional investments, so the time required has no resemblance to reality.

Yeah, that's why I never mentioned that as a final variable. Then you'd have to know how long rounds last and how long it takes to pause the rounds and do an investment.

Thanks for all the work on the math. I'll have to write it out on paper to try to understand it, but at least now I know a formula exists.

### Who is online

Users browsing this forum: No registered users and 9 guests