It takes a function g, and returns the values of it's arguments (theta and psi) that minimize the function g.