How to check whether given number lies in the solution of a function?

24 Views Asked by At

Suppose I have a function f(x,y) and I have a number g. I want to check whether g lies in the range of the function and if yes for what x and y. If no, I want the closest number to g that the function can generate along with the respective x and y values. How to do this without trial and error?