Linked to my previous question, when solving the following integral ($a$ is an integer) I get:
$$\int^\pi_{-\pi} \cos^3(x) \cos(ax)~dx = \frac{2a(a^2-7)\sin(\pi a)}{a^4 - 10a^2 + 9}$$
However, trivially, $\sin(\pi a) = 0$ for all integer values of $a$. Therefore the integral is always equal to $0$. Wolfram Alpha agrees with this solution.
However, let us substitute $a=1$ and $a=3$ into the integral and then solve:
$$\int^\pi_{-\pi} \cos^3(x) \cos(x)~dx = \frac{3\pi}{4}$$ and $$\int^\pi_{-\pi} \cos^3(x) \cos(3x)~dx = \frac{\pi}{4}$$
Why do these answers disagree?