About the integral $\int_0^{\pi/2} \cos^n(x)\cos(nx) \;dx$ and $\int_0^{\pi/2} \cos^n(x)\sin(nx) \;dx$. About the integral $\displaystyle\int_0^{\pi/2}\cos^n{x}\cos{nx} dx$ and $\displaystyle\int_0^{\pi/2} \cos^n{x}\sin{nx} dx$. The value of the first one contains $\pi$, However, I tried to calculate them by integrating by parts as follows.

Let $I(m,n)$ denote the integral $\displaystyle\int_0^{\pi/2} \cos^m{x}\cos{nx} dx$, we have 
$$
 \begin{split}
I(m,n)&=\displaystyle\int_0^{\pi/2} \cos^m{x}\cos{nx}\,dx=\dfrac{1}{n}\displaystyle\int_0^{\pi/2} \cos^m{x}\,d(\sin{nx})\\
&=\dfrac{1}{n}\cos^m{x}\sin{nx}\biggr|_0^{\pi/2}-\dfrac{m}{n}\displaystyle\int_0^{\pi/2} \sin{nx}\cos^{m-1}{x}\sin{x}\,dx\\
&=-\dfrac{m}{n}\displaystyle\int_0^{\pi/2} \sin{nx}\cos^{m-1}{x}\sin{x}\,dx\\
&=\dfrac{m}{n^2}\displaystyle\int_0^{\pi/2} \cos^{m-1}{x}\sin{x}\,d(\cos{nx})\\
&=\dfrac{m}{n^2}\cos^{m-1}{x}\sin{x}\cos^{nx}\biggr|_0^{\pi/2}-\dfrac{m}{n^2}\displaystyle\int_0^{\pi/2} \cos{nx}\,d(\cos^{m-1}{x}\sin{x})\\
&=-\dfrac{m}{n^2}\displaystyle\int_0^{\pi/2}\cos{nx}(\cos^m{x}+(m-1)\cos^{m-2}{x}\sin^2{x})\,dx\\
&=-\dfrac{m}{n^2}\displaystyle\int_0^{\pi/2} \cos{nx}\cos^m{x}\,d{x}-\dfrac{m(m-1)}{n^2}\displaystyle\int_0^{\pi/2} (1-\cos^2{x})\cos^{m-2}{x}\cos{nx}\,d{x}\\
&=\dfrac{m(m-2)}{n^2}\displaystyle\int_0^{\pi/2} \cos{nx}\cos^{m}{x}\,d{x}-\dfrac{m(m-1)}{n^2}\displaystyle\int_0^{\pi/2} \cos^{n-2}{x}\cos{nx}\,d{x}\\
&=\dfrac{m(m-2)}{n^2}I(m,n)-\dfrac{m(m-1)}{n^2}I(m-2,n),
\end{split}, 
$$
That is,
$$I(m,n)=-\dfrac{m(m-1)}{n^2-m^2+2m}I(m-2,n),$$
Then we can calculate $I(m,n)$ by calculating $I(0,n)$ and $I(1,n)$. I can't see where $\pi$ occurs.
Or I'm on the wrong way... ? I don't know. Anyone can help me?
 A: Maybe nice to have an alternative way to find the integral. 
