text: Q:
  
  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.
  
  A:
  
  I prefer to write this using Euler's formula (exponentials are so much easier)
  \begin{align}
  \int e^{x(a+ i b)} \, dx & = \frac{1}{a + i b} e^{x(a + ib)} \\
  & = \frac{a - ib}{a^2+b^2} e^{x(a+ib)}.
  \end{align}
  Then you can just read off $$\int e^{ax} \cos(bx) = \frac{e^{ax}}{a^2+b^2}[a \cos(bx) + b \sin(bx)]$$ and $$\int e^{ax} \sin(bx) = \frac{e^{ax}}{a^2+b^2}[a \sin(bx) - b \cos(bx)]$$
  
  