I feel like this is a very trivial question or just a blatant oversight on my part, but here it goes anyway.
Consider the function $f(x,y) = (x-y)^2$, where $x,y\in\mathbb{R}$.
Now, when I take the partial derivative of $f$ with respect to $x$ and then $y$, I get the following, $$\frac{\partial f}{\partial x} = 2(x-y)$$ $$\frac{\partial f}{\partial y} = 2(y-x)$$
My question is, if $(x-y)^2 = (y-x)^2$, after I differentiate both sides with respect to $x$ (or $y$), why won't I get the same answer? Essentially, it seems like if $f(x,y) = (x-y)^2$, then it is imprecise to say that $f(x,y) = (y-x)^2$.
As a side note, I was working with some potential functions using Green's kernels and I decided to get funny with how I took my gradients, and this question popped up.
Hint: $(g^2)'=2 g g'$ (you forgot $g'$).