Calculating definite integral two ways different results Let's assume $k\in Z $ and we know that $\int_{0}^{\pi}{e^{ax}\cos{kx}\;dx} = \frac{((-1)^ke^{a\pi} - 1)a}{a^2 + k^2}$ (that is true, integration by parts solves it)
Let's try to calculate $\int_{0}^{pi}e^{ax}\sin{kx}\;dx$
Approach 1:
$f = \sin{kx}, dg = e^{ax}dx, g = \frac{1}{a}e^{ax}dx$, so integrating by parts we get
$k\frac{e^{ax}\sin{kx}}{a} - \frac{k}{a}\int_{0}^{\pi}e^{ax}\cos{kx}\;dx$, knowing that k is integer we have that first ratio is zero and our result can be calculated substituting result we know for integral we got. As a result, $\int_{0}^{pi}e^{ax}\sin{kx}\;dx = \frac{((-1)^ke^{a\pi} - 1)k}{a^2 + k^2}$
Approach 2:
$f = e^{ax}, dg = \sin{kx}\;dx, g = -\frac{1}{k}\cos{kx}$ so integrating by parts we get
$-\frac{e^{ax}\cos{kx}}{k} + \frac{a}{k}\int_{0}^{\pi}e^{ax}\cos{kx}\;dx$, ratio is zero, since at pi cosine is -1 and at 0 it is 1, and as a result we get
$\int_{0}^{pi}e^{ax}\sin{kx}\;dx = \frac{((-1)^ke^{a\pi} - 1)a^2}{k(a^2 + k^2)}$
First answer is correct but I can not find a place where I start lying in the second approach.
 A: Concerning the second approach, after doing the first computations you got$$-\frac{e^{ax}\cos{kx}}k+\frac ak\int_0^\pi e^{ax}\cos{kx}\,\mathrm dx$$but you should have got\begin{align}\left[-\frac{e^{ax}\cos{kx}}k\right]_{x=0}^{x=\pi}+\frac ak\int_0^\pi e^{ax}\cos{kx}\,\mathrm dx&=\frac{e^{\pi a}(-1)^{k+1}+1}k+\frac ak\int_0^\pi e^{ax}\cos{kx}\,\mathrm dx\\&=\frac{e^{\pi a}(-1)^{k+1}+1}k+\frac{a^2\left(e^{\pi a}(-1)^k-1\right)}{k(a^2+k^2)}\\&=-\frac{k \left(e^{\pi  a} (-1)^k-1\right)}{a^2+k^2}\end{align}
A: Check your substitutions in your second approach. $\cos(k\pi) = (-1)^k, k \in \Bbb Z$
$\begin{align}-\left[\frac{e^{ax}\cos(kx)}{k}\right]_0^\pi + \frac{a}{k}\cdot\frac{a((-1)^ke^{a\pi}-1)}{a^2+k^2} &= -\frac{e^{a\pi}(-1)^k}{k}+\frac{1}{k}+\frac{a^2((-1)^ke^{a\pi}-1)}{k(a^2+k^2)}\\&=\frac{(-1)^ke^{a\pi}(-a^2-k^2+a^2) +(a^2+k^2-a^2)}{k(a^2+k^2)}\\&=\frac{k(1-(-1)^ke^{a\pi})}{a^2+k^2}\end{align}$

Also in your first approach you're missing a $-$ sign in the result, or reverse the terms in the numerator.
A: Your mistake:" ratio is zero, since at pi cosine is -1 and at 0 it is 1, " -1-1=-2 not zero
