Integrating factor of a differential arising from thermodynamics Let $\delta E = (xy^2 + xye^x)dx + (2x^2y + xe^x)dy$
I now need to find the integrating factor $\mu (x,y)$ s.t. $dS = \mu (x,y) \delta E$ is a exact differential. 
Now as far as I know $\delta E$ is exact if $\int (xy^2 + xye^x)\mu (x,y)dx = \int (2x^2y + xe^x)\mu (x,y)dy$
i.e. $\frac{1}{2} x^2 y^2 + e^x(x-1)y + C_1(y) = x^2 y^2 + xe^x +C_2(x)$ which as given isn't exact. 
Now $\delta S$ is exact if $\int (xy^2 + xye^x)\mu (x,y)dx = \int (2x^2y + xe^x)\mu (x,y)dy$ at least I think so. But how do I compute these integrals when I have no idea what $\mu (x,y)$ looks like? Can somebody explain this to me?
Cheers in advance!
 A: The differential is exact if it's of the form
$$
\mathrm dS=\frac{\partial S}{\partial x}\mathrm dx+\frac{\partial S}{\partial y}\mathrm dy\;,
$$
and you can check this using the integrability condition
$$
\frac{\partial}{\partial y}\frac{\partial S}{\partial x}=\frac{\partial}{\partial x}\frac{\partial S}{\partial y}\;.
$$
In your case, this is
$$
\frac{\partial}{\partial y}\left(\mu\left(xy^2+xy\mathrm e^y\right)\right)=\frac{\partial}{\partial x}\left(\mu\left(2x^2y+x\mathrm e^y\right)\right)\;,
$$
that is,
$$
\frac{\partial\mu}{\partial y}\left(xy^2+xy\mathrm e^x\right)+\mu\left(2xy+x\mathrm e^x\right)=\frac{\partial\mu}{\partial x}\left(2x^2y+x\mathrm e^x\right)+\mu\left(4xy+x\mathrm e^x+\mathrm e^x\right)\;.
$$
The ansatz $\mu=x^\alpha y^\beta$ seems promising, and indeed substituting this, dividing through by $x^\alpha y^\beta$ and separately comparing the coefficients of the polynomial and exponential terms yields the two equations
$$
\beta xy+2xy=2\alpha xy+4xy
$$
and
$$
\beta x\mathrm e^x+x\mathrm e^x=\alpha\mathrm e^x+x\mathrm e^x+\mathrm e^x\;,
$$
which are simultaneously solved by $\alpha=-1$ and $\beta=0$. Thus the integrating factor is $\mu=1/x$; with hindsight, this might have been guessed from the fact that all coefficients contain a factor $x$.
A: Besides to generalized method of @joriki, if you take $$
M(x,y)=\left(xy^2+xy\mathrm e^x\right)$$ and $$N(x,y)=\left(2x^2y+x\mathrm e^x\right)
$$ then $$\frac{M_y-N_x}{N}=\frac{-1}x$$
