Paradoxical result from the chain rule I noticed a very simple problem, yet paradoxical when I was solving a different problem. It would be great if you help me understand which of the following lines lead to the paradoxical result and why it is wrong.
Assume the equation: 
$$X=f(X,Y)=5X+Y$$
obviously we can write:
$$ dX=5dX+dY \rightarrow  \frac{dX}{dY}=-1/4 $$
$$  \frac{\partial f}{\partial Y}=1$$
now if I differentiate $f(x,y)$, I would get:
$$ df=\frac{\partial f }{\partial X}dX+\frac{\partial f }{\partial Y}dY$$
Since $X=f(X,Y)$, replace $f$ with $X$ from above:
$$ dX=\frac{\partial X }{\partial X}dX+\frac{\partial X }{\partial Y}dY$$
$$ dX=dX+\frac{\partial X }{\partial Y}dY$$
$$ \frac{\partial X }{\partial Y}dY=0$$
$$ \frac{\partial X }{\partial Y}=0 \rightarrow \frac{\partial f }{\partial Y}=0 $$
Thanks in advance
UPDATE:
As people mentioned here the problem is that $X$ and $Y$ are not independent variables but still it's not clear to me as it is the whole point of the chain rule. For example let's consider the following case in which the variables are also dependent on each other:
$$f(s)=4s^{2}+5s$$ 
$$df=8sds +5ds$$
now define $u=2s$ and $v=5s$, so $du=2ds$ and $dv=5ds$
$$ f(u,v)=u^{2}+v$$
of course $u$ and $v$ are not independent but writing the following yields the correct result:
$$ df=\frac{\partial f }{\partial u}du+\frac{\partial f }{\partial u}dv$$
$$ df=2udu+dv$$
substituting $u,v ,du$ and $dv$ from above:
$$df=4s*2ds+5ds=8sds+5ds$$
Here $u$ and $v$ are not independent just like $X$ and $Y$ in the earlier example but why $df=\frac{\partial f }{\partial u}du+\frac{\partial f }{\partial u}dv$ leads to the correct result as opposed to $ df=\frac{\partial f }{\partial X}dX+\frac{\partial f }{\partial Y}dY$?
 A: First, note that you have failed to define the function $f$. Your equation only specifies what the value of $f(a,b)$ should be in the special case where $b = -4 a$.
I assume that you mean $f$ to be the function defined by the formula $f(a,b) = 5a + b$.

The problem here is notation. Expressions such as $\frac{\partial f}{\partial Y}$ do not have a reasonable, literal interpretation; instead they are shorthand for something more complex or awkward to write.
This means that the notation is very fragile in the face of creative calculations.
The biggest warning sign here is that $X$ and $Y$ are not independent variables. This means the intended interpretation of $\frac{\partial (5X + Y)}{\partial Y}$ depends on the specific choice of formula by which we've written in the numerator.
So, despite the fact $X$ and $5X + Y$ are equal, you should not expect any sort of relationship between $\frac{\partial (5X + Y)}{\partial Y}$ and $\frac{\partial X}{\partial Y}$.

I prefer to work with differentials exclusively, whenever possible. Differentials say what they mean and are well-behaved algebraically; it is rare to run into the same sorts of problems that you see when using the usual partial derivative notation.
For example, you'll find that you really do have an equation
$$ \mathrm{d}X = \mathrm{d}f(X,Y)$$
(and note that $\mathrm{d}Y = -4\,  \mathrm{d}X$)
