Can you always treat variables as constants in partial derivatives/integrals? Ok so imagine you are given an expression: $xy : x=y$, & you need to take the partial derivative w.r.t. $x$ but you don't simplify (i.e. substitute x=y) --> $d/dx(xy)=y$.
Now you've gotten a different answer than you would have gotten had you simplified/substituted. But in math you should only be able to get 1 correct answer regardless of simplification. So why does standard partial derivative procedure in this trivial example yield 2 seemingly 'correct' answers?
P.S. Ditto question for partial integrals & cases where $x=y + \epsilon: \epsilon\approx 0$.
 A: The partial derivative with respect to $x$ of $f(x,y) = xy$ is defined to be the result you get by holding $y$ constant and differentiating with respect to $x$:
$$\frac{\partial}{\partial x}f(x,y) = \frac{\partial}{\partial x}(xy) = y.$$  If you are looking for the total rate of change of $f(x,y) = xy$ with respect to $x$, with the additional information that $y = x$, then you are really looking for the total derivative, and will need to use the chain rule:
$$\frac{d}{dx}f(x,y) = \frac{d}{dx}(xy) = y + x\frac{dy}{dx} = y + x = x + x = 2x,$$ or alternatively by substituting $y = x$ in the expression, you have $$\frac{d}{dx}f(x,x) = \frac{d}{dx}x^2 = 2x.$$  It all depends on whether you are in fact looking for the partial derivative or the total derivative.
A: Consider $f:\mathbb{R}^2\to\mathbb{R}$ with $f(x,y)=xy$. Also consider the function $g:\mathbb{R}\to\mathbb{R}^2$ with $g(x)=(x,x)$. You can then define the composition $h=f\circ g:\mathbb{R}\to\mathbb{R}$
$$
h(x)=f(g(x))=f(x,x)=x^2
$$
While understandable, it is confusing to write $\frac{d}{dx}f(x,x)$. What you actually have is the composition of two functions.
The derivative of the function $h$ is $h'(x)=2x$.
On the other hand, the partial derivative with respect to $x$ for $f$ is
$$
\frac{\partial}{\partial x}f(x,y)=y.
$$
