Consider the function
$$f(x,y)=\sqrt{x^2+y^2}.$$
If we introduce the variables
$$\begin{align} r&=x\cos\varphi-y\sin\varphi,\\ u&=y\cos\varphi+x\sin\varphi, \end{align}$$
we'll get that
$$f(x,y)=\sqrt{x^2+y^2}=\sqrt{u^2+r^2}.$$
If we now fix $x$ and use $y$ as a parameter and consider a parametric function $(u(x,y),f(x,y))$ and try to differentiate $f$ with respect to $u$, we'll get:
$$\frac{\mathrm{d}f}{\mathrm{d}u}=\frac{\mathrm{d}f}{\mathrm{d}y}\bigg/\frac{\mathrm{d}u}{\mathrm{d}y}=\frac{y}{\sqrt{x^2+y^2}}\bigg/\cos\varphi=\frac{y}{f(x,y)\cos\varphi}.$$
But if we directly express $f$ in terms of $u$ and differentiate the resulting expression, we'll instead get:
$$\frac{\mathrm{d}f}{\mathrm{d}u}=\frac{\mathrm{d}}{\mathrm{d}u}\sqrt{u^2+r^2}=\frac{u}{\sqrt{u^2+r^2}}=\frac {y\cos\varphi+x\sin\varphi}{f(x,y)}.$$
These two results don't match, but I can't seem to spot the mistake.
So what am I doing wrong here? Why don't the results match?
The mistake is in the second method, where you treat $r$ as constant whereas it still contains the parameter $y.$
You're supposed to differentiate the function $$\sqrt{x^2+\left(\frac{u-x\sin\phi}{\cos\phi}\right)^2}$$ instead.