<s>[INST] How to solve the differential equation $y'=\frac{y-xy^2}{x+x^2y}$ $$y'=\frac{y-xy^2}{x+x^2y}$$
This is the equation I want to solve.
My idea is to substitute $xy$ with $u,$ $u=xy$ and $\frac{du}{dx}=xy'+y.$
So, the equation becomes
$y'=\frac{y(1-u)}{x(1+u)}.$
What I am struggling with is how to deal with the $x$ and $y$ that are left in the equation.
 [/INST] The equation is $$y^{\prime}=\frac{y-x y^2}{x+x^2 y}$$
HINT:
We can re-write it as: $$-\frac{1}{y^2}\frac{dy}{dx}=\frac{\left(x-\frac{1}{y}\right)}{x+x^2 y}$$
Now letting $\frac{1}{y}=t \Rightarrow -\frac{1}{y^2}\frac{dy}{dx}=\frac{dt}{dx}$
$$\Rightarrow \frac{d t}{d x}=\frac{t(x-t)}{x(x+t)}=\frac{\frac{t}{x}\left(1-\frac{t}{x}\right)}{1+\frac{t}{x}}$$
Now use $t=vx \Rightarrow \frac{dt}{dx}=v+x\frac{dv}{dx}$
$$\Rightarrow \quad v+x \frac{d v}{d x}=\frac{v(1-v)}{1+v} \Rightarrow x \frac{d v}{d x}=\frac{-2 v^2}{1+v}$$
</s>