Integrating Trig Functions How you I solve the following integral?
$\int_{-\pi}^\pi \cos(5x)\cos(nx)dx$
I know I need to use the ${1\over 2}(\cos(u-v)+\cos(u+v))$ but I keep getting zero.
 A: Firstly, $\cos(nx)\cos(5x)=\frac{1}{2}(\cos((n-5)x)+\cos((n+5)x))$.
If $n\neq\pm5$, we split the integral up as follows:
\begin{align*}
\int_{-\pi}^{\pi} \cos(nx)\cos(5x)dx&=\frac{1}{2}\left(\int_{-\pi}^{\pi}\cos((n-5)x)dx+\int_{-\pi}^{\pi}\cos((n+5)x)\right) \\
&= \frac{1}{2}\left[\frac{1}{n-5}\sin((n-5)x)+\frac{1}{n+5}\sin((n+5)x)\right]_{-\pi}^{\pi} \\
&= \frac{1}{2}\left(\left(\frac{1}{n-5}\sin((n-5)\pi)+\frac{1}{n+5}\sin((n+5)\pi)\right)-\left(\frac{1}{n-5}\sin(-(n-5)\pi)+\frac{1}{n+5}\sin(-(n+5)\pi)\right)\right) \\
&= \frac{1}{n-5}\sin((n-5)\pi)+\frac{1}{n+5}\sin((n+5)\pi)\:.
\end{align*}
Now if we are assuming that $n$ is an integer, then because $\sin$ is zero for integer multiples of $\pi$, this integral becomes 0.
If instead $n$ were equal to $\pm5$, using the evenness of the cosine function, we see:
\begin{align*}
\int_{-\pi}^{\pi} \cos(\pm5x)\cos(5x)dx &= \int_{-\pi}^{\pi} \cos^2(5x)dx \\
&= \frac{1}{2}\int_{-\pi}^{\pi}(\cos(10x)+1)dx \\
&= \frac{1}{2}\left[\frac{1}{10}\sin(10x)+x\right]_{-\pi}^{\pi} \\
&= \frac{1}{2}\left(\left(\frac{1}{10}\sin(10\pi)+\pi\right)-\left(\frac{1}{10}\sin(-10\pi)-\pi\right)\right) \\
&= \pi\:.
\end{align*}
A: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
\begin{align}
&\color{#66f}{\large\int_{-\pi}^{\pi}\cos\pars{5x}\cos\pars{nx}\,\dd x}
=\int_{-\pi}^{\pi}\cos\pars{5x}\cos\pars{\verts{n}x}\,\dd x
=\Re\int_{-\pi}^{\pi}\cos\pars{5x}\expo{\verts{n}x\ic}\,\dd x
\\[3mm]&=\Re
\oint_{\verts{z}\ =\ 1\atop{\vphantom{\Huge A}\verts{{\rm Arg}\pars{z}}\ <\ \pi}}
{z^{5} + 1/z^{5} \over 2}\,z^{\verts{n}}\,\,{\dd z \over \ic z}
=\half\,\Im
\oint_{\verts{z}\ =\ 1 \atop{\vphantom{\Huge A}\verts{{\rm Arg}\pars{z}}\ <\ \pi}}
{z^{10} + 1 \over z^{6 - \verts{n}}}\,\,\dd z
\\[3mm]&=\half\,\Im
\oint_{\verts{z}\ =\ 1 \atop{\vphantom{\Huge A}\verts{{\rm Arg}\pars{z}}\ <\ \pi}}
\pars{{1 \over z^{-4 - n}} + {1 \over z^{6 - n}}}\,\,\dd z
=\half\,\Im\pars{2\pi\ic\,\delta_{-4 - \verts{n},1}
+ 2\pi\ic\,\delta_{6 - \verts{n},1}}
\\[3mm]&=\color{#66f}{\large\pi\,\delta_{\verts{n}\,,\,5}
=\color{#c00000}{\left\{\begin{array}{lcl}
\pi & \mbox{if} & n = \pm 5
\\[1mm]
0 && \mbox{otherwise}
\end{array}\right.}}
\end{align}
