# What is the general solution of the differential equation ? xdy/dx=2/x+2-y given that x=-1,y=0

Nov 9, 2017

$y = \frac{\ln | x | + x + 1}{x}$

#### Explanation:

We have:

$x \frac{\mathrm{dy}}{\mathrm{dx}} = \frac{2}{x} + 2 - y$ ..... [A]

We can rearrange [A] as follows:

$\frac{\mathrm{dy}}{\mathrm{dx}} = \frac{2}{x} ^ 2 + \frac{2}{x} - \frac{y}{x}$

$\frac{\mathrm{dy}}{\mathrm{dx}} + \frac{y}{x} = \frac{2}{x} ^ 2 + \frac{2}{x}$ ..... [B]

We can use an integrating factor when we have a First Order Linear non-homogeneous Ordinary Differential Equation of the form;

$\frac{\mathrm{dy}}{\mathrm{dx}} + P \left(x\right) y = Q \left(x\right)$

So we form an Integrating Factor;

$I = {e}^{\int P \left(x\right) \mathrm{dx}}$
$\setminus \setminus = \exp \left(\int \setminus \frac{1}{x} \setminus \mathrm{dx}\right)$
$\setminus \setminus = \exp \left(\ln x\right)$
$\setminus \setminus = x$

And if we multiply the DE [B] by this Integrating Factor, $I$, we will have a perfect product differential;

$\setminus \setminus x \setminus \frac{\mathrm{dy}}{\mathrm{dx}} + y = \frac{2}{x} + 2 x$

$\therefore \frac{d}{\mathrm{dx}} \left(x y\right) = \frac{2}{x} + 2$

Which we can directly integrate to get:

$x y = \int \setminus \frac{2}{x} + 2 x \setminus \mathrm{dx}$
$\setminus \setminus \setminus \setminus = 2 \ln | x | + 2 x + C$

Using the initial Condition, $x = - 1 , y = 0$ we have:

$0 = 2 \ln | 1 | - 2 + C \implies C = 2$

$x y = 2 \ln | x | + 2 x + 2$
$\implies y = \frac{\ln | x | + x + 1}{x}$