Integrating factor of $x^2ydx-(x^3+y^3)dy=0$ $x^2ydx-(x^3+y^3)dy=0$
I have to find an integrating factor $\mu$.
Denote $P=x^2y,Q=-(x^3+y^3)$
The correct answer for getting an integrating factor is $\mu=e^{\int\frac{P_y-Q_x}{\color{red}{P}}dy}$ or $\mu=e^{\int\frac{P_y-Q_x}{\color{red}{-P}}dy}$ ?
In my post Solve $ye^ydx+(1+xe^y)dy=0$ , I got a comment that the correct answer is $\mu=e^{\int\frac{P_y-Q_x}{\color{red}{P}}dy}.$
Then , $\int\frac{x^2+3x^2}{x^2y}dy=4ln|y| \implies \mu=e^{ln|y|}=y^4$ , But the correct integrating factor is $y^{-4}$.
How is it possible ? maybe $\mu=e^{\int\frac{P_y-Q_x}{\color{red}{-P}}dy}$?
Thanks !
 A: There is no general formula for an integrating factor.
However you can assume the integrating factor depends only on one variable or the other, and if that assumption is consistent with the equation then you can go from there.
If you assume it depends only on $x$ and the equation is of the form $P dx + Q dy = 0$ then you want $\frac{\partial}{\partial y}(P\mu)=\frac{\partial}{\partial x}(Q\mu)$, which is to say $P_y \mu = Q_x \mu + Q \mu'$, so $\mu'=\frac{P_y-Q_x}{Q} \mu$. This is consistent with the assumption about $\mu$ if and only if $\frac{P_y-Q_x}{Q}$ depends only on $x$.
If you assume it depends only on $y$ then you want $\frac{\partial}{\partial y}(P\mu)=\frac{\partial}{\partial x}(Q\mu)$ or $P_y \mu + P \mu' = Q_x \mu$, so $\mu'=\frac{Q_x-P_y}{P} \mu$. Note the sign change. This is consistent with the assumption about $\mu$ if and only if $\frac{Q_x-P_y}{P}$ depends only on $y$.
This is the same as what was told to you in the comments of the other question.
A: You forgot a minus in the formula for integrating factor. The formula says that if $(P_y-Q_x)/M$ is a function of $y$ only, then the equation $P(x,y)dx+Q(x,y)dy=0$ has an intergrating factor
$\mu(y)=\exp\left(-\int\dfrac{P_y-Q_x}{M}dy\right).$
In your case, $(P_y-Q_x)/M=(4x^2)/(x^2y)=4/y$, thus
$\mu(y)=\exp\left(-\int 4dy/y\right)=1/y^4.$
