$ f(x,y) = 2 ln(xy)-xy $
am trying to work out the gradient vector
so when I take partial derivatives with respect to x and y
$ \frac{2}{xy} - y $ , $ \frac{2}{xy}-x$
$ f(x,y) = 2 ln(xy)-xy $
am trying to work out the gradient vector
so when I take partial derivatives with respect to x and y
$ \frac{2}{xy} - y $ , $ \frac{2}{xy}-x$
Your answers are slightly incorrect: $$\frac{\partial f}{\partial x}=\frac2x-y\\\frac{\partial f}{\partial y}=\frac2y-x$$ because $$\frac{d}{dx}(\ln(kx))=\frac{d}{d(kx)}(\ln(kx))\cdot\frac{d}{dx}(kx)=\frac1{kx}\cdot k=\frac1x$$ An alternative way to show this is as follows: $$\frac{d}{dx}(\ln(kx))=\frac{d}{dx}[\ln(x)+\ln(k)]=\frac{d}{dx}[\ln x]+\frac{d}{dx}[\ln k]=\frac1x+0=\frac1x$$
So in your problem, you treat the $y$ as a constant in the first computation, and $x$ as a constant in the second computation.