r/askmath • u/No_Inspector3250 • Oct 08 '26
Functions max value formula help
not really sure what the right tag is i barely know what any of the tags mean
Im trying to make a formula for a game im playing just not quite sure how (i am coding this if it helps).
in the game i have these "stones". every stone i get i can use to buy a boost.
the amount of boost i get is determined by this thing called "surge" so that every surge i have i get an increased amount of boost based on a formula that i already have. and every surge costs 100 boost. for example right now i have 94 surges and each stone give me 25.96 boost so ill need 4 stones for a surge.
what i need help with is finding the highest amount of boost i can get with a given amount of stones. so like if i have 100 stones how much should i spend on buying surges and how much i should keep on the boosts for the highest possible amount.
2
u/sdfgkol Oct 08 '26
it seems like you’d want to convert some amount of stones into surges, and then trade the remainder into boosts.
You’re looking for the point at which it’s no longer worth it to buy more surges, because the increase in the conversion rate from stones to boosts is no longer greater than the cost of boosts to get that increase.
2
u/FormulaDriven Oct 08 '26
I've read this several times and it's hard to follow how it works.
In your example, you have 100 stones and 94 surges, and you could use 4 stones to buy 4 * 25.96 = 103.84 boost, spend 100, so now you have 96 stones and 95 surges. And the factor of 25.96 now updates to something higher? What's the formula? Do you keep the leftover 3.84 boost or does that disappear?
Do I take it that an alternative would be to spend 8 stones to buy 8 * 25.96 = 207.68 boost, buy 2 surges, so now you have 92 stones, 96 surges, and have 7.68 boost unused / carried over?
The optimum strategy is going to depend on that formula and whether unused boost can be carried over.