Solve the following differential equation: $xy' - y = x^2$ I'm preparing to exam in Linear Algebra $2$ and I have problems with differential equations..
For example, the following exercise:

Solve the following differential equation: $xy' - y = x^2$.

I started to solve:
$$xy' - y = x^2$$
$$ \implies y' - \frac{y}{x} = x$$
I need to find some $u$ and multiply both sides by it:
$$uy' - \frac{u}{x}y = ux$$
I need somehow to satisfy the product rule of derivative, by finding $u$ such that $u' = -\frac{u}{x}$ and by this get: $(uy)' = uy' + u'y$.
I need the help to find $u$.
I need to find $u$ such that $u' = -\frac{u}{x}$.
How would you find $u$? thanks in advance.
 A: Hint: $\dfrac{u'}{u}=(\ln u)'$, so $\dfrac{u'}{u}+\dfrac{1}{x}=0$ implies $(\ln u)'+(\ln x)'=0$.
A: Your differential equation $xy'-y=x^2$ can, assuming $x \neq 0$, be rewritten as 
$$y' - \frac{1}{x}y = x$$
This is a first order differential question of the form $y'+P(x)y=Q(x)$. Such equations can be solved by finding an integrating factor, say $\mu$, which when we multiply through by $\mu$, the left-hand side is an exact derivative. In the case of $y' + Py = Q$ we have
$$\mu = \mathrm{e}^{\ \int P\, \mathrm{d}x}$$
In our case, $P=-\frac{1}{x}$ and so $\mu = \frac{1}{|x|}$. 
If $x>0$, then $\mu =\frac{1}{|x|} \equiv \frac{1}{x}$. If $x<0$, then 
$\mu = \frac{1}{|x|} \equiv -\frac{1}{x}$. Multiplying through by $\mu = \pm\frac{1}{x}$ gives an equation equivalent to
$$\frac{1}{x}y'-\frac{1}{x^2}y = 1$$
The left-hand side is an derivative:
$$\left(\frac{1}{x}y\right)' = 1$$
Integrating both sides gives
$$\frac{1}{x}y = x + c$$
It follows that $y=x^2 + cx$, where $c \in \mathbb{R}$.
NOTE: 
The method of using an integrating factor can be used to solve $u'+\frac{1}{x}u=0$. In this case $P=\frac{1}{x}$ and so $\mu = x$. Multiplying through gives $xu'+u=0$ and hence $(xu)'=0$. It follows that $xu = c$ and hence $u=\frac{c}{x}$.
