How to evaluate $\int_0^\pi \cos(x) \cos(2x) \cos(3x) \cos(4x)\, dx$

Because I like it, I will add a tricky approach ($C$ denotes the unit circle):

$$ I=\frac{1}{2}\int_{-\pi}^{\pi}dx\prod_{n=1}^4\cos(nx)\underbrace{=}_{z=e^{ix}}\frac{1}{32i}\oint_C\frac{1}{z^{11}}\prod_{n=1}^4(z^{2n}+1). $$

Now, since $\oint_Cz^{n}=0$ for $n\in \mathbb{Z}$ and $n\neq-1$, only the terms of the product with total power of $10$ will contribute. There are exactly two of them $2+8=4+6=10$, so

$$ I=\frac{1}{32i}\oint_C\frac{2}{z}=\frac{\pi}8 $$

where the last equality results from the residue theorem.


Fiddling around with generalizations of this result and consulting OEIS I stumbled over this interesting set of slides: http://www.dorinandrica.ro/files/presentation-INTEGERS-2013.pdf So integrals of this kind have a deep connection to problems in number theory which is pretty awesome


HINT: We have the following identities

$\cos(A+ B) = \cos A \cos B - \sin A \sin B$ and

$\cos(A-B) = \cos A \cos B + \sin A \sin B$

$2\cos A \cos B = \cos(A+B) + \cos (A-B)$

$\cos A \cos B = \dfrac{\cos(A+B) + \cos(A-B)}{2}$

Take $\cos x$ and $\cos 4x$ together and $\cos 2x$ and $\cos 3x$ together.

Then $\cos(x) \cos(2x) \cos(3x) \cos(4x) =\\ \frac18[1 + \cos(10x) + \cos(8x)+ \cos(6x)+2\cos(4x)+2\cos(2x)+\cos(x) ]$.

Now you can do with your usual integration formula.


Using Werner's formula with $a\ge b>0$ so that $a\pm b$ are integers

$$\int_0^\pi\cos ax\cos bx\ dx=\dfrac12\int_0^\pi\{\cos(a+b)x+\cos(a-b)x\} dx=\cdots=\begin{cases}0&\mbox{if } a\ne b\\ \dfrac\pi2 & \mbox{if } a=b\end{cases}$$

Now, $(2\cos x\cos4x)(2\cos2x\cos3x)=(\cos3x+\cos5x)(\cos x+\cos5x)$

$=\cos3x\cos x+\cos x\cos5x+\cos3x\cos5x+\cos5x\cdot\cos5x$

So, $\displaystyle4\int_0^\pi\cos x\cos2x\cos3x\cos4x\ dx=\dfrac\pi2$ for $a=b=5$