Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate inverse of a function--Library [closed]

Tags:

python

c

math

Is there any library available to have inverse of a function? To be more specific, given a function y=f(x) and domain, is there any library which can output x=f(y)? Sadly I cannot use matlab/mathematics in my application, looking for C/Python library..

like image 451
username_4567 Avatar asked Mar 04 '13 11:03

username_4567


2 Answers

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.

like image 144
ev-br Avatar answered Nov 09 '22 10:11

ev-br


I am a bit late, but for future readers of the post, I just published a python package that does this precisely. https://pypi.python.org/pypi/pynverse There is a detailed description of how to use it and how it does it in the description!

like image 28
alvarosg Avatar answered Nov 09 '22 10:11

alvarosg