Rebirths math problem

Why are you guys making it this complicated, just use a exponential scale. Any equation of the form y=n^x will work fine, where n is the steepness of the function and x would be the amount of rebirths which you can track by your own means. Using a for loop for any sort of math that isn’t integration(but even integration in most cases) is a massive sign you’re doing something terribly wrong.

he wants the total price of multiple iterations of buying a rebirth not just the price of a specific rebirth

Yes, exactly, I want to be able to calculate the next price and add it to the current one.

Then just integrate whatever formula (exponential formula in this case) for calculating the price and do the exact same thing.

My question is what is the formula?

This is exactly what arithmetic series sums do as I have said above. To get the price of x amount of rebirths it would be s(currentRebirths + x) - s(currentRebirths) where s is the sum function. Refer to my post above for code.

I edited post above, but here it is again:

scale = 10000
final_cost = 0.5*scale * HowManyRebirths * (HowManyRebirths + 2*RebirthsIHave - 1)

Wow, thank you! This is what I was looking for! I printed it and it printed out the exact number I wanted.

1 Like

that will give you your first rebirth free
just so you know

1 Like

Yea, I’ll try to find something for this by myself. Thanks for this notice!

check my first response, it is a very similar formula but it shifts everything 1 spot so starting at 0, it is 10k

local e = 10 -- steepness of the scale

function expoScale(x)
  return e^x
end

function expoScaleInt(x)
  return (e^(x+1)-1)/(e-1)
end

is what you want

But I don’t understand it, could you repost it more clearly now?

Yours work perfectly but doesn’t include how many rebirths you have rn.

expoScale gives you a curve exponentially increasing by e, expoScaleInt is the analytic form for the series sum of that function.

It is just variables, put your variable for current rebirths in for cR and how many they buy for nR

1 Like

The fundamental theorem of calculus says you can just subtract whatever the sum of a series from the sum of a series to get the sum over an interval, thus

expoScaleInt(goalRebirths) - expoScaleInt(currentRebirths)

is what you would want to do.

What is the 2cR? its erroring me this

its just 2*cR, sorry for the confusion. formatting removes * and such

When RebirthsIHave=0 and HowManyRebirths=1 then the price is 0. If that’s not what you want, then you’ll need to shift things so that costs something else (probably 10000).

The fn that Pharyx_Styx posted is pretty much identical to the one I ended up with. Just change the -1 at the end of the fn to +1 and it will shift everything up by 10k.

I was trying to replicate what you did whereas he was showing the right way to do it :smiley:
Should mark his first post as solution. He was on to the answer right from the start.

2 Likes