Integration: Integrating then substituting a number has a different answer to substituting a number then integrating; for trigonometric functions This might be a very dumb question but I am really stuck as to why this happens. Now, the answer to the integral
$$B_n = 2 \int_0^1 k\sin(3\pi x)\sin(n\pi x) dx \qquad (k = 0.01,  
 n=1,2,3,...)$$
is $k$ when $n=3$ and $0$ when $n\neq3 $.
But when I try to solve for a general solution I get
$$
\begin{align}
B_n &= 2k\int_0^1 \frac12[\cos(3\pi x-n\pi x)-\cos(3\pi x+n\pi x)]dx
\\ &= k\int_0^1 \cos(3\pi x-n\pi x)-cos(3\pi x+n\pi x)dx
\\ &= k[\frac{1}{3\pi - n\pi}\sin(3\pi x - n\pi x) - \frac{1}{3\pi+ n\pi}\sin(3\pi x+ n\pi x)]_0^1 
\\ &= k(\frac{1}{3\pi - n\pi}\sin(3\pi - n\pi) - \frac{1}{3\pi+ n\pi}\sin(3\pi+ n\pi)
)\end{align}
$$
which gives $0$ for all integer $n$. 
Why is that?

Note that  $\dfrac{1}{3\pi - n\pi}$ is not defined at $n=3$. So you need to solve the integral for $n=3$ separately. 
When  $n=3$, we have 
$$k\int_0^1 \cos(3\pi x-n\pi x)-\cos(3\pi x+n\pi x)dx=k\int_0^1 \cos(0)-cos(6\pi x)dx=k\int_0^1 1-\cos(6\pi x)dx.$$
Can you complete this?
