# 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!

• What does that "'s" mean? – dfeuer Jan 27 '14 at 17:26

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.

• Thanks for this. I tried integrating in parts twice and got I = I*(n^2/m^2). Did I something wrong? I mean, if say n>m then the equality is false but I feel like I made a mistake somewhere. – Mark Emacr Jan 27 '14 at 17:28
• @MarkEmacr: No, this is what I got too. This only implies that $I\not=0$ is possible only if $m=n$, i.e. $I=0$ if $m\not=n$, if we work with positive integers that is. Btw. you have a load of unaccepted questions with answers; please accept them if you are satisfied with the answers! – J.R. Jan 27 '14 at 17:29
• TooOldForMath, I really appreciate you taking the time to answer my many questions. I am of course satisfied with your answer I just have no idea how to accept it. – Mark Emacr Jan 27 '14 at 17:38
• @MarkEmacr: On the left side of every question there is a vote counter with arrows below and under it. You can click on the "up" arrow to vote up an answer that you find useful. The "down" arrow is for voting down. Under the down arrow you should also see a greyed out "hook sign". Click on that to accept an answer. – J.R. Jan 27 '14 at 17:41

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.

$\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$

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.

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.