Differential equation: $y'-\tan x \cdot y=e^{2x}$ I am having difficulty solving the differential equation $y'-\tan x \cdot y=e^{2x}$.

Here is my attempt


Any help is appreciated.
Trivial.

Multiple both sides $\cos(x)$:

$\cos(x)y'-\sin(x)y = e^{2x}\cos(x)$

Notice $d\cos(x)/dx=-\sin(x)$ so we have:

$y'\cos(x)+y\cos'(x)=e^{2x}\cos(x)$

But:

$\dfrac{d(f \cdot g)}{dx} = g \cdot \dfrac{df}{dx} + f \cdot \dfrac{dg}{dx}$  is the left side of our equation

$d(y\cos(x))/dx=e^{2x}\cos(x)$

Now we finally can integrate:

$y\cos(x) = C + 1/5*e^{2x}*(\sin(x)+2\cos(x))$

P.S. Integration by parts of $e^{2x}*cos(x) dx$ 

First time:

$U = e^{2x}$

$dU = 2e^{2x}dx$

$V = sin(x)$

$dV = cos(x)dx$

(1)  $\int e^{2x}*cos(x) dx = e^{2x}*sin(x)-2*\int e^{2x}*sin(x) dx = $ 

Second time:

$U = e^{2x}$

$dU = 2e^{2x}dx$

$V = cos(x)$

$dV = -sin(x)dx$

(1) $=e^{2x}*sin(x)+2(e^{2x}*cos(x)-2*\int e^{2x}*cos(x) dx)$

Finally:

$5*\int e^{2x}*cos(x) dx = e^{2x}(\sin(x)+2\cos(x))$

$\int e^{2x}*cos(x) dx = 1/5*e^{2x}*(\sin(x)+2\cos(x)) + C$
Trivial.

Multiple both sides $\cos(x)$:

$\cos(x)y'-\sin(x)y = e^{2x}\cos(x)$

Notice $d\cos(x)/dx=-\sin(x)$ so we have:

$y'\cos(x)+y\cos'(x)=e^{2x}\cos(x)$

But:

$\dfrac{d(f \cdot g)}{dx} = g \cdot \dfrac{df}{dx} + f \cdot \dfrac{dg}{dx}$  is the left side of our equation

$d(y\cos(x))/dx=e^{2x}\cos(x)$

Now we finally can integrate:

$y\cos(x) = C + 1/5*e^{2x}*(\sin(x)+2\cos(x))$

P.S. Integration by parts of $e^{2x}*cos(x) dx$ 

First time:

$U = e^{2x}$

$dU = 2e^{2x}dx$

$V = sin(x)$

$dV = cos(x)dx$

(1)  $\int e^{2x}*cos(x) dx = e^{2x}*sin(x)-2*\int e^{2x}*sin(x) dx = $ 

Second time:

$U = e^{2x}$

$dU = 2e^{2x}dx$

$V = cos(x)$

$dV = -sin(x)dx$

(1) $=e^{2x}*sin(x)+2(e^{2x}*cos(x)-2*\int e^{2x}*cos(x) dx)$

Finally:

$5*\int e^{2x}*cos(x) dx = e^{2x}(\sin(x)+2\cos(x))$

$\int e^{2x}*cos(x) dx = 1/5*e^{2x}*(\sin(x)+2\cos(x)) + C$