First order linear differential equation, wrong result I have a differential equation:  
$y'= \frac{y}{x} + x^2$
I apply this formula:  
$y(x)= e^{A(x)} \int {e^{-A(x)} b(x)  dx} $
With $a(x) = \frac{1}{x}$ and $b(x)= x^2$, and $A(x)$ primitive of $a(x)$.
It gives:  
$y(x)= e^{log|x|} \int{ e^{-log|x|} x^2 dx }$ = $|x| - \int{ |x| \cdot x^2 dx } $ 
With $x>0$ it is equal to $x - \frac{x^4}{4} $
But the result is wrong, it is $\frac{1}{2} \cdot x^3 + c \cdot x $
What am I doing wrong? I have this problem solved on the book using a "trick" instead of using this formula. Possibly I would know what I am doing wrong and how this problem can be solved using the formula above, instead of giving another solution which doesn't follow an ordinary pattern.
 A: The solution is
$$
y(x) = e^{A(x)} \cdot \bigg ( \int e^{-A(x)} b(x) dx + C \bigg )
$$
Then computing you get
$$
y(x) = x \cdot \bigg ( \int x dx + C \bigg ) = \frac{x^3}{2} + C x 
$$
Your manipulations with the $\log$ contained many mistakes.
A: At least one mistake I could find is that:
Your step after "It gives:" is incorrect.
$$e^{-\log(|x|)}=\frac{1}{|x|}$$ 
What you have written is: 
$$e^{-\log(|x|)}=|x|$$ 
A: Want to solve the differential equation:
$$y'= \frac{y}{x} + x^2$$
First normalize the form:
$$y'+ \biggr(-\frac{1}{x}\biggr)y = x^2$$
Now we can introduce an integrating factor of $e^{\int -\frac{1}{x}dx}=\dfrac{1}{x}$.
$$\dfrac{1}{x}\biggr[y'+ \biggr(-\frac{1}{x}\biggr)y\biggr] = x$$
Integrating both sides gives us
$$\begin{align*}
\dfrac{y}{x} &= \dfrac{x^2}{2}+C\\
y &= \dfrac{x^3}{2}+Cx
\end{align*}$$
EDIT: Continuing from the comments below, consider the general linear first-order equation
$$y' + f(x)y = g(x)$$
We want to find an integrating factor $\lambda (x)$ such that $\lambda (x)[y' + f(x)y] = \lambda (x)g(x)$ has an exact solution. Clearly the right hand side is integrable, so we focus on the left. In order for the left hand side to be integrable, the following must be true:
$$\dfrac{d \lambda (x)}{dx} = \lambda(x)f(x)$$
We can separate this equation find the solution:
$$\lambda(x) = e^{\int f(x) dx}$$
