Fermat's theorem (stationary points)