How do I invert this exponential function?

In summary: Calculus is a very powerful tool, but it doesn't always provide a simple answer. Inverse functions are a bit more complicated than that.The function f(x) = (x*ex-1)x/(x+1) is not an inverse function. It's a function that maps from ammo to kaboom, but it doesn't provide an inverse. What you are looking for is an f(y) = x function. This can be found by taking the derivative of f(x) with respect to y.
  • #1
martix
160
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 x amount of ammo to produce f(x) amount of kaboom. Initially it was linear, e.g. fL(x) = x, but I didn't like the scaling. So I figure I'd make it scale exponentially.
Something like fe(x) = ex-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: fL*fe
f2 is now 0 at x=0 and 1 at x=1
But I am multiplying to very similar values, so a square root seemed in order: f2 = √fL*fe
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. f2 = (fL*fe)p, p>0.5
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 f2?

I made a new function, to look at how and when this happens: fratio = f2/fe, which has a very interesting shape and properties. More specifically, it's global minimum is the point where f2 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*ex-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 fratio, 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 ∂fr/∂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: f2 = (fL*fe)p => f2 = (x*ex-1)x/(x+1)
 
Physics news on Phys.org
  • #2
martix said:
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 x amount of ammo to produce f(x) amount of kaboom. Initially it was linear, e.g. fL(x) = x, but I didn't like the scaling. So I figure I'd make it scale exponentially.
Something like fe(x) = ex-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: fL*fe
f2 is now 0 at x=0 and 1 at x=1
But I am multiplying to very similar values, so a square root seemed in order: f2 = √fL*fe
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. f2 = (fL*fe)p, p>0.5
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 f2?

I made a new function, to look at how and when this happens: fratio = f2/fe, which has a very interesting shape and properties. More specifically, it's global minimum is the point where f2 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*ex-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 fratio, 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 ∂fr/∂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: f2 = (fL*fe)p => f2 = (x*ex-1)x/(x+1)
There is no "closed form" for the inverse function. With the exponent involved, I'm not certain, but you may be able to find a solution using the Lambert W-function.

-Dan
 
  • #3
So that's what that W I've been seeing pop up in W|A results means. Not that I can do much with it.
I reached y=x+ln(x) and that's it. (In other words this operation from the OP: fL*fe) Seems that's the unsolvable part. Doesn't get any simpler than that and the root is apparently x = e(-W(1)). And I can totally find the wiki page but I'd need a course in calc and complex analysis before I can do anything with it.
 

Similar threads

Replies
3
Views
916
Replies
12
Views
912
Replies
5
Views
1K
  • Precalculus Mathematics Homework Help
Replies
12
Views
917
  • Calculus
Replies
25
Views
850
Replies
5
Views
947
Replies
2
Views
661
  • Calculus
Replies
4
Views
817
  • Calculus
Replies
2
Views
1K
Replies
4
Views
1K
Back
Top