Inverse of this function with two powers

72 Views Asked by At

I'm trying to find the inverse of the function: $$y=\frac{x^f + 1 - (1-x)^\frac{1}{f}}{2}$$ where $f=10c^3+1$ and $x,y$ and $z$ lie in the interval $[0,1]$

I'm using this for mapping of MIDI note velocities and need to be able to convert back to the original value - but my math is failing me.

The function is basically a curved line from (0,0) -> (1,1) where c controls how much it bends away from the straight line.

See here for background

See here for Desmos Calculator showing how the curve behaves.


Sorry for incorrect previous posting, pretty sure the function is now correct.


Someone asked about the rationale... to be honest I can't remember where I got this function. It's been in my software for 10+ years and works well but now I need the inverse.


Note: this function looks symmetrical about the line $y=1-x$ for the specified x range... but it's definitely not.

1

There are 1 best solutions below

2
On BEST ANSWER

You are not going to find a simple expression which, when given a value $y=g(x)$, produces $x$ precisely.

That said, it seems that your function $g(x)$ is fairly smooth and well-behaved.

Accordingly, you should be able to solve $g(x)=y$ quite easily by Newton's method. (It is easy enough to differentiate).

If you think that this will be too slow in practice, you can calculate solutions in advance for the 100 values $y=0.00, 0.01,… 1.00$ and make a table of the corresponding $x$ values in your program. You can then look up those values when you need them, or interpolate between them, or even use the looked-up value as a starting point and do one step of Newton's method to refine the result. You do not, after all, need your result accurate to ten decimal places.

My guess, however, is that given what you have said about your function and its intended use, starting with an estimate $x=y$ and doing a fixed number (say, 6) of "Newton steps" from there will give you all the accuracy you could reasonably need.