# Solving linear first order differential equation with hard integral

I'm try to solve this differential equation: $y'=x-1+xy-y$

After rearranging it I can see that is a linear differential equation: $$y' + (1-x)y = x-1$$

So the integrating factor is $l(x) = e^{\int(1-x) dx} = e^{(1-x)x}$

That leaves me with an integral that I can't solve... I tried to solve it in Wolfram but the result is nothing I ever done before in the classes so I'm wondering if I made some mistake...

This is the integral: $$ye^{(1-x)x} = \int (x-1)e^{(1-x)x} dx$$

-
add comment

## 1 Answer

The integrating factor is $e^{\int(1-x)dx}=e^{x-\frac{x^2}{2}}$

Thus: $$e^{x-\frac{x^2}{2}}y'+y(1-x)e^{x-\frac{x^2}{2}}=(x-1)e^{x-\frac{x^2}{2}}$$ $$\frac{d}{dx}[e^{x-\frac{x^2}{2}}y]=(x-1)e^{x-\frac{x^2}{2}}$$ Hence: $$e^{x-\frac{x^2}{2}}y=\int(x-1)e^{x-\frac{x^2}{2}}dx=C-e^{x-\frac{x^2}{2}}......$$

Another way to solve this is:

$$y'+(1-x)y=x-1$$ $$y'=(x-1)(y+1)$$ $$(y+1)'=(x-1)(y+1)$$ $$\frac{(y+1)'}{y+1}=(x-1)$$ $$\frac{d}{dx}[\log(y+1)]=(x-1)........$$

-
Thanks. Can't believe that mistake I made in the integrating factor! –  Tiago Costa Jan 21 '13 at 15:14
add comment