TITLE: Proof of $\int_{0}^{\pi}\cos^n(x)\cos(nx)dx=\frac{\pi}{2^n}$
QUESTION [6 upvotes]: I am trying to prove the following:
$$\int_{0}^{\pi}\cos^n(x)\cos(nx)dx=\frac{\pi}{2^n}$$
so far I have got:
$$I=\int_{0}^{\pi}\cos^n(x)\cos(nx)dx=\Re\left(\int_{0}^{\pi}\cos^n(x)\left(\cos(nx)+i\sin(nx)\right)dx\right)=\Re\left(\int_{0}^{\pi}\cos^n(x)e^{inx}dx\right)$$
since $e^{ix}=\cos(x)+i\sin(x)$ through Euler's formula and then $(e^{ix})^n=\cos(nx)+i\sin(nx)$ from De Moivre's theorem.
We also know that:
$$\cos(x)=\frac{e^{ix}+e^{-ix}}{2} \therefore \cos^n(x)=\frac{(e^{ix}+e^{-ix})^n}{2^n}$$
$$\therefore I=\frac{1}{2^n}\Re\left(\int_{0}^{\pi}e^{inx}\left(e^{ix}+e^{-ix}\right)^ndx\right)=\frac{1}{2^n}\Re\left(\int_{0}^{\pi}e^{inx}\sum_{r=0}^{n}\left(\begin{matrix}n\\r\end{matrix}\right)(e^{ix})^{n-r}(e^{-ix})^rdx\right)=\frac{1}{2^n}\Re\left(\sum_{r=0}^{n}\left(\begin{matrix}n\\r\end{matrix}\right)\int_{0}^{\pi}(e^{ix})^{2n-2r}dx\right)=\frac{1}{2^n}\Re\left(\sum_{r=0}^{n}\left(\begin{matrix}n\\r\end{matrix}\right)\left[\frac{e^{(2n-2r)ix}}{(2n-2r)i}\right]_{0}^{\pi}\right)$$
I have found the same problem but a confusing layout, shown below. Could someone show me where to go from here?
https://www.quora.com/Is-it-possible-to-integrate-cos-n-x-cos-nx-taking-limits-as-0-to-%CF%80 (1)
EDIT:
$$I=\frac{1}{2^n}\Re\left(\sum_{r=0}^{n}\left(\begin{matrix}n\\r\end{matrix}\right)\left[\frac{e^{(n-r)2i\pi}-1}{2(n-r)i}\right]\right)$$
for when $r=n$ we effectively get $$\lim_{x \to 0}\left(\frac{e^{2xi\pi}}{2xi}\right)=\lim_{x \to 0}\left(\frac{2i\pi\,e^{2xi\pi}}{2i}\right)=\pi$$
FURTHER EDIT:
since all other elements in the summation will be imaginary then the summation will evaluate to $\pi$ therefore I have proved it

REPLY [4 votes]: Although I recognize that this post is relatively old, let me propose another strategy to solving this problem. 
Let
$$ I(n) = \int_{0}^{\pi}\cos^{n}(x)\cdot\cos(n\cdot x)\,\text{d}x\text{,}$$
where $n\in\mathbb{N}^{0}$.
Perform integration by parts, 
$$ \int u\,\text{d}v=u\cdot v-\int v\,\text{d}u\text{,} $$ 
where 
$$ u = \cos^{n}(x)\Leftrightarrow\text{d}u = -n\cdot\cos^{n-1}(x)\cdot \sin(x)\,\text{d}x\text{,} \\
    \text{d}v = \cos(n\cdot x)\,\text{d}x\Leftrightarrow v = 1/n\cdot\sin(n\cdot x)\text{.} $$
Then,
$$ \begin{align} 
I(n) & = \left.1/n\cdot\cos^{n}(x)\cdot\sin(n\cdot x)\right|_0^{\pi}+\int_{0}^{\pi}\cos^{n-1}(x)\cdot\sin(n\cdot x)\cdot\sin(x)\,\text{d}x \\
  & = \int_{0}^{\pi}\cos^{n-1}(x)\cdot\sin(n\cdot x)\cdot\sin(x)\,\text{d}x\text{.}
   \end{align} $$
Take the sum of both integral forms:
$$ \begin{align} 
2\cdot I(n) & = \int_{0}^{\pi}\cos^{n}(x)\cdot\cos(n\cdot x)\,\text{d}x+\int_{0}^{\pi}\cos^{n-1}(x)\cdot\sin(n\cdot x)\cdot\sin(x)\,\text{d}x \\
  & = \int_{0}^{\pi}\cos^{n-1}(x)\cdot\left(\cos(n\cdot x)\cdot\cos(x)+\sin(n\cdot x)\cdot\sin(x)\right)\text{d}x\text{.}
   \end{align} $$ 
Make use of the angle-difference identity for the cosine function, 
$$ \cos(\alpha-\beta) = \cos(\alpha)\cdot\cos(\beta)+\sin(\alpha)\cdot\sin(\beta)\text{.} $$
Then,
$$ 2\cdot I(n) = \int_{0}^{\pi}\cos^{n-1}(x)\cdot\cos\left((n-1)\cdot x\right)\,\text{d}x\text{.} $$
Recognize that
$$ 2\cdot I(n) = I(n-1) $$
Then,
$$ \begin{align}
2\cdot I(n-1) & = I(n-2) \\
2\cdot I(n-2) & = I(n-3) \\
       & \;\;\vdots \\
2\cdot I(1)   & = I(0)\text{.}
   \end{align} $$
It follows that
$$ 2^{n}\cdot I(n) = I(0)\Rightarrow I(n) = \frac{I(0)}{2^{n}}\text{.} $$
According to the integral form,
$$ I(0) = \int_{0}^{\pi}\cos^{0}(x)\cdot\cos(0\cdot x)\,\text{d}x = \int_{0}^{\pi}\text{d}x = \pi\text{.} $$ 
Thus,
$$ I(n) = \frac{\pi}{2^{n}}\text{,} $$
where $n\in\mathbb{N}^{0}$.