Define $A_n, I_n$ and $J_n$ as follows: $$A_n:=\int^{\pi/2}_0 \cos^n(x) e^{inx}\,dx$$
$$I_n:=\int^{\pi/2}_0 \cos^n(x)\cos(nx)\,dx , \ \ \  \ \ \ J_n:=\int^{\pi/2}_0 \cos^n(x)\sin(nx)\,dx  $$
This means that $I_n = \Re A_n$ and $J_n=\Im A_n$. So we only have to find $A_n$. 
Using $\cos(x) = \frac 1 2 \left( e^{ix}+e^{-ix}\right)$ together with the Binomial Theorem one gets
\begin{align}
A_n &= \int^{\pi/2}_0 \frac 1{2^n}\left( e^{ix}+e^{-ix} \right)^n e^{inx}\,dx \\
&= \int^{\pi/2}_0 \frac 1{2^n} \sum_{k=0}^n \binom{n}{k} e^{i2kx} \,dx\\
&= \frac 1{2^n} \frac{\pi}{2}+ \frac 1{2^n}\sum_{k=1}^n \binom{n}{k} \int^{\pi/2}_0 e^{i2kx}\,dx\\
&=\frac {\pi}{2^{n+1}} + \frac 1{2^n}\sum_{k=1}^n \binom{n}{k} \frac{1}{i2k} \left( e^{ik\pi}-1\right)\\
&=\frac {\pi}{2^{n+1}} + \frac 1{2^n}\sum_{k=1}^n \binom{n}{k} \frac{1}{i2k} \left( (-1)^k-1\right)\\
&=\frac {\pi}{2^{n+1}} +i \frac 1{2^{n}}\sum_{k=0}^{\lfloor (n-1)/2 \rfloor} \binom{n}{2k+1} \frac{1}{2k+1} \\
\end{align}
Hence:
\begin{align}
I_n = \frac{\pi}{2^{n+1}}, \ \  \ \ \ J_n = \frac 1{2^{n}}\sum_{k=0}^{\lfloor (n-1)/2 \rfloor} \binom{n}{2k+1} \frac{1}{2k+1}
\end{align}
I don't know if a nice closed form for $J_n$ exists...
A: $\underline{\left(1^{\text{st}}\right)\colon}$
$$ 
\begin{split} 
I_{(n-1)}&=+\int_{0}^{\pi/2}\cos^{n-1}(x)\,\cos\left((n-1)x\right)\,dx \\ 
&=+\int_{0}^{\pi/2}\cos^{n-1}(x)\,\left[\sin(x)\,\sin(nx)+\cos(x)\,\cos(nx)\right]\,dx \\ 
&=+\int_{0}^{\pi/2}\cos^{n-1}(x)\,\sin(x)\,\sin(nx)\,dx\,+\,\int_{0}^{\pi/2}\cos^{n}(x)\,\cos(nx)\,dx \\ 
&=+\int_{0}^{\pi/2}\cos^{n-1}(x)\,\sin(x)\,\sin(nx)\,dx\,+\,I_{(n)} \\ 
&\qquad\color{blue}{\left\{u=\sin(nx)\,\Rightarrow\,du=n\,\cos(nx)\,dx\right\}} \\ 
&\qquad\color{blue}{\left\{dv=\cos^{n-1}(x)\,\sin(x)\,dx\,\Rightarrow\,v=-{\cos^{n}(x)}/{n}\right\}} \\ 
&=I_{(n)}+\int_{0}^{\pi/2}\cos^{n}(x)\,\cos(nx)\,dx-\frac{1}{n}\cos^{n}(x)\,\sin(nx)\biggr|_{0}^{\pi/2}=2I_{(n)}-0 \\[6mm] 
I_{(n)}&=\frac{I_{(n-1)}}{2^{1}}=\frac{I_{(n-2)}}{2^{2}}=\,\,\dots\,\,=\frac{I_{(1)}}{2^{n-1}}=\frac{I_{(0)}}{2^{n}} \\ 
I_{(0)}&=\int_{0}^{\pi/2}dx\,=\frac{\pi}{2}\,\implies\,\color{red}{I_{(n)}=\int_{0}^{\pi/2}\cos^{n}(x)\,\cos(nx)\,dx=\frac{\pi}{2^{n+1}}} \\ 
\end{split} 
$$ 
$\underline{\left(2^{\text{nd}}\right)\colon}$
$$ 
\begin{split} 
J_{(n-1)}&=+\int_{0}^{\pi/2}\cos^{n-1}(x)\,\sin\left((n-1)x\right)\,dx \\ 
&=-\int_{0}^{\pi/2}\cos^{n-1}(x)\,\left[\sin(x)\,\cos(nx)-\cos(x)\,\sin(nx)\right]\,dx \\ 
&=-\int_{0}^{\pi/2}\cos^{n-1}(x)\,\sin(x)\,\cos(nx)\,dx\,+\,\int_{0}^{\pi/2}\cos^{n}(x)\,\sin(nx)\,dx \\ 
&=-\int_{0}^{\pi/2}\cos^{n-1}(x)\,\sin(x)\,\cos(nx)\,dx\,+\,J_{(n)} \\ 
&\qquad\color{blue}{\left\{u=\cos(nx)\,\Rightarrow\,du=-n\,\sin(nx)\,dx\right\}} \\ 
&\qquad\color{blue}{\left\{dv=\cos^{n-1}(x)\,\sin(x)\,dx\,\Rightarrow\,v=-{\cos^{n}(x)}/{n}\right\}} \\ 
&=J_{(n)}+\int_{0}^{\pi/2}\cos^{n}(x)\,\cos(nx)\,dx+\frac{1}{n}\cos^{n}(x)\,\cos(nx)\biggr|_{0}^{\pi/2}=2J_{(n)}-\frac{1}{n} \\[6mm] 
J_{(n)}&=\frac{2^{-1}}{n}+\frac{J_{(n-1)}}{2^{1}}=\frac{2^{-1}}{n}+\frac{2^{-2}}{n-1}+\frac{J_{(n-2)}}{2^{2}}=\,\,\dots\,\,=\sum_{k=0}^{n-1}\frac{2^{-1-k}}{n-k}+\frac{J_{(0)}}{2^{n}} \\ 
J_{(0)}&=0\,\implies\,\color{red}{J_{(n)}=\int_{0}^{\pi/2}\cos^{n}(x)\,\sin(nx)\,dx=\sum_{k=0}^{n-1}\frac{2^{-1-k}}{n-k}} \\ 
\end{split} 
$$ 
Where the last expression can be written using Lerch Zeta function: 
$$ J_{(n)} =\frac{1}{2^{n+1}}\sum_{k=0}^{n-1}\frac{2^{n-k}}{n-k} =\frac{1}{2^{n+1}}\sum_{k=1}^{n}\frac{2^k}{k} =-\frac{i\,\pi}{2^{n+1}}-\Phi(2,1,n+1) $$
