I am differentiating a function $f(x,y) = ax( \frac{y}{x} + b)$ with respect to $\frac{y}{x}$ (where $a$ and $b$ are constants). I am doing it in 2 ways and different results come up. What goes wrong?
- When $f(x,y) = ax(\frac{y}{x}+ b)$, then: $$\frac{df}{d(\frac{y}{x})} = a \frac{dx}{d(\frac{y}{x})}\Big(\frac{y}{x} + b\Big) + ax(1 + 0)$$ where the term $\frac{dx}{d(\frac{y}{x})}$ I obtain as: $$\frac{dx}{d(\frac{y}{x})} = \frac{1}{\frac{d(\frac{y}{x})}{dx}} = \frac{1}{\frac{-y}{x^2}} = \frac{x^2}{-y}$$ and plug into the expression before, obtaining: $$\frac{df}{d(\frac{y}{x})} = a \Big(\frac{x^2}{-y}\Big) \Big(\frac{y}{x} + b\Big) + ax = -ax - ab\frac{x^2}{y} + ax = - ab\frac{x^2}{y}$$
- However, when I first simplify: $f(x,y) = ax( \frac{y}{x} + b) = ay + abx$ and then differentiate, I get: $$\frac{df}{d(\frac{y}{x})} = a \frac{dy}{d(\frac{y}{x})} + ab\frac{dx}{d(\frac{y}{x})}$$ where the term $\frac{dy}{d(\frac{y}{x})}$ I obtain as: $$\frac{dy}{d(\frac{y}{x})} = \frac{1}{\frac{d(\frac{y}{x})}{dy}} = \frac{1}{\frac{1}{x}} = x$$ and plug into the expression before, obtaining: $$\frac{df}{d(\frac{y}{x})} = ax +ab \Big(\frac{x^2}{-y}\Big) = ax - ab\frac{x^2}{y}$$
This is clearly different from the result obtained in 1, so what went wrong ??