<s>[INST] How to solve this differential equation: $x^2dy-y^2dx+xy^2(x-y)dy=0$ 
$$x^2dy-y^2dx+xy^2(x-y)dy=0$$


What I tried:
$$\frac{x^2}{y^2} \frac{dy}{dx}+x(x-y)\frac{dy}{dx}=1\\$$
Let $h=-1/x, \; k=-1/y,\; dh=1/x^2 \,  dx, \; dk=1/y^2 \,dy$
$$\frac{dk}{dh}+\frac{(k-h)}{k^2} \frac{dk}{dh}=1\\
\frac{dk}{dh}+\frac hk=1+\frac1k\\
he^{\int-1/k^2\; dk}=\int\left(1+\frac1k\right)e^{\int-1/k^2\; dk}dk\\
he^{-y}=\int\frac{1-y}{y^2}e^{-y}dy=\int\left(\frac 1{y^2}-\frac1y\right)e^{-y}dy$$
Which probably is unsolvable?I tried using IBP on RHS.Dont use Ricatti Eqn(Not in my course)
Answer is:

 $$\large\ln\left|\frac{x-y}{xy}\right|=\frac{y^2}2+\mathcal C$$

 [/INST] The equation is $\displaystyle \frac{dy(x)}{dx}\cdot{\frac{x^2}{y(x)^2}}+\frac{dy(x)}
{dx}\cdot{x(x-y(x))}=1$.
Multiplying by $y(x)^2$ we get $$\displaystyle \frac{dy(x)}{dx}\left[x^2+x(x-y(x))y(x)^2\right]=y(x)^2 \rightarrow \frac{dy(x)}{dx}=\frac{y(x)^2}{x^2+x^2y(x)^2-xy(x)^3}$$
Now, $\displaystyle \frac{dy(x)}{dx}=\large \frac{1}{\frac{dx(y)}{dy}}$, so $$\displaystyle \frac{1}{\frac{dx(y)}{dy}}=\frac{y^2}{x(y)^2+x(y)^2y^2-x(y)y^3} \Rightarrow \frac{dx(y)}{dy}=x(y)^2-yx(y)+\frac{x(y)^2}{y^2}$$
Adding $yx(y)$ and dividing by $-x(y)^2$ we get $\displaystyle -\frac{\frac{dx(y)}{dy}}{x(y)^2}-\frac{y}{x(y)}=-\left(\frac{1}{y^2}+1\right)$.
Let $\displaystyle v(y)=\frac{1}{x(y)} \rightarrow \frac{dv(y)}{dy}=-\frac{\frac{dx(y)}{dy}}{x(y)^2}$.
Multiplying both sides by $\displaystyle e^{\Large \frac{-y^2}{2}}$ we get$$\displaystyle e^{\large -\frac{y^2}{2}}\frac{dv(y)}{dy}-\left(e^{\large-\frac{y^2}{2}}y\right)v(y)=-e^{\large-\frac{y^2}{2}}\left(\frac{1}{y^2}+1\right)$$
Using the reverse product rule to get $$\displaystyle \frac{d}{dy}\left(e^{\large -\frac{y^2}{2}}v(y)\right)=-e^{\large-\frac{y^2}{2}}\left(\frac{1}{y^2}+1\right)$$
Integrate both sides to get $$\displaystyle e^{\large -\frac{y^2}{2}}v(y)=-\int e^{\large -\frac{y^2}{2}}\left(\frac{1}{y^2}+1\right)dy$$
Using the result shown in the link Integrate $e^{-\frac{y^2}{2}}\left(\frac{1}{y^2}+1\right)$ we get $$\displaystyle e^{\large -\frac{y^2}{2}}v(y)=\frac{e^{\large -\frac{y^2}{2}}}{y}+\mathcal{C_1}$$
We get that $\displaystyle v(y)=\frac{1}{y}+\mathcal{C_1}e^{\large \frac{y^2}{2}}$.
Now we can write that $\displaystyle v(y)-\frac{1}{y}=\mathcal{C_1}e^{\large \frac{y^2}{2}}$.
Taking logarithm from both sides we get $\displaystyle \ln\left|v(y)-\frac{1}{y}\right|=\frac{y^2}{2}+\ln(\mathcal{C_1})$.
Substitute $\displaystyle v(y)=\frac{1}{x(y)}$ we find that the final answer is $\displaystyle \ln\left|\frac{1}{x}-\frac{1}{y}\right|=\frac{y^2}{2}+C_2$.
</s>