What is $\int_{-\pi}^\pi \cos(nx)\cos(mx)\,dx$? I'm pretty sure that there's a theorem that says that the Fourier coefficients of a sum of $\cos(nx)$ and $\sin(nx)$ 's are the coefficients of the sum itself. 
I tried to prove that in the specific case of $f(x) = \sum_{n=1}^{\infty}\frac{\cos(nx)}{n^2}$. In calculating the Fourier coefficients I got to calculating  $\cos(nx)\cdot\cos(mx)$, but I'm now stuck. Any tips would be appreciated!
 A: Let $m,n\ge 1$. Use
$$\cos (m x) \cos (n x)=\frac{1}{2} (\cos (m x-n x)+\cos (m x+n x)).$$
Then if $m\not=n$ we get $0$, since $\int_{-\pi}^\pi \cos(kx)dx=\frac{2\sin(n\pi)}{n}=0$ for all $k\in\mathbb{Z}, k\not=0$. For $m=n$ we have
$$\int_{-\pi}^\pi \cos(nx)^2 dx = \frac{1}{2}\int_{-\pi}^\pi (1+\cos(2nx)) dx = \frac{1}{2} 2\pi+\underbrace{\frac{1}{2}\int_{-\pi}^\pi \cos(2nx) dx}_{=0}=\pi.$$
This is exactly what we expected.
A: Hint: $$\cos mx\cos nx=\frac{\cos((m-n)x)+\cos((m+n)x)}{2}.$$
Easily that gives integral $0$ except when $m=n$. The case $m=n$ has to be handled separately. 
A: $\displaystyle I_{m,n} = \int_{-\pi}^{\pi}\cos  (mx)\cdot \cos (nx)dx = 2\int_{0}^{\pi}\cos (mx)\cdot \cos (nx)dx$
$\displaystyle  = \int_{0}^{\pi}\cos \{(m+n)x\}dx+\int_{0}^{\pi}\cos \{(m-n)x\}dx $
$\displaystyle = \left[\frac{\sin \{(m+n)x\}}{(m+n)}\right]_{0}^{\pi}+\left[\frac{\sin \{(m-n)x\}}{(m-n)}\right]_{0}^{\pi} = 0$, If $m,n\in \mathbb{Z}$ and $m\neq n$ and $m\neq -n$
A: Hint: Write each of the cosines in terms of complex exponentials, then note that the result is a lot easier to integrate than a product of cosines. 
A: Saw a fascinating case in the book so copy it here.
Actually $\cos z=\frac{e^{iz}+e^{-iz}}{2}, \sin z=\frac{e^{iz}-e^{-iz}}{2i}$
Where $\int^\pi_{-\pi} e^{imx}e^{-inx} dx=
\begin{cases}
0,if m\neq n\\
2\pi , if m=n
\end{cases}
$,
Just substitute the $\sin x, and \cos x$ with complex identity into the integration, done.
