<s>[INST] Trouble integrating $e^{ax}\cos bx$ and $e^{ax}\sin bx$ I have to integrate the following indefinite integrals $$\int e^{ax}\sin bxdx~~;~\int e^{ax}\cos bx$$ The procedure I used is the same for both integrals: 


*

*Make the change of variables $bx=t$

*Use partial integration twice with $dv=e^{at/b}dt$ until the initial integral reappears and then solve. 
This is the full procedure for the first integral. For the 2nd integral the result I obtain is the same except for the signs.  $$\int e^{ax}\sin bxdx$$ Change of variables $bx=t$ $$\frac{1}{b}\int e^{at/b}\sin tdt$$ Partial integration $$dv=e^{at/b}dt~;~v=\frac{b}{a}e^{at/b}~;~u=\sin t~;~du=\cos tdt$$ Which leads to $$\frac{1}{a}e^{at/b}\sin t-\frac{1}{a}\int e^{at/b}\cos tdt$$ Partial integration again $$dv=e^{at/b}~;~v=\frac{b}{a}e^{at/b}~;~u=\cos t~;~du=-\sin tdt$$ Which leads to $$\frac{1}{b}I=\frac{1}{a}e^{at/b}\sin t-\frac{b}{a^2}e^{at/b}\cos t-\frac{b}{a^2}\int e^{at/b}\sin tdt$$ $$\frac{a^2+b^2}{ba^2}I=\frac{1}{a}e^{at/b}\sin t-\frac{b}{a^2}e^{at/b}\cos t$$ $$(a^2+b^2)I=bae^{at/b}\sin t-b^2e^{at/b}\cos t$$ $$I=\frac{ba}{a^2+b^2}e^{at/b}\sin t-\frac{b^2}{a^2+b^2}e^{at/b}\cos t$$ $$I=\frac{ba}{a^2+b^2}e^{ax}\sin bx-\frac{b^2}{a^2+b^2}e^{ax}\cos bx+C$$
The correct result is the one I obtained but divided by $b$ and for the love of God I can't figure out where I made the mistake.
 [/INST] Let, $I=\displaystyle\int{e^{ax}\sin{bx}}\ dx$
now by applying by parts rule
\begin{align*}
I&= e^{ax}\int \sin{bx}\ dx-\int\left[\frac{d}{dx}(e^{ax})\cdot\int\sin{bx}\ dx\right]\ dx\\
&= e^{ax}\left(-\frac{\cos{bx}}{b}\right)-\int{ae^{ax}}\cdot\left(-\frac{\cos{bx}}{b}\right)\ dx\\
&=-\frac{e^{ax}\cos{bx}}{b}+\frac{a}{b}\int{e^{ax}\cos{bx}}\ dx\\
&=-\frac{e^{ax}\cos{bx}}{b}+\frac{a}{b}\left[e^{ax}\int\cos{bx}\ dx-\int\left\{\frac{d}{dx}(e^{ax})\cdot\int\cos{bx}\ dx\right\}dx\right]+k_1\\
&=-\frac{e^{ax}\cos{bx}}{b}+\frac{a}{b}e^{ax}\cdot\frac{\sin{bx}}{b}-\frac{a}{b}\int ae^{ax}\cdot\frac{\sin{bx}}{b}\ dx+k_1\\
or,\ I&=-\frac{e^{ax}\cos{bx}}{b}+\frac{a}{b^2}e^{ax}\sin{bx}-\frac{a^2}{b^2}I+k_1\\
or,\ I+\frac{a^2}{b^2}I&=\frac{e^{ax}}{b^2}\left(a\sin{bx}-b\cos{bx}\right)+k_1\\
or,\ I&=\frac{e^{ax}}{a^2+b^2}\left(a\sin{bx}-b\cos{bx}\right)+k
\end{align*}
</s>