What is the general solution of $xy' - 2y = -x$? I am trying to find the general solution of $xy' - 2y = -x$. 
I normalize the equation to get $y' - \frac{2}{x}y = -1$.
I get the integrating factor as $x^{-2}$, and so $y = x^{2}\int x^{-2}*(-1)\,dx $.
Solving for this integral, I get $ y = x + \frac{C}{x^2}$, but this is not the answer I get on wolfram, which is $Cx^2 +x$. I'd like to know where I'm going wrong.
 A: After dividing both sides by $x$ you get
$$y'(x) - \frac{2}{x}y(x) = -1$$
The integrating factor is
$$\mu(x) = e^{\int -\frac{2}{x}\ dx} = \frac{1}{x^2}$$
Then by following the procedure, you multiply both sides by $\mu(x)$:
$$\frac{1}{x^2}y'(x) - \frac{2}{x^3}y(x) = -\frac{1}{x^2}$$
Use the tricky substitution:
$$-\frac{2}{x^3} = \frac{d}{dx} \frac{1}{x^2}$$
To get
$$\frac{1}{x^2} y'(x) + \frac{d}{dx} \left(\frac{1}{x^2}\right) y(x)  = -\frac{1}{x^2}$$
Now in the central term, we apply the reverse product rule:
$$f g' = (fg)' - f'g$$
This will help you to get rid of the first term. Now integrate what remains with respect to $x$:
$$\int \frac{d}{dx}\left(\frac{y(x)}{x^2}\right) \ dx = \int -\frac{1}{x^2}\ dx$$
Easily: 
$$\frac{y(x)}{x^2} = \frac{1}{x} + C$$
Hence
$$\color{red}{y(x) = x + Cx^2}$$
A: Without Rhs,
$$\frac {y'}{y}=\frac {2}{x} $$
thus
$$y_h=\lambda x^2$$
the variation of the constant gives
$$x^3\lambda'(x)=-x $$
or
$$\lambda'(x)=-\frac {1}{x^2} $$
and
$$\lambda (x )=\frac {1}{x}+C $$
Finally
$$y_g=Cx^2+x $$
A: Just be more careful. You have
$$
\int\frac{-1}{x^2}\,dx=\frac{1}{x}+C
$$
so
$$
y=x^2\left(\frac{1}{x}+C\right)=x+Cx^2
$$
A: $$xy' - 2y = -x \implies xy' - y = y-x$$
$$\frac {xy' - y}{x^2} = \frac {y-x} {x^2}$$
$$\left( \frac y x\right )' = \frac 1 x \left (\frac y x\right )-\frac 1 x$$
It's seperable now :
$$\left( \frac y x\right )' = \frac 1 x \left ( \left (\frac y x\right )-1 \right )$$
Just integrate now :
$$\int \dfrac {d\left( \dfrac y x\right )}{ \left ( \dfrac y x -1 \right )}=\int \frac {dx} x= \ln|x|+K$$
$$\ln  \left | \dfrac y x -1 \right |=\ln|x|+K$$
$$.......$$
