# Solving $\frac{dy}{dt} - y = 1 + \cos t$, using the integrating factor method

I'm having trouble trying to solve this differential equation: $\frac{dy}{dt} - y = 1 + \cos t$

So far, I've decided:

$\mu(t) = e^{-1\int dt} = e^{-t}$

$e^{-t}\frac{dy}{dt} - e^{-t}y = e^{-t} (1+\cos t)$

$e^{-t}\frac{dy}{dt} - e^{-t}y = e^{-t} + e^{-t}\cos t$

When I begin to integrate the right-hand side, I get:

$e^{-t}y = \int e^{-t}dt + \int e^{-t} \cos t\, dt$

$e^{-t}y = -e^{-t}dt + \int e^{-t} \cos t\, dt$

I'm having trouble integrating the $\int e^{-t} \cos t\, dt$ portion, which makes me think that I'm doing something wrong solving this equation. It seems like integrating it using integration by parts would just lead to an infinite loop of cosine & sine functions.

Am I approaching solving this differential equation incorrectly?

$$I = \int \mathrm{e}^{-t}\cos t dt = -\mathrm{e}^{-t}\cos(t) - \int \mathrm{e}^{-t}\sin t dt$$
Applying integration by parts again we find $$\int \mathrm{e}^{-t}\sin t dt = -\mathrm{e}^{-t}\sin t + \int \mathrm{e}^{-t}\cos t\mathrm{e}^{-t}\cos t$$ Putting it all together we find $$I = \int \mathrm{e}^{-t}\cos t dt = -\mathrm{e}^{-t}\cos(t) - \left[-\mathrm{e}^{-t}\sin t + \int \mathrm{e}^{-t}\cos t\mathrm{e}^{-t}\cos t\right] =-\mathrm{e}^{-t}\cos(t) +\mathrm{e}^{-t}\sin - \int \mathrm{e}^{-t}\cos t dt$$ but the right is just $$I = \int \mathrm{e}^{-t}\cos t dt = =-\mathrm{e}^{-t}\cos(t) +\mathrm{e}^{-t}\sin t - I$$ re-arrange to find $$2I = \mathrm{e}^{-t}(\sin t - \cos t)$$ or $$I = \frac{1}{2}\mathrm{e}^{-t}(\sin t - \cos t) = \int \mathrm{e}^{-t}\cos t dt$$
$\int e^{-t} cos t dt=\int e^{-t} \frac {1}{ 2} ( e^{it} + e^{-it})dt=\frac 1 2 \int e^{-t+it} + e^{-t-it})dt=\frac 1 2 \int e^{-t(1-i)}dt + \frac 1 2\int e^{-t(1+i)})dt$
You can also use derivative methods, because： $$(e^{-t}\cos t)'=-e^{-t}\cos t-e^{-t}\sin t$$ and $$(e^{-t}\sin t)'=-e^{-t}\sin t+e^{-t}\cos t$$ thus: $$e^{-t}\cos t=-\int e^{-t}\cos tdt-\int e^{-t}\sin tdt\qquad(1)$$ $$e^{-t}\sin t=-\int e^{-t}\sin tdt+\int e^{-t}\cos tdt\qquad(2)$$ (2)-(1),we'll get it： $$\int e^{-t}\cos tdt=\frac{1}{2}e^{-t}(\sin t-\cos t)$$
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}