determine the extrema of a function on a closed interval