Differentiation is not the whole story for this problem, though – there is a critical point at which the function is not differentiable.
A quick sketch of the curve should show that for and for and has a nondifferentiable critical point at Therefore a better solution is to rewrite the function as follows:
You can then use differentiation on the open intervals and separately to find the other critical point(s).