How to solve non trivial first order differential equations with integrating factor I'm trying to solve the following problem:
Find the integrating factor and solve this first order differential equation:
3xy + y^2 + (x^2 + xy) * y' = 0
I'm trying to follow the solution process described here. Using the solution process took forever and I ended up with a monstrosity equation that I am unable to solve. It looks like I'm doing something incorrectly, but I don't know what. Is this an appropriate approach for this kind of problem? If it's not, what is a good strategy to work on problems like this?
Here's what I did so far:
First, I wrote the equation in the desired form:
(dy)/(dx) + (3x)/(x^2+xy)*y = -(y^2)/(x^2+xy)
Multiply both sides by u(x) to get:
u(x)*(dy)/(dx) + u(x)*(3x)/(x^2+xy)*y = -u(x)*(y^2)/(x^2+xy)
Assume u(x)*(3x)/(x^2+xy)*y = u'(x)*y (why do we get to make this assumption?)
Substitute that into the equation:
u(x)*(dy)/(dx) + u'(x)*y = -u(x)*(y^2)/(x^2+xy)
Use reverse product rule to get:
(u(x)*y)' = -u(x)*(y^2)/(x^2+xy) (I assume the derivate in the beginning is over dx?)
Integrate both sides:
u(x)*y + c = integrate(-u(x)*(y^2)/(x^2+xy) dx)
Now we want to solve u(x). I took the equation given for u(x) and substituted p(x) = (3x)/(x^2+xy) to get:
u(x) = e^integrate((3x)/(x^2+xy) dx)
Solving this we get:
u(x) = 3ln(x+y)
Substitute u(x) into our equation:
3ln(x+y)y + c = integrate(-(3ln(x+y)y^2)/(x^2+xy) dx)
I don't know where to go from here.
 A: After having a bref look at the method that you intend to use, I noticed that this method is valuable for a certain form of ODE. This is not the case of the ODE :
$$3xy + y^2 + (x^2 + xy) y' = 0$$
where $p$ and $q$ are not functions of $x$ only.
We have to use a more general form of the method of integrating factors. The ODE can be presented as:
$$(3xy+y^2)dx+(x^2+xy)dy=0$$
The aim it to find an integrating factor $\mu(x,y)$ in order to obtain a total derivative of a function $F(x,y)$ to be determined :
$$\mu(x,y)\left((3xy+y^2)dx+(x^2+xy)dy \right)=dF(x,y)$$
so that, the ODE will become $dF(x,y)=0 \quad\to\quad F(x,y)=C$
$$dF=\frac{\partial F}{\partial x}dx+\frac{\partial F}{\partial y}dy \quad\to\quad \begin{cases}
\frac{\partial F}{\partial x}=\mu(x,y)(3xy+y^2)\\
\frac{\partial F}{\partial y}=\mu(x,y)(x^2+xy) 
\end{cases}$$
$$\frac{\partial^2 F}{\partial x\partial y}=\frac{\partial  }{\partial x}\mu(x,y)(x^2+xy)=\frac{\partial  }{\partial y}\mu(x,y)(3xy+y^2)$$
$$(x^2+xy)\frac{\partial \mu(x,y)  }{\partial x}+(2x+y)\mu(x,y)=(3xy+y^2)\frac{\partial \mu(x,y)  }{\partial y}+(3x+2y)\mu(x,y)$$
At this point, the general process could become very complicated. Since the problem is probably a textbook case, we can suppose that $\mu(x,y)$ is a very simple function. We try more simple forms like $\mu(x)$ or $\mu(y)$ or more complicated if not adequate.
For example, with the variable $x$ only 
$$(x^2+xy)\frac{d \mu(x)  }{d x}+(2x+y)\mu(x)=(3x+2y)\mu(x)$$
This equation must contains functions of $x$ only $\quad\to\quad \begin{cases}
x\frac{d \mu  }{d x}+\mu=2\mu \\
x^2\frac{d \mu  }{d x}+2x\mu=3x\mu
\end{cases} \quad\to\quad \mu(x)=x$
We are not looking for the general solution for $\mu(x)$ : only any one particular solution is enough. So, $\mu=x$ is very well, because simple.
$$x\left((3xy+y^2)dx+(x^2+xy)dy \right)=dF(x,y)$$
$$(3x^2y+xy^2)dx+(x^3+x^2y)dy=dF(x,y)=0$$
$$d(x^3y+\frac{1}{2}x^2y^2)=dF(x,y)=0$$
$$F(x,y)=x^3y+\frac{1}{2}x^2y^2=C$$
$$x^2y^2+2x^3y-2C=0$$
$$y=\frac {-x^3 \pm  \sqrt{x^6 +2Cx^2}}{x^2}=\frac {-x^2 \pm  \sqrt{x^4 +C'}}{x}$$
IN ADDITION :
If we don't want to make an assumption about a simplified form for $\mu(x,y)$ we have to continue from the above equation :
$$(x^2+xy)\frac{\partial \mu(x,y)  }{\partial x}+(2x+y)\mu(x,y)=(3xy+y^2)\frac{\partial \mu(x,y)  }{\partial y}+(3x+2y)\mu(x,y)$$
$$(x^2+xy)\frac{\partial \mu(x,y)  }{\partial x}-(3xy+y^2)\frac{\partial \mu(x,y)  }{\partial y}=(x+y)\mu(x,y)$$
Solving this PDE thanks to the method of characteristics starts from the set of ODEs for the characteristics curves :
$$\frac{dx}{x^2+xy}=\frac{dy}{-(3xy+y^2)}=\frac{d\mu}{(x+y)\mu}$$
With the first ODE : $\frac{dx}{x^2+xy}=\frac{dy}{-(3xy+y^2)}$ not surprisingly we come back to the first beginning : $(3xy+y^2)dx+(x^2+xy)dy=0$. This is of no interest.
With the second ODE : $\quad\frac{dx}{x^2+xy}=\frac{d\mu}{(x+y)\mu}\quad\to\quad
\frac{dx}{(x+y)x}=\frac{d\mu}{(x+y)\mu}\quad$ it is obvious that $\quad \mu=x\quad$ is a solution. We are not looking for all solutions for $\mu$. Only one (any one) is sufficient. This one $\mu=x$ is what we where looking for. The end of the calculus was already shown above.
NOTE :
Some particular forms for the integrating factor are ready-made, so avoiding a long calculus. For example , see the cases (11), (12), (13) in : 
 http://mathworld.wolfram.com/OrdinaryDifferentialEquation.html 
