Maximum and minimum values of a function