Absolute value in integrating factor of First-Order Linear Differential Equation

Question states: $$y' + \frac{y}{x} = 6x+2$$ Obviously x cannot be zero. If we assume that $x$ is positive (i.e. $x>0$), we find the integrating factor as $$u(x)=e^{\int \frac{1}{x} dx}$$ which is equal to $x$. Then the solution is $$y(x)= \frac{1}{u(x)} \int (6x+2)(u(x)) dx = \frac {1}{x} \int 6x^2+2x \ dx = 2x^2+x+\frac{C}{x}.$$ Now, we assumed that $x$ is positive. But I couldn't get the same answer when I didn't make this assumption; that is, the integrating factor is $$u(x)=e^{\int \frac{1}{x} dx} = e^{ \ln \lvert x\rvert} = \lvert x\rvert.$$ Then this problem gets way more complicated, as the solution becomes $$y(x)= \frac{1}{u(x)} \int (6x+2)(u(x)) dx = \frac {1}{\lvert x\rvert} \int 6x \lvert x\rvert +2\lvert x\rvert \ dx.$$ My calculus textbook omitted the absolute value altogether; that is, the textbook indicated that the integrating factor was just $x$. Because the textbook is written by quite reputable and trustworthy authors (Ron Larson and Bruce Edwards), I was wondering (1) if treating the integrating factor as just $x$ is acceptable, and/or (2) How the solution is still correct if we must use the integrating factor as $\lvert x\rvert$. If we can omit the absolute value sometimes, how do we know when we can omit the absolute value sign and when we shouldn't? (As a side note, I fully understand why there's absolute value sign for the antidervative of $\frac{1}{x}$).

• Hint:$(\ln|x|)'=\frac{|x|'}{x}=\frac{\frac{|x|}{x}}{x}=\frac{1}{x}$ – Khosrotash Mar 13 '16 at 5:09
• Khosrotash, thanks for the hint, but I still don't get it. Could you just fully explain? I already know that $\int \frac {1}{x} dx = \ln \lvert x\rvert.$ – user304152 Mar 13 '16 at 5:15
• Oops, small mistake - $\int \frac {1}{x} \ dx = \ln \lvert x\rvert + C.$ But you get the idea of what I'm saying. – user304152 Mar 13 '16 at 6:25
• Thank you Prof. Blatter. But the question didn't specify $x>0$ and thus we cannot make that assumption. – user304152 Mar 13 '16 at 18:04
• I don't know what an "integrating factor" is. At any rate: Divide your problem into two subproblems, one concerning the domain $x>0$ and the other concerning the domain $x<0$. When $x<0$ a primitive of ${1\over x}$ is $\log(-x)$. – Christian Blatter Mar 14 '16 at 9:57

You see that in your last equation attain the same result for $x>0$ and $x<0$. So absolute sign is omitted.