Finding Local Maxima and Minima by Differentiation