I need to find the maximum and the minimum of $$f(x,y)=x^2-y-2\sqrt{x^2+y^2}$$ on $G$: $x^2+y^2=1$. My problem lies in the order in which i perform differentiation and imposing constraint:
Differentiation + constraint: $$\frac{\partial f}{\partial x}=2x-\frac{2x}{\sqrt{x^2+y^2}}\rightarrow \frac{\partial f}{\partial x}_G=2x-2x=0.$$
Constraint + differentiation:
$$f(x,y)_G=x^2-y-2\rightarrow\frac{\partial f}{\partial x}_G=2x.$$
Can anyone please explain to me why is that and which is the correct path to follow?