Let me take an example that I've come across while studying Fourier series,
We all know that
$$\int_{-a}^{a} \sin \left( \frac{n\pi x}{a} \right) dx = 2 \int_{0}^{a} \sin \left(\frac{n \pi x}{a} \right) dx$$
So why is it that when evaluating both sides separately the results seem to differ?
I. $$\int_{-a}^{a} \sin \left( \frac{n\pi x}{a} \right) dx = -\frac{a}{n \pi} \cos \left( \frac{n\pi x}{a} \right)_{-a}^{a} = -\frac{a}{n \pi} \left[ \cos (n\pi) - \cos(-n \pi) \right] = 0$$
II. $$2 \int_{0}^{a} \sin \left(\frac{n \pi x}{a} \right) dx = -\frac{2a}{n \pi} \cos \left( \frac{n\pi x}{a} \right)_{0}^{a} = - \frac{2a}{n\pi} \left[ \cos(n \pi) - 1\right] = \begin{cases} 0, & \text{if } n\text{ is even} \\ \frac{4a}{n\pi}, & \text{if } n \text{is odd} \end{cases}$$
My question is, how can I also obtain $\frac{4a}{n\pi}$ from a direct integration from $-a$ to $a$ ? The expression $\left[ \cos (n\pi) - \cos(-n \pi) \right]$ seems to be always $0$, right? Regardless of $n$ being even or odd. Or am I missing something here?
The statement after "We all know that" is completely false. $\sin(cx)$ for any $c$ is an odd function, so any integral on an interval symmetric around $0$ will give 0. The correct result is:
$$\int_{-a}^a\sin(cx)dx=\int_{0}^a\sin(cx)dx+\int_{-a}^0\sin(cx)dx,$$
and now do a change of variables on the second integral $u=-x$ and use the fact that $\sin(-x)=-\sin(x)$.