# Inverse of this function with two powers

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.

• I wouldn't expect this function to have an inverse that can be expressed with elementary functions. This is just a hunch, though. – 5xum Jul 15 at 7:00
• I think when $0<c<1$, the function does not have a unique inverse function, because it's not monotonous. – Matti P. Jul 15 at 7:04
• desmos.com/calculator/cnhvp4u9jh – Matti P. Jul 15 at 7:05
• There is no closed-form expression, as the equation can be put in the form of a polynomial for rational $c$. – Yves Daoust Jul 15 at 7:12
• This function looks fairly empirical. What's the rationale ? – Yves Daoust Jul 15 at 7:15

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.