Evaluating $ \int {e^x \sin (k \pi x) } dx $ I'm trying to integrate $$ I = \int {e^x \sin (k \pi x)} dx. $$ I've used Matlab and Wolfram Alpha, which have both given me the result $$ I = \frac{e^x(\sin (k \pi x) - \cos (k \pi x))}{k^2 \pi^2 +1 }.$$
How did these programs get this result? 
 A: Consider $e^{ik\pi x} = \cos k\pi x + i \sin k\pi x$.
The integrand becomes $e^{(ik\pi + 1)x}$, then take the imaginary part after integrating.
We get:
$$
\int e^{(ik\pi + 1) x} dx=\frac{e^{(ik\pi+1)x}}{ik\pi + 1}+C = \frac{(1-ik\pi)e^{(ik\pi+1)x}}{1+k^2\pi^2}+C=\frac{(1-ik\pi)e^x (\cos k\pi x+ i \sin k\pi x)}{1+k^2\pi^2}+C
$$
Take the imaginary parts of both sides, should yield same result as integration by parts.
$$
\therefore \int e^x \sin k\pi x \,dx =\frac{e^x (\sin k\pi x - k\pi \cos k\pi x)}{1+k^2\pi^2}+C
$$
A: $$I = \int e^x \sin (k \pi x) dx\\=\sin k\pi x\int e^xdx-\int k\pi\cos k\pi x \left(\int e^xdx \right)dx\\=e^x\sin k\pi x-k\pi\int e^x\cos k \pi x\\=e^x\sin k\pi x-k\pi\left(\cos k\pi x\int e^x dx-\int k\pi \sin k\pi x\left(\int e^x dx\right)dx\right) \\
I=e^x(\sin k \pi x -k\pi\cos k\pi x)+k^2\pi^2 I+c$$
$$I=\frac{e^x(\sin k\pi x-k\pi\cos k\pi x)}{1+k^2\pi^2}+c$$

In general:
$$I_{a,b}=\int e^{ax}\sin bx dx=\frac{e^{ax}(a\sin bx-b\cos bx)}{a^2+b^2}+c$$
A: Hint: Use integration by parts twice.
