# Did I do this First order linear differential equation right?

## y'-ytanx = 2xsinxcosx Ok so I was told I.F. = ${e}^{\int F \left(x\right)}$ and I got y=cosx(sinx-xcosx)+C Is this right? If not, please help me?

May 29, 2018

$y \left(x\right) = \setminus \frac{\setminus \tan \left(x\right)}{2} + \setminus \frac{1}{18} \setminus \sin \left(3 x\right) \setminus \sec \left(x\right) - \setminus \frac{2}{3} x \setminus {\cos}^{2} \left(x\right) + C \setminus \sec x$

#### Explanation:

The integrating factor for a linear first order equation

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

is given by ${e}^{\int P \left(x\right) \mathrm{dx}}$

For our case $P \left(x\right) = - \tan x$ and $Q \left(x\right) = 2 x \sin x \cos x$

Thus the integrating factor is

${e}^{\int \left(- \tan x\right) \mathrm{dx}} = {e}^{- \ln \sec x} = \cos x$

Thus, we multiply both sides of the equation by $\cos x$

This yields

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

The left hand side is

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

and this means that

$y \cos x = \int 2 x \sin s {\cos}^{2} x \mathrm{dx}$

The integral can be evaluated easily by integration by parts to yield

$y \cos x = \setminus \frac{\setminus \sin \left(x\right)}{2} + \setminus \frac{1}{18} \setminus \sin \left(3 x\right) - \setminus \frac{2}{3} x \setminus {\cos}^{3} \left(x\right) + C$

and thus the solution is

$y \left(x\right) = \setminus \frac{\setminus \tan \left(x\right)}{2} + \setminus \frac{1}{18} \setminus \sin \left(3 x\right) \setminus \sec \left(x\right) - \setminus \frac{2}{3} x \setminus {\cos}^{2} \left(x\right) + C \setminus \sec x$

May 29, 2018

$y = - \frac{2}{3} x {\cos}^{2} x + \frac{2}{3} \tan x - \frac{2}{9} {\sin}^{3} x \sec x + C \sec x$

#### Explanation:

We have:

$y ' - y \tan x = 2 x \sin x \cos x$

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 can put the equation in standard form:

$y ' - \left(\tan x\right) y = 2 x \sin x \cos x$

Then the integrating factor is given by;

$I = {e}^{\int P \left(x\right) \mathrm{dx}}$
 \ \ = exp(int \ -tanx) \ dx)
$\setminus \setminus = \exp \left(- \ln \sec x\right)$
$\setminus \setminus = \exp \left(\ln \cos x\right)$
$\setminus \setminus = \cos x$

And if we multiply the DE [A] by this Integrating Factor, $I$, we will have a perfect product differential (in fact the original equation);

$\therefore \cos x y ' - \cos x \left(\tan x\right) y = \cos x 2 x \sin x \cos x$ 

$\therefore \cos x y ' - \sin x y = 2 x \sin x {\cos}^{2} x$

$\therefore \frac{d}{\mathrm{dx}} \left(\cos x \setminus y\right) = 2 x \sin x {\cos}^{2} x$

This is now separable, so by "separating the variables" we get:

$\cos x \setminus y = \int \setminus 2 x \setminus \sin x \setminus {\cos}^{2} x \setminus \mathrm{dx}$

Now, consider the integral:

$I = \int \setminus 2 x \setminus \sin x \setminus {\cos}^{2} x \setminus \mathrm{dx}$

We can then apply Integration By Parts:

Let  { (u,=2x, => (du)/dx,=2), ((dv)/dx,=sinx \ cos^2x, => v,=-1/3cos^3x ) :}#

Then plugging into the IBP formula:

$\int \setminus \left(u\right) \left(\frac{\mathrm{dv}}{\mathrm{dx}}\right) \setminus \mathrm{dx} = \left(u\right) \left(v\right) - \int \setminus \left(v\right) \left(\frac{\mathrm{du}}{\mathrm{dx}}\right) \setminus \mathrm{dx}$

We have:

$\int \setminus \left(2 x\right) \left(\sin x \setminus {\cos}^{2} x\right) \setminus \mathrm{dx} = \left(2 x\right) \left(- \frac{1}{3} {\cos}^{3} x\right) - \int \setminus \left(- \frac{1}{3} {\cos}^{3} x\right) \left(2\right) \setminus \mathrm{dx}$

$\therefore I = - \frac{2}{3} x {\cos}^{3} x + \frac{2}{3} \setminus \int \setminus {\cos}^{3} x \setminus \mathrm{dx}$

So, next we must consider the integral:

${I}_{1} = \int \setminus {\cos}^{3} x \setminus \mathrm{dx}$
$\setminus \setminus \setminus = \int \setminus \cos x \setminus {\cos}^{2} x \setminus \mathrm{dx}$
$\setminus \setminus \setminus = \int \setminus \cos x \setminus \left(1 - {\sin}^{2} x\right) \setminus \mathrm{dx}$
$\setminus \setminus \setminus = \int \setminus \cos x \setminus \mathrm{dx} - \int \setminus \cos x \setminus {\sin}^{2} x \setminus \mathrm{dx}$
$\setminus \setminus \setminus = \sin x - \frac{1}{3} {\sin}^{3} x$

Combining these results, we have

$I = - \frac{2}{3} x {\cos}^{3} x + \frac{2}{3} \left\{\sin x - \frac{1}{3} {\sin}^{3} x\right\}$
$\setminus \setminus = - \frac{2}{3} x {\cos}^{3} x + \frac{2}{3} \sin x - \frac{2}{9} {\sin}^{3} x$

So that, returning to the DE, we have:

$\cos x \setminus y = - \frac{2}{3} x {\cos}^{3} x + \frac{2}{3} \sin x - \frac{2}{9} {\sin}^{3} x + C$

$\therefore y = \frac{1}{\cos} x \left\{- \frac{2}{3} x {\cos}^{3} x + \frac{2}{3} \sin x - \frac{2}{9} {\sin}^{3} x + C\right\}$

$\therefore y = - \frac{2}{3} x {\cos}^{2} x + \frac{2}{3} \tan x - \frac{2}{9} {\sin}^{3} x \sec x + C \sec x$