Differential equation with integrating factor 
Hey I am supposed to solve the following differential equation:
$(1-x^{2}y)dx+x^{2}(y-x)dy=0$

I found integrating factor:
$\varphi (x)=-\frac{2}{x}$
So I multiply my original equation and I got:
$\left ( \frac{1}{x^{2}} -y\right )dx+\left ( y-x \right )dy=0$
But then I try to integrate it and I got stuck. The answer should be:
$y^{2}-2xy-\frac{2}{x}=C$
Can somebody help me?
Thanks
 A: Strating from your last line:
$$\left ( \frac{1}{x^{2}} -y\right )dx+\left ( y-x \right )dy=0$$
$$\frac{1}{x^{2}} dx+ y dy-(xdy+ydx)=0$$
$$\frac{1}{x^{2}} dx+ y dy-dxy=0$$
Integration gives us:
$$-\frac{2}{x} + y^2 -2xy=c$$
$$\frac{2}{x} - y^2 +2xy=C$$
A: $P(x,y)dx + Q(x,y)dy = 0$
$P(x,y) = \frac{1}{x^2} - y, Q(x,y) = y - x$
$\frac{\partial Q}{\partial x} = \frac{\partial P}{\partial y} = -1$
So this is exact differential equation.
To solve the exact differential equation, let's write two differential equations that define function $u(x,y)$
$\frac{\partial u}{\partial x} = P(x,y)$
$\frac{\partial u}{\partial y} = Q(x,y)$
$u(x,y) = \int P(x,y) dx + \varphi(y) = - \frac{1}{x} - xy + \varphi(y)$ ...(i)
$\varphi'(y) = Q(x,y) - \frac{\partial \, (- \frac{1}{x} - xy)}{\partial y} = y - x + x = y$
$\varphi(y) = \frac{y^2}{2}$ ...(ii)
Substituting (ii) in (i),
$u(x,y) = \frac{y^2}{2} - xy - \frac{1}{x} = C_1$
Or, $y^2 - 2xy - \frac{2}{x} = C$
A: $(1-x^2y)~dx+x^2(y-x)~dy=0$
$x^2(y-x)~dy=(x^2y-1)~dx$
$(y-x)\dfrac{dy}{dx}=y-\dfrac{1}{x^2}$
Let $u=y-x$ ,
Then $y=u+x$
$\dfrac{dy}{dx}=\dfrac{du}{dx}+1$
$\therefore u\left(\dfrac{du}{dx}+1\right)=u+x-\dfrac{1}{x^2}$
$u\dfrac{du}{dx}+u=u+x-\dfrac{1}{x^2}$
$u\dfrac{du}{dx}=x-\dfrac{1}{x^2}$
$u~du=\left(x-\dfrac{1}{x^2}\right)$
$\int u~du=\int\left(x-\dfrac{1}{x^2}\right)~dx$
$\dfrac{u^2}{2}=\dfrac{x^2}{2}+\dfrac{1}{x}+c$
$u^2=x^2+\dfrac{2}{x}+C$
$(y-x)^2=x^2+\dfrac{2}{x}+C$
$y^2-2xy+x^2=x^2+\dfrac{2}{x}+C$
$y^2-2xy=\dfrac{2}{x}+C$
