Derive the formula \[\bbox[5px, border:1px solid black, #F9F7ED]{ \int e^{ax}\cos (bx) \,dx=\dfrac{e^{ax}[b\sin (bx) +a\cos (bx)] }{a^{2}+b^{2}}+C\qquad b ≠ 0} \tag{1} \]
Then \[ \begin{equation*} du=ae^{ax}\,dx\qquad \hbox{and}\qquad v=\int \cos (bx) \,dx=\frac{1}{b}\sin (bx) \end{equation*} \]
and \[ \begin{equation*} \int e^{ax}\cos (bx) \,dx=e^{ax}\,\dfrac{\sin (bx) }{b}-\frac{a}{b}\int e^{ax}\sin (bx) \,dx \tag{2} \end{equation*} \]
The new integral on the right, \(\int e^{ax}\sin (bx) \,dx,\) is different from the original integral, but it is essentially of the same form. We use integration by parts again with this integral by choosing \[ \begin{equation*} u=e^{ax}\qquad \hbox{and}\qquad dv=\sin (bx) \,dx \end{equation*} \]
Then \[ \begin{equation*} du=ae^{ax}\,dx\qquad \hbox{and}\qquad v=\int \sin (bx) \,dx=- \frac{1}{b}\cos (bx) \end{equation*} \]
and \[ \begin{equation*} \int e^{ax}\sin (bx) \,dx=-\frac{1}{b}\,e^{ax}\cos (bx) +\frac{a}{b}\int e^{ax}\cos (bx) \,dx\tag{3} \end{equation*} \]
Substituting the result from (3) into (2), we obtain \[ \begin{eqnarray*} \int e^{ax}\cos (bx) \,dx& =& \frac{1}{b}e^{ax}\sin (bx) -\frac{a}{b}\left[ -\frac{1}{b}e^{ax}\cos (bx) + \frac{a}{b}\int e^{ax}\cos (bx) \,dx\right] \\[8pt] \int e^{ax}\cos (bx) \,dx& =&\frac{1}{b}\,e^{ax}\sin (bx) +\frac{a}{b^{2}}\,e^{ax}\cos (bx) -\frac{a^{2}}{b^{2}}\int e^{ax}\cos (bx) \,dx \end{eqnarray*} \]
Now we solve for \(\int e^{ax}\cos (bx) \,dx\) and simplify. \[ \begin{eqnarray*} \int e^{ax}\cos (bx) \,dx+\frac{a^{2}}{b^{2}}\int e^{ax}\cos (bx) \,dx& =&\frac{1}{b}\,e^{ax}\sin (bx) +\frac{a}{ b^{2}}\,e^{ax}\cos (bx) \nonumber \\[5pt] \left( 1+\frac{a^{2}}{b^{2}}\right) \int e^{ax}\cos (bx) \,dx &=&\frac{1}{b^{2}}\,e^{ax} [b\sin (bx) +a\cos (bx) ] \\ \int e^{ax}\cos (bx) \,dx &=&\frac{e^{ax}[b\sin (bx)+a\cos (bx)]}{a^{2}+b^{2}}+C \end{eqnarray*} \]