# What is a general solution to the differential equation dy/dx=(xy+2)/(x+1)?

Jul 6, 2016

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

#### Explanation:

you can't separate this so we will use an Integrating Factor

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

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

the integrating factor I(x) is

$I \left(x\right) = \exp \left(\int \mathrm{dx} q \quad - \frac{x}{x + 1}\right)$

$= \exp \left(- \int \mathrm{dx} q \quad \frac{x + 1 - 1}{x + 1}\right)$

$= \exp \left(- \int \mathrm{dx} q \quad 1 - \frac{1}{x + 1}\right)$

$= \exp \left(- \left(x - \ln \left(x + 1\right)\right)\right)$

$= \exp \left(\ln \left(x + 1\right) - x\right)$

$= {e}^{\ln \left(x + 1\right)} {e}^{- x} = \left(x + 1\right) {e}^{- x}$

so multiplying both sides by $I \left(x\right)$

$\left(x + 1\right) {e}^{- x} \cdot \frac{\mathrm{dy}}{\mathrm{dx}} - \left(x + 1\right) {e}^{- x} \cdot \frac{x}{x + 1} y = \frac{2}{x + 1} \cdot \left(x + 1\right) {e}^{- x}$

$\implies \textcolor{red}{\left(x + 1\right) {e}^{- x}} \cdot \textcolor{b l u e}{\frac{\mathrm{dy}}{\mathrm{dx}}} - \textcolor{red}{x {e}^{- x}} \textcolor{b l u e}{y} = 2 {e}^{- x}$

$\implies {\left(\left(x + 1\right) {e}^{- x} y\right)}^{p} r i m e = 2 {e}^{- x}$

So
$\left(x + 1\right) {e}^{- x} y = 2 \int \mathrm{dx} q \quad {e}^{- x}$

$\left(x + 1\right) {e}^{- x} y = - 2 {e}^{- x} + C$

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