finding stationary points using differentiation