Evaluating $\int^\pi_{-\pi} \cos^3(x) \cos(ax)~dx$

I need to evaluate $I = \int^\pi_{-\pi} \cos^3(x) \cos(ax)~dx$ where $a$ is some integer.

I get:
$\dfrac{2a(a^2-7)\sin(\pi a)}{a^4 – 10a^2 + 9}$. However $\sin(\pi a)$ is $0$ for all $a$ so $I=0$. But as noted by an answer, there are answers for $a = 1,3,-1,-3$.

Solutions Collecting From Web of "Evaluating $\int^\pi_{-\pi} \cos^3(x) \cos(ax)~dx$"

It tells you everything. After you factorize, it tells you either

$$I=0$$

or

$$1+\frac{9}{a^3}-\frac{3}{a^2}-\frac{7}{a}=0$$

Which is true for $a=1$. For this case, you can perform the integration by hand.

$a=3$ is also nonzero, but your expression seems not to show that. Check your equations again.

HINT:

We can use $$\cos3x=4\cos^3x-3\cos x\implies \cos^3x=\frac{\cos3x+3\cos x}4$$

Then use Werner Formulas

Also, observe that $ax+x, ax-x$ have same parity like $3x+ax,3x-ax$

$$
I=\int_{-\pi}^\pi \cos^3 x \cos(ax) dx=\frac{2a(7-a^2)\sin(a\pi)}{a^4-10a^2+9}
$$
It doesn’t matter that $\sin(a\pi)$ will give zero for all a, since the denominator also gives zero for some values of a! For ex: a=1, the denominator is also zero. Thus the 0/0 works in your favor and you get a result when you take the limit as $a \to 1$.

We can show this by
$$
I=\int_{-\pi}^\pi \cos^3 x \cos(ax) dx=\Re \bigg(\int_{-\pi}^\pi e^{iax} \cos^3x dx\bigg)=\Re \bigg(\int_{-\pi}^\pi e^{iax}(1-\sin^2 x)\cos xdx\bigg)
$$
where I used $\cos x= \Re(e^{ix})$ and the identity $\cos^2 x=1-\sin^2 x$.
We obtain
$$
I=\Re\bigg(\int_{-\pi}^\pi e^{iax}\cos x dx-\int_{-\pi}^\pi e^{iax}\sin^2 x \cos x dx\bigg).
$$
These integrals are tedious but can be done using partial integration(first one) and the second one by writing everything as exponentials, we obtain
$$
I=\Re\bigg(\frac{2a\sin(a\pi)}{1-a^2}-\frac{1}{8}\int_{-\pi}^\pi e^{iax}\left(e^{ix}+e^{-ix}-e^{-3ix}-e^{3ix} \right)dx\bigg)=\Re\bigg(\frac{2a\sin(a\pi)}{1-a^2}-\frac{4 a \sin(a\pi)}{a^4-10a^2+9}\bigg)=\frac{2a(7-a^2)\sin(a\pi)}{a^4-10a^2+9}.$$ Thus we have shown that
$$
{\boxed{I=\frac{2a(7-a^2)\sin(a\pi)}{a^4-10a^2+9}}}
$$