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.
 A: 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}$$
A: Solve
\begin{gather*}
\boxed{y^{\prime}-\frac{y-x y^{2}}{x +x^{2} y}=0}
\end{gather*}
Using $u=yx$ the above becomes
\begin{align*}
u' &= \frac{2 u}{x \left(u +1\right)}
\end{align*}
This is separable. Integrating gives
\begin{align*}
\left(\frac{u +1}{u}\right)\mathop{\mathrm{d}u}&= \left(\frac{2}{x}\right)\mathop{\mathrm{d}x}\\   
\int \left(\frac{u +1}{u}\right)\mathop{\mathrm{d}u}&= \int \left(\frac{2}{x}\right)\mathop{\mathrm{d}x}
\end{align*}
Which gives
\begin{align*}
u +\ln \left(u \right) = 2 \ln \left(x \right)+c_{1}
\end{align*}
Replacing $u \left(x \right)$ in the above solution by $yx$ gives
\begin{align*}
x y+\ln \left(x y\right)-2 \ln \left(x \right)-c_{1} = 0
\end{align*}
This is implicit solution. If you want explicit, you'll have to deal with LambertW special function.
A: Starting from your last line:
$$y'=\frac{y(1-u)}{x(1+u)}.$$
Then:
$$xy'=\frac{y(1-u)}{(1+u)}.$$
$$u'-y=\frac{y(1-u)}{(1+u)}.$$
$$u'=\frac{y(1-u)+y(1+u)}{(1+u)}.$$
$$u'=\frac{2y}{(1+u)}$$
$$xu'=\frac{2xy}{(1+u)}$$
$$xu'=\frac{2u}{(1+u)}$$
$$x\dfrac {du}{dx}=\frac{2u}{(1+u)}$$
The DE is separable:

Another solution:
$$y'=\frac{y-xy^2}{x+x^2y}$$
$$y'x-y=-xy^2-x^2yy'$$
$$d\dfrac {y}{x}=-\dfrac 12 \dfrac {d(x^2y^2)}{x^2}$$
$$\dfrac x yd\dfrac {y}{x}=- {d(xy)}$$
Integrate.
$$\ln \dfrac yx+xy=C$$
A: $(xy^{2}-y)~dx+(yx^{2}+x)~dy=0$
Integrating factor :$μ(x,y)=x^{m} y^{n}$
$(x^{m}y^{n+2}-x^{m}y^{n+1})~dx+(y^{n+1}x^{m+2}+x^{m+1}y^{n})~dy=0$
\begin{cases} \frac{\partial M}{\partial y}=(n+2)x^{m}y^{n+1}-(n+1)x^{m}y^{n} \\\\
\frac{\partial N}{\partial x}=(m+2)x^{m+1}y^{n+1}+(m+1)x^{m}y^{n}\\\\
\end{cases}
The condition of exact of the differential equation :$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$
\begin{cases} m+2=n+2 \\\\
-n-1=m+1\\\\
\end{cases}
$m=n=-1$
$μ(x,y)=x^{-1} y^{-1}$
$(y-x^{-1})~dx+(x+y^{-1})~dy=0$
$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}=1$
$f(x,y)=\int(y-x^{-1})~dx+h(y)=xy-\ln(x)+h(y)$
$x+h'(y)=x+y^{-1}$
$h(y)=\int y^{-1}~dy=\ln(y)$
$f(x,y)=xy-\ln(x)+\ln(y)=c$
$$xy+\ln(\frac{y}{x})=C$$
