What is the integrating factor for this non-exact differential equation? I am trying to solve this non-exact differential equation: $$2y(x^2-y+x)dx\,+\,(x^2-2y)dy = 0$$
Assuming that the integrating factor is of the form $x^my^m$:
$$2(n+1)x^{m+2}y^n-2(n+2)x^my^{n+1}+2(n+1)x^{m+1}y^n=(m+2)x^{m+1}y^n-2mx^{m-1}y^{n+1}$$
Equating co-efficients of like terms:
$$2n+2=0\\-2n-4=0\\2n+2=m+2\\-2m=0$$
Obviously this system has no solution. What could I be missing here? Is the integrating factor of a form different from $x^my^n$?
 A: Let $M=2x^2y-2y^2+2xy$ and $N=x^2-2y$ Then
$$ \frac{\partial M}{\partial y}=2x^2-4y+2x $$
$$ \frac{\partial N}{\partial x}=2x$$
So
$$ \frac{1}{N}\left(\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}\right)=2 $$
So $\mu=e^{\int 2\,dx}=e^{2x}$ is an integrating factor.
ADDENDUM:
In general if
$$ p=\frac{1}{N}\left(\frac{\partial M}{dy}-\frac{\partial N}{dx}\right) $$
is a function of $x$ alone (or a constant) then $\mu=e^{\int p(x)\,dx}$ is an integrating factor.
And if
$$q=\frac{1}{M}\left(\frac{\partial N}{dx}-\frac{\partial M}{dy}\right)  $$
is a function of $y$ alone (or a constant) then $\mu=e^{\int q(y)\,dy}$ is an integrating factor.
A: $$2y(x^2-y+x)dx\,+\,(x^2-2y)dy = 0$$
$$dx^2y+2y(x^2-y)dx-2ydy = 0$$
Substitute $u=x^2y$:
$$(du+2udx)-(2y^2dx+dy^2) = 0$$
Integrating factor:
$$2 \mu dx =d \mu $$
$$(\ln \mu)'=2$$
$$\mu (x) =e^{2x}$$
Therefore:
$$(e^{2x}du+ude^{2x})-(y^2de^{2x}+e^{2x}dy^2) = 0$$
$$due^{2x}-de^{2x}y^2 = 0$$
Integrate.
$$x^2ye^{2x}-e^{2x}y^2 = C$$
$$ye^{2x}(x^2-y) = C$$
