How to find inverse of a function