Finding the inverse of a rational function