Integrating factor with $-\ln x$

integrationordinary differential equations

I know that

$$\int \frac{1}{x}dx = \ln |x| + C$$

however I have seen differential equation notes and solutions claim that the integrating factor for $P(x)=-\frac{1}{x}$ is

$$\mu(x)=e^{\int P(x)dx}=e^{-\int\frac{1}{x}dx}=e^{-\ln|x|}=\frac{1}{x}$$

For example consider the IVP

$$\frac{dy}{dx}-\frac{y}{x}=xe^x, ~~~y(1)=e^{-1}$$

We have that $P(x)=-\frac{1}{x}$ so we could find the integrating factor exactly as above

$$\mu(x)=e^{\int P(x)dx}=e^{-\int\frac{1}{x}dx}=e^{-\ln|x|}=\frac{1}{x}\tag{1a}$$

then our equation would become

$$\frac{1}{x}\frac{dy}{dx}-\frac{y}{x^2}=e^x \implies \frac{d}{dx}\Big(\frac{1}{x}y\Big)=e^x$$

which after integrating produces

$$\frac{y}{x}=e^x+C$$

Applying the initial condition of $y(1)=e^{-1}$ forms $C=-1$. Then

$$\frac{y}{x}=e^x+1$$

or

$$y=xe^x+x\tag{1b}$$

If instead we found the integrating factor as

$$\mu(x)=e^{\int P(x)dx}=e^{-\int\frac{1}{x}dx}=e^{-\ln|x|}=\frac{1}{|x|}\tag{2a}$$

then we would carry through the $|x|$ throughout the computation. We have

$$\frac{1}{|x|}\frac{dy}{dx}-\frac{y}{x|x|}=e^x \implies \frac{d}{dx}\Big(\frac{1}{|x|}y\Big)=e^x$$

which after integrating forms

$$\frac{y}{|x|}=e^x+C$$

Applying the initial condition of $y(1)=e^{-1}$ once again forms $C=-1$. Then

$$\frac{y}{|x|}=e^x+1$$

or

$$y=|x|e^x+|x|\tag{2b}$$

I have seen different people claim that both solutions are correct. I'm not sure if we can drop the absolute value sign at some point in the computation.

Best Answer

The differential equation breaks down at $x=0$, so what happens for negative $x$ is something we cannot tell from the given information. We only care about positive $x$ because we can only care about positive $x$, and therefore the absolute value signs do nothing.

Even for the simpler differential equation $y'=\frac yx$, we get general solution $$ y(x)=\cases{ax& for $x>0$\\bx& for $x<0$} $$ In fact, the true antiderivative of $\frac1x$ is $$ \cases{\ln x+c_1& for $x>0$\\\ln(-x)+c_2 & for $x<0$} $$ and you don't have any information to help you pin down $c_2$ (or really $c_2-c_1$) for your integrating factor, which is another manifestation of our inability to tell what happens for negative $x$.

Of course, assuming something like $y$ being differentiable at $x=0$ (if that's even something that can happen; that's not the case with all differential equations) will be enough to stitch together the negative and positive branches.

Related Question