TITLE: Proving integral is zero
QUESTION [5 upvotes]: I want to prove that for $m,n\in \mathbb{N}$, $m\neq n$ following holds $(\cos (nx),\cos (mx))=0$ in $L_2(-\pi,\pi)$. Which means
$$\int_{-\pi}^\pi\cos(nx)\cos(mx)dx=0.$$
Is there a clever way to do this?

REPLY [5 votes]: If you are in an exam and you simply can't remember the trigonometric formula used by @MichaelBiro, and you also are afraid of @clark's complex exponentials, then integrating by parts twice will save you (assuming $n \ne 0$):
$$\int \limits _{-\pi} ^\pi \underbrace {\cos mx} _u \underbrace {\cos nx} _{v'} \ \Bbb d x = \cos mx \frac {\sin nx} n \Bigg| _{-\pi} ^\pi - \int \limits _{-\pi} ^\pi (-m \sin mx) \frac {\sin nx} n \Bbb d x =\\
\frac m n \int \limits _{-\pi} ^\pi \underbrace{\sin mx} _u \underbrace{\sin nx} _{v'} \Bbb d x = \frac m n \left( \sin mx \frac {-\cos nx} n \Bigg| _{-\pi} ^\pi - \int \limits _{-\pi} ^\pi m \cos mx \frac {-\cos nx} n \ \Bbb d x \right) =\\
\frac {m^2} {n^2} \int \limits _{-\pi} ^\pi \cos mx \cos nx \ \Bbb d x$$
whence it follows that
$$\left( \frac {m^2} {n^2} - 1 \right) \int \limits _{-\pi} ^\pi \cos mx \cos nx \ \Bbb d x = 0$$
whence (remembering that $m \ne n$)
$$\int \limits _{-\pi} ^\pi \cos mx \cos nx \ \Bbb d x = 0 .$$
If $n = 0$ then $m \ne 0$, so just exchange $u$ and $v$.