Here we have a function made from the product of two functions, so we canuse the product differenciation rule.
y=uv => dy/dx=udv/dx + vdu/dx
Therefore dy/dy=(x-2)^2 + 2(x-2)(x+1)
Stationary points occur when the gradient is zero, we solve for (x-2)^2 + 2(x-2)(x+1)=0 which gives (0,4), (2,0)
Solving for nature of stationary point we find the second derivative d^2y/dx^2=6x-6
When x=0 we get a maximum, when x=2 we get a minimum point.