1. ## Linear ODE question

The question:

Solve the following Linear ODE:
$x\frac{dy}{dx} + (1 + x)y = 2$

My attempt:
$x\frac{dy}{dx} + y + xy = 2$
= $x(\frac{dy}{dx} + y) + y = 2$
= $\frac{dy}{dx} + 2y = \frac{2}{x}$

Integrating factor is:
$e^{2x}$

So we get:
$e^{2x}y = 2\int{\frac{1}{x}e^{2x} \ dx}$

Now at this point, Wolfram is giving me a weird solution to that integral. Have I made an error so far? I tried going further, but nothing resembles the answer at all. Any help would be great!

2. $\displaystyle x\,\frac{dy}{dx} + (1+x)\,y = 2$

$\displaystyle \frac{dy}{dx} + \left(\frac{1+x}{x}\right)\,y = \frac{2}{x}$.

So the integrating factor is $\displaystyle e^{\int{\frac{1+x}{x}\,dx}} = e^{\int{\frac{1}{x} + 1\,dx}} = e^{\ln{x} + x} = e^{\ln{x}}e^x = x\,e^x$.

Multiplying through gives

$\displaystyle x\,e^x\,\frac{dy}{dx} + x\,e^{x}\left(\frac{1+x}{x}\right)\,y = \frac{2x\,e^{x}}{x}$

$\displaystyle x\,e^x\,\frac{dy}{dx} + e^x(1+x)\,y = 2e^x$

$\displaystyle \frac{d}{dx}(x\,e^x\,y) = 2e^x$

$\displaystyle x\,e^x\,y = \int{2e^x\,dx}$

$\displaystyle x\,e^x\,y = 2e^x + C$

$\displaystyle y = \frac{2e^x + C}{x\,e^x}$.

3. $\displaystyle y'+\frac{1+x}{x}y=2/x$

$\displaystyle P(x)=\frac{1+x}{x} \ \ e^{\int P(x)dx}=e^{\int\frac{1+x}{x}dx}=e^{\ln{x}+x}=xe^x$

$\displaystyle Q(x)=2/x$

$\displaystyle \int\frac{dy}{dx}\left[e^{P(x)dx}y\right]=\int P(x)Q(x)dx$

4. Whoops, silly algebra mistake.

Thanks!