<s>[INST] Evaluate $\int_{-\pi}^\pi \! \cos(kx)\cos^n(x) \, \mathrm{d}x$ My question is:

Evaluate $$\int_{-\pi}^\pi \! \cos(kx)\cos^n(x) \, \mathrm{d}x$$ for $k=0,1,...,(n-1)$ and $n \in \mathbb{N}$.

I've tried integration by parts but without much success. Any help/trick for this integral? Thanks!
 [/INST] $$\begin{align} 2^n \cos^n x &= \left(e^{ix} + e^{-ix}\right)^n\\
&= e^{inx} + {n \choose 1}e^{i(n-2)x} + {n \choose 2}e^{i(n-4)x}+ \cdots+{n \choose 2}e^{-i(n-4)x}+{n \choose 1}e^{-i(n-2)x} +  e^{-inx}\\
&=2\cos nx+ 2{n \choose 1}\cos(n-2)x+2{n \choose 2}\cos(n - 4)x + \cdots  
 \end{align}$$
multiplying by $\cos kx,$ we have 
$$\begin{align}2^n \cos^n x\cos kx &= 2\cos nx\cos kx+ 2{n \choose 1}\cos(n-2)x\cos kx+{n \choose 2}\cos(n - 4)x\cos kx + \cdots \\
&=\cos(n+k)x +\cos(n-k)x+{n\choose 1}\left(\cos(n-2+k)x -\cos(n-2-k)x\right)\\ &+{n\choose 2}\left(\cos(n-4+k)x -\cos(n-4-k)x\right) +\cdots
\end{align}$$
only contribution to $\int_{-\pi}^{\pi} 2^n \cos^n x\cos kx\, dx$  are $2\pi{n \choose j}$ with $j = \frac{n+k}2$ and $-2\pi{n\choose j}$ with $j = \frac{n-k}2$ therefore $$\int_{-\pi}^{\pi} 2^n \cos^n x\cos kx\, dx = 2\pi\left({n\choose {\frac{n+k}2}} - {n\choose {\frac{n-k}2}}\right)$$
</s>