Non-Exact solution to ODE Question:
$$ \text{Solve:}  \; \; (3xy+y^2)dx+(x^2+xy)dy=0$$
Solution Thus far:
$$ M = 3xy+y^2 \; \text{and} \; N= x^2+xy $$
$$ \frac{\partial{M(x,y)}}{\partial{y}} = 3x + 2y$$
$$ \frac{\partial{N(x,y)}}{\partial{x}} = 2x + y$$
$$ \implies \frac{\partial{N}}{\partial{x}} -\frac{\partial{M}}{\partial{y}} \neq 0 $$
Hence this is not an exact equation therefore we must apply an integrating factor such that:
$$ \mu(x,y)M (x,y)+ \mu(x,y) N (x,y) = 0 $$ which is an exact equation
, meaning this is equivalent so solving the equation:
$$ \frac{\partial{\mu(x,y)M(x,y)}}{\partial{y}} = \frac{\partial{\mu(x,y)N(x,y)}}{\partial{x}} $$
Now rearrange this into a more computationally friendly form:
$$ (-N(x,y)) \frac{\partial{\mu}}{\partial{x}} + M(x,y)\frac{\partial{\mu}}{\partial{y}} =  \bigg{(} \frac{\partial{N}}{\partial{x}} -\frac{\partial{M}}{\partial{y}} \bigg{)} \mu $$
$ \text{define:} \; \mu = \text{integrating factor} $
Where I'm stuck:
$ \mu (x,y) = \mu(x) $ did not work
$ \mu (x,y) = \mu(y) $ did not work
$ \mu (x,y) = \mu(x+y) $ nearly worked but didn't
This guess and testing of an integrating factor is too difficult for me. How does one gain the intuition to find it. Or am I using the wrong technique entirely? Any insight would be greatly appreciated!
 A: We are given
$$(3xy+y^2)dx+(x^2+xy)dy=0$$
Rearrange the differential equation to
$$\frac{dy}{dx}=-\frac{3xy+y^2}{x^2+xy}$$
then let $$y=vx,\quad \frac{dy}{dx}=v + x\frac{dv}{dx}$$ 
The differential equation becomes
$$v + x\frac{dv}{dx}=-\frac{3x^2v+v^2x^2}{x^2+x^2v}$$
$$v + x\frac{dv}{dx}=-\frac{3v+v^2}{1+v}$$
$$x\frac{dv}{dx}=-\frac{4v+2v^2}{1+v}$$
$$\frac{1+v}{4v+2v^2}\,dv=-\frac{1}{x}\,dx$$
$$\frac{2+2v}{2v+v^2}\,dv=-\frac{4}{x}\,dx$$
Integrate both sides. 
In general, a common strategy is to rewrite the first order differential equation as a homogeneous equation of the form
$$\frac{dy}{dx}=f(x,y)$$
from which a common substitution is $y=vx$. The first order equation can then be solved as a separable equation after you substitute the values of $y$ and $dy$ and then simplify.
A: $$\text{Solve:}  \; \; (3xy+y^2)dx+(x^2+xy)dy=0$$
Multiply by Integrating Factor that depends only on $x$:
$$(3xy+y^2)\mu(x)dx+(x^2+xy)\mu(x)dy=0$$
$$Mdx+Ndy=0$$
$$M_y=\mu(x)(3x+2y), \; $$
$$N_x=\mu '(x) (x^2+xy)+\mu(x) (2x+y)$$
For exactness we need that:
$$\mu(x)(3x+2y)=\mu '(x) (x^2+xy)+\mu(x) (2x+y)$$
$$ \implies \frac {\mu '(x)}{ \mu (x)}=\frac {1}{x}$$
$$\ln |\mu (x )|=\ln x  \implies \mu(x)=x$$
Multiply by Integrating Factor that depends only on $x$ and $\mu(x)=x$ :
$$(3x^2y+y^2x)dx+(x^3+x^2y)dy=0$$
$$Mdx+Ndy=0$$
$$M_y=3x^2+2yx,\,\, N_x=3x^2+2xy$$
It's exact...Maybe you made a mistake somewhere ? Do the calculations again for the integrating factor. 

Another way: 
$$\text{Solve:}  \; \; (3xy+y^2)dx+(x^2+xy)dy=0$$
$$(3x^2y+y^2x)dx+(x^3+x^2y)dy=0$$
Rearrange terms:
$$(3x^2ydx+x^3dy)+(y^2xdx+x^2ydy)=0$$
$$d(x^3y)+\frac 12(2y^2xdx+2x^2ydy)=0$$
Now, it's exact:
$$d(x^3y)+\frac 12d(xy)^2=0$$
Integrate:
$$\boxed {2x^3y+(xy)^2=K}$$
A: Hint: You can try converting into a homogeneous equation. Write it in the form:
$$\frac{dy}{dx} = -\frac{y(3+\frac{y}{x})}{x(1+\frac{y}{x})} $$
Then use the substitution $v=\frac{y}{x}$. Can you take it from here?
Edit: There is a nice justification for this kind of substitution. It comes from the fact that the functions $M(x,y)=3xy+y^2$ and $N(x,y)=x^2+xy$ are homogeneous polynomials of degree $2$.
A polynomial $P$ of $n$ variables is said to be homogeneous of degree $d$ whenever $P(\lambda x_1,\lambda x_2,\dots,\lambda x_n) = \lambda^d P(x_1, x_2,\dots,x_n)$. Here, we have that $d=2$ and $n=2$ for $M$ and $N$.
The idea behind the substitution is to then reduce the number of variables. Note that you can always express the equation as:
$$\frac{dy}{dx} = -\frac{3xy+y^2}{x^2+xy} =F(x,y)$$
To reduce the number of variables of $F$ from $2$ to $1$, you use the fact that $M$ and $N$ are homogeneous and write:
$$ F(\lambda x,\lambda y) = -\frac{M(\lambda x,\lambda y)}{N(\lambda x,\lambda y)} = -\frac{M(x,y)}{N(x,y)} $$
Letting $\lambda = \frac{1}{x} $ accomplishes just this. So we'd have instead: 
$$\frac{dy}{dx}= F(1, \frac{y}{x}) = f(\frac{y}{x})=-\frac{3(\frac{y}{x})+(\frac{y}{x})^2}{1+\frac{y}{x}}$$
You can naively think about it as just replacing $x$ by $1$ and $y$ by $\frac{y}{x}$. The function $f$ is only dependent on one variable, put this new variable as $v = \frac{y}{x}$. Then you can proceed as you would normally. 
