As has already been mentioned, not all functions are invertible. In some cases imposing additional constraints helps: think about the inverse of sin(x)
.
Once you are sure your function has a unique inverse, solve the equation f(x) = y
. The solution gives you the inverse, y(x)
.
In python, look for nonlinear solvers from scipy.optimize
.