Find a first integral of an ODE system I have the system
$$ \left\{\begin{array}{ccl}
\dot x & = & 2xy \\
\dot y & = & x+y^2 \\
\end{array} \right. $$
and I need to find a first integral $H$ of the system. This is easy if the equation 
$(x+y^2)dx-2xy dy = 0 $ is exact (i.e the divergence of the field is 0). In this case, the divergence is $4y$ so I need to find an integrating factor $\mu(x,y) $ . But I don't know how to do it, because it doesn't work if I use that $\mu$ is just a function of $x$ or $y$. 
Any help is welcome!

Collect terms in the differential form and combine them into differentials of increasingly complex functions to reduce the number of terms,
$$
0=\frac12d(x^2)+y^2dx - xd(y^2)=\frac12d(x^2)-x^2d(\frac{y^2}x).
$$
With $u=x^2$ and $v=\frac{y^2}{x}$ this reads as
$$
0=\frac12du-udv=-u\,d\!\left(-\frac12\ln u+v\right),
$$
which gives $F=-\frac12\ln u+v=-\ln|x|+\frac{y^2}x$ as first integral. Test by differentiating along a solution
$$
\frac{dF}{dt}=-\frac{\dot x}{x}-\frac{y^2\dot x}{x^2}+\frac{2y\dot y}{x}
=-2y-\frac{2y^3}{x}+\frac{2y(x+y^2)}{x}=0
$$
