TITLE: Calculate the $\int_0^{2\pi}\cos(mx)\cos(nx)dx$
QUESTION [5 upvotes]: I'm having trouble with this problem:
Consider the integral:
  $$\tag 1\int_0^{2\pi}\cos(mx)\cos(nx)dx$$ 
a. Write $\cos(mx)$ and $\cos(nx)$ in terms of complex exponentials and compute $\cos(mx)\cos(nx)$
b. Show that, for integer $L$: 
$$\int \exp(iLx)dx = \begin{cases} 2\pi, & \text{ if } L=0 \\ 0, & \text{otherwise}, \end{cases}$$
(where i is a complex number)  
c. Compute the integral in $(1)$ by using the above.

REPLY [5 votes]: Using complex exponentials, or more elementarily the cosine addition laws $\cos(A+B)=\cos A\cos B-\sin A\sin B$ and its twin $\cos(A-B)=\cos A\cos B+\sin A\sin B$, we find that
$$\cos(mx)\cos(nx)=\frac{1}{2}\left(\cos((m+n)x)+\cos((m-n)x)\right).$$
Integrate. Be careful about the case $m=n$.

REPLY [2 votes]: Hint:
$$\cos kx=\frac{e^{ikx}+e^{-ikx}}{2}\Longrightarrow \cos mx\cos nx=\frac{1}{4}\left(e^{i(m+n)x}+e^{-i(m+n)x}+e^{i(m-n)x}+e^{-i(m-n)x}\right)$$