# What is the general solution of the differential equation  dy/dx +y = y^2(cosx-sinx) ?

Feb 16, 2017

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

#### Explanation:

$y ' + y = {y}^{2} \left(\cos x - \sin x\right)$

$\frac{y '}{y} ^ 2 + \frac{1}{y} = \cos x - \sin x$

Let $v \left(x\right) = \frac{1}{y \left(x\right)}$, such that $v ' = - \frac{y '}{y} ^ 2$

$\implies - v ' + v = \cos x - \sin x$

$\implies v ' - v = - \cos x + \sin x$

From here, we grab the Integrating Factor, $\setminus \lambda \left(x\right)$:

$\lambda \left(x\right) = {e}^{- \int \mathrm{dx}} = {e}^{- x}$

$\implies {e}^{- x} \left(v ' - v\right) = {e}^{- x} \left(- \cos x + \sin x\right)$

$\implies v {e}^{- x} = \int \mathrm{dx} q \quad {e}^{- x} \left(- \cos x + \sin x\right)$

$q \quad = \int \mathrm{dx} q \quad \frac{d}{\mathrm{dx}} \left(- {e}^{- x} \sin x\right)$

$\implies v {e}^{- x} = - {e}^{- x} \sin x + C$

From there, we remember that: $v = \frac{1}{y}$.

Therefore:

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

Feb 16, 2017

The solution to the DE

$\frac{\mathrm{dy}}{\mathrm{dx}} + y = {y}^{2} \left(\cos x - \sin x\right)$

is:

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

#### Explanation:

We have:

$\frac{\mathrm{dy}}{\mathrm{dx}} + y = {y}^{2} \left(\cos x - \sin x\right) \setminus \setminus \setminus \setminus \setminus \ldots . . \left[1\right]$

This is a First Order Bernoulli differential equation of the form:

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

The technique to solve such an equation is to use a substitution to reduce the equation to a linear differential equation. We can do this by letting $v = {y}^{- 1}$

$v = {y}^{- 1} \iff y = \frac{1}{v}$

Differentiating we get:

$\setminus \setminus \setminus \setminus \setminus \frac{\mathrm{dv}}{\mathrm{dy}} = - \frac{1}{y} ^ 2$
$\setminus \setminus \setminus \setminus \setminus \frac{\mathrm{dy}}{\mathrm{dx}} = \frac{\mathrm{dy}}{\mathrm{dv}} \cdot \frac{\mathrm{dv}}{\mathrm{dx}} \setminus \setminus \setminus$ (chain rule)
$\therefore \frac{\mathrm{dy}}{\mathrm{dx}} = - {y}^{2} \setminus \frac{\mathrm{dv}}{\mathrm{dx}}$
$\therefore \frac{\mathrm{dy}}{\mathrm{dx}} = - \frac{1}{v} ^ 2 \setminus \frac{\mathrm{dv}}{\mathrm{dx}}$

Substituting into the DE [1] gives us:

$- \frac{1}{v} ^ 2 \setminus \frac{\mathrm{dv}}{\mathrm{dx}} + \frac{1}{v} = \frac{1}{v} ^ 2 \left(\cos x - \sin x\right)$
$\therefore - \frac{\mathrm{dv}}{\mathrm{dx}} + v = \cos x - \sin x$
$\therefore \frac{\mathrm{dv}}{\mathrm{dx}} - v = \sin x - \cos x \setminus \setminus \setminus \setminus \setminus \left[2\right]$

And so we have reduced our non-linear DE to a First Order Linear Differential equation of the form

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

We can sole this equation by using an Integrating Factor to convert the equation to a the perfect differential of a product as follows:

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

Multiply the DE [2] by the IF:

${e}^{- x} \frac{\mathrm{dv}}{\mathrm{dx}} - v {e}^{- x} = {e}^{- x} \left(\sin x - \cos x\right)$
$\frac{d}{\mathrm{dx}} \setminus \left(v {e}^{- x}\right) = {e}^{- x} \left(\sin x - \cos x\right)$

This is a simple separable DE so we can separate the variables to get:

$v {e}^{- x} = \int \setminus {e}^{- x} \left(\sin x - \cos x\right) \mathrm{dx}$

To save space I will just quote the result for the integral on the RHS, but this can easily be derived using Integration by Parts, so we get:

$v {e}^{- x} = - {e}^{- x} \sin x + C$

Restoring the earlier substitution the gives:

${y}^{- 1} {e}^{- x} = {e}^{- x} \sin x + C$
$\therefore \setminus {y}^{- 1} = - \sin x + C {e}^{x}$
$\therefore \setminus \setminus \setminus \setminus \frac{1}{y} = C {e}^{x} - \sin x$
$\therefore \setminus \setminus \setminus \setminus \setminus y = \frac{1}{C {e}^{x} - \sin x}$