- #1

martix

- 156

- 0

- TL;DR Summary
- How to inverse f(x) = (x*e^(x-1))^(x/(x+1))

Preface: I have not done serious math in years. Today I tried to do something fancy for a game mechanic I'm designing.

I've got an item with a variable power level. It uses

Something like f

That way it's still 1 at x=1. The low-end values look weird though. Like x=0 is not 0.

So I figure multiply both: f

f

But I am multiplying to very similar values, so a square root seemed in order: f

It's higher than the linear function below 1, but that's fine for now. Above 1, with the square root it's not quite exponential, but it's close enough and certainly above linear.

And normally that would have been the end of the story. But then I started tinkering with the function. At this point I'm just in it for the math and (re)learning things long forgotten.

Interesting things happen when you mess with the power. f

This makes it go above exponential growth for a while, and then dip below, depending on how close p is to 1.

The item has a max power level, it can't go to infinity. So I started thinking, can I somehow align this max level with the inflection point of f

I made a new function, to look at how and when this happens: f

An hour or two of struggle with WolframAlpha later, I arrive at the following function of power as a function of ammo:

But I don't know how to find the inverse. Or to be more explicit I want an f(y) = x function. I tried some algebra, but that got me nowhere. It seems to me the inverse function should exist, but I'm stumped at this point.

(Step-by-step in the spoiler below, should anyone feel the need to double-check my work. I plopped everything in an excel sheet to verify my results, so I'm reasonably certain it's correct, even if I don't know why. Explanations appreciated tho.)

1. We're looking for the minima of f

2. Our function has 2 variables x (ammo) and p (exponent). I mess around with both partial derivatives, looking for anything useful to fall out. Turns out ∂f

3. Substitute: f

I've got an item with a variable power level. It uses

*amount of ammo to produce***x***amount of kaboom. Initially it was linear, e.g. f***f(x)**_{L}(x) = x, but I didn't like the scaling. So I figure I'd make it scale exponentially.Something like f

_{e}(x) = e^{x-1}.That way it's still 1 at x=1. The low-end values look weird though. Like x=0 is not 0.

So I figure multiply both: f

_{L}*f_{e}f

_{2}is now 0 at x=0 and 1 at x=1But I am multiplying to very similar values, so a square root seemed in order: f

_{2}= √f_{L}*f_{e}It's higher than the linear function below 1, but that's fine for now. Above 1, with the square root it's not quite exponential, but it's close enough and certainly above linear.

And normally that would have been the end of the story. But then I started tinkering with the function. At this point I'm just in it for the math and (re)learning things long forgotten.

Interesting things happen when you mess with the power. f

_{2}= (f_{L}*f_{e})^{p}, p>0.5This makes it go above exponential growth for a while, and then dip below, depending on how close p is to 1.

The item has a max power level, it can't go to infinity. So I started thinking, can I somehow align this max level with the inflection point of f

_{2}?I made a new function, to look at how and when this happens: f

_{ratio}= f_{2}/f_{e}, which has a very interesting shape and properties. More specifically, it's global minimum is the point where f_{2}goes from above exponential, to below. Which immediately got me thinking calculus and derivatives.An hour or two of struggle with WolframAlpha later, I arrive at the following function of power as a function of ammo:

**f(x) = (x*e**^{x-1})^{x/(x+1)}But I don't know how to find the inverse. Or to be more explicit I want an f(y) = x function. I tried some algebra, but that got me nowhere. It seems to me the inverse function should exist, but I'm stumped at this point.

(Step-by-step in the spoiler below, should anyone feel the need to double-check my work. I plopped everything in an excel sheet to verify my results, so I'm reasonably certain it's correct, even if I don't know why. Explanations appreciated tho.)

1. We're looking for the minima of f

_{ratio}, so derivatives ahoy! With WolframAlpha as a substitute for my non-existent calculus skills.2. Our function has 2 variables x (ammo) and p (exponent). I mess around with both partial derivatives, looking for anything useful to fall out. Turns out ∂f

_{r}/∂x = e^(p (-x) + p + x - 1) x^(-p - 1) (x - p (x + 1)) is the one I need (I have no idea why); We have 3 multiplicands here, so for the derivative to be 0, either one should be 0. Not the e^ part and x^ is only 0 when x=0, which is not what we're looking for. So the only working part left is*(x - p (x + 1)) = 0*which gives us a relation between x and p: p = x / (x+1)3. Substitute: f

_{2}= (f_{L}*f_{e})^{p}=> f_{2}= (x*e^{x-1})^{x/(x+1)}