# Find $a_n:a_{n+1}$ if $a_n=\int_0^{\pi/2}\cos^nx.\cos nx.dx$

Find $$a_n:a_{n+1}$$ if $$a_n=\int_0^{\pi/2}\cos^nx.\cos nx.dx$$

Attempt 1 \begin{align} &a_{n+1}=\int_0^{\pi/2}\cos^{n+1}x.\cos(n+1)x.dx\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x-(n+1)\int\cos^{n}x.\frac{\sin (n+1)x}{(n+1)}.dx\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x-\int\cos^{n}x.{\sin (n+1)x}dx\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x-\bigg[\frac{-\cos(n+1)x}{n+1}.\cos^nx\\ &\quad\quad\quad\quad\quad\quad\quad\quad-n\int\cos^{n-1}x.\frac{-\cos(n+1)x}{n+1}.dx\bigg]\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x+\frac{\cos(n+1)x}{n+1}.\cos^nx\\ &\quad\quad\quad\quad\quad\quad\quad\quad+\frac{n}{n+1}\int\cos^{n-1}x.\big(\cos nx.\cos x-\sin nx\sin x\big)dx\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x+\frac{\cos(n+1)x}{n+1}.\cos^nx\\ &\quad\quad\quad\quad\quad\quad\quad\quad+\frac{n}{n+1}\bigg[\color{red}{\int\cos^nx\cos nxdx}+\int\cos^{n-1}x.\sin x.\sin nx.dx\bigg]\\ &=\frac{\sin (n+1)x}{n+1}.\cos^{n+1}x+\frac{\cos(n+1)x}{n+1}.\cos^nx\\ &\quad\quad\quad\quad\quad\quad\quad\quad+\frac{n}{n+1}\bigg[\color{red}{a_n}+\int\cos^{n-1}x.\sin x.\sin nx.dx\bigg] \end{align}

I don't think it is leading anywhere, is there any trickier way to see the solution ?

Note: The solution given in my reference is $$2:1$$ and I understand that $$\int_0^{\pi/2}\sin^nx.dx=\int_0^{\pi/2}\cos^nx.dx=\begin{cases} \dfrac{(n-1)(n-3)....2}{n(n-2)....1}\quad\text{if n is odd}\\ \dfrac{(n-1)(n-3)....1}{n(n-2)....2}\quad\text{if n is even} \end{cases}$$

Thanks @Math1000,

Attempt 2 \begin{align} a_n &= \int_0^{\frac\pi2}\cos^n x\cos nx\ \mathsf dx = \frac{1}{2.2^n} \int_0^{\frac{\pi }{2}} \left(e^{i x}+e^{-i x}\right)^n \left(e^{i n x}+e^{-i n x}\right) \, dx\\ I_1&=\int_0^{\frac{\pi }{2}} \left(e^{i x}+e^{-i x}\right)^n e^{i n x}.dx\\ &=\bigg[(e^{i x}+e^{-i x})^n\frac{e^{inx}}{in}\bigg]_0^{\pi/2}-n\int(e^{i x}+e^{-i x})^{n-1}\frac{e^{i n x}}{in}.dx\\ &=\frac{1}{in}-n\int(e^{i x}+e^{-i x})^{n-1}\frac{e^{i n x}}{in}.dx\\ I_2&=\int_0^{\frac{\pi }{2}} \left(e^{i x}+e^{-i x}\right)^n e^{-i n x}.dx\\ &=\bigg[(e^{i x}+e^{-i x})^n\frac{e^{-inx}}{-in}\bigg]_0^{\pi/2}-n\int(e^{i x}+e^{-i x})^{n-1}\frac{e^{-i n x}}{-inx}.dx\\ &=\frac{-1}{in}+n\int(e^{i x}+e^{-i x})^{n-1}\frac{e^{-i n x}}{in}.dx\\ a_n&=\frac{i}{4}\bigg(\int_0^{\pi/2}(e^{i x}+e^{-i x})^{n-1}e^{i n x}.dx-\int_0^{\pi/2}(e^{i x}+e^{-i x})^{n-1}e^{-i n x}.dx\bigg)\\ &=\frac{i}{2^{n+1}}\int_0^{\pi/2}(e^{i x}+e^{-i x})^{n-1}\Big(e^{i n x}-e^{-i n x}\Big).dx \end{align}

• +1 for this nice question Commented Mar 10, 2023 at 23:41

$$\newcommand{\d}[1]{\, \mathrm{d}#1}$$ It's easier to start by expanding $$\cos{(n+1)x}$$. \begin{align*} a_{n+1} &= \int_0^\frac{\pi}{2} \cos^{n+1}{x}\cos{(n+1)x} \d{x} \\ &= \int_0^\frac{\pi}{2} \cos^{n+1}{x}(\cos{nx}\cos{x} - \sin{nx}\sin{x}) \d{x} \\ &= \int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} - \int_0^\frac{\pi}{2} \sin{x}\cos^{n+1}{x}\sin{nx} \d{x} \end{align*} Let's first look at the second term. Integrating by parts yields: \begin{align*} \int_0^\frac{\pi}{2} \sin{x}\cos^{n+1}{x}\sin{nx} \d{x} &= \left[-\frac{1}{n+2}\cos^{n+2}{x}\sin{nx}\right]_{x = 0}^{x = \frac{\pi}{2}} + \frac{n}{n+2}\int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} \\ &= \frac{n}{n+2}\int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} \end{align*} Back to $$a_{n+1}$$: \begin{align*} a_{n+1} &= \int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} - \frac{n}{n+2}\int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} \\ &= \frac{2}{n+2}\int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} \end{align*} We now examine the term in RHS. Integrating by parts again: \begin{align*} \int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} &= \left[\frac{1}{n}\cos^{n+2}{x}\sin{nx}\right]_{x = 0}^{x = \frac{\pi}{2}} + \frac{n+2}{n}\int_0^\frac{\pi}{2}\sin{x}\cos^{n+1}{x}\sin{nx} \d{x} \\ &= \frac{n+2}{n}\int_0^\frac{\pi}{2}\sin{x}\cos^{n+1}{x}\sin{nx} \d{x} \\ &= \frac{n+2}{n}\left[-\frac{1}{n}\sin{x}\cos^{n+1}{x}\cos{nx}\right]_{x = 0}^{x = \frac{\pi}{2}} + \frac{n+2}{n^2}\int_0^\frac{\pi}{2} (\cos^{n+2}{x} - (n+1)\sin^2{x}\cos^n{x})\cos{nx} \d{x} \\ &= \frac{n+2}{n^2}\int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} - \frac{(n+1)(n+2)}{n^2}\int_0^\frac{\pi}{2} \sin^2{x}\cos^n{x}\cos{nx} \d{x} \\ &= \frac{n+2}{n^2}\int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} - \frac{(n+1)(n+2)}{n^2}\int_0^\frac{\pi}{2} (1 - \cos^2{x})\cos^n{x}\cos{nx} \d{x} \\ &= \left(\frac{n+2}{n}\right)^2\int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} - \frac{(n+1)(n+2)}{n^2}\color{red}{\int_0^\frac{\pi}{2} \cos^n{x}\cos{nx} \d{x}} \end{align*} Therefore: \begin{align*} &\left(1 - \left(\frac{n+2}{n}\right)^2\right)\int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} = -\frac{(n+1)(n+2)}{n^2}a_n \\ &\implies \int_0^\frac{\pi}{2} \cos^{n+2}{x}\cos{nx} \d{x} = \frac{n+2}{4}a_n \end{align*} Substituting back finally yields the desired result: $$a_{n+1} = \frac{1}{2}a_n$$

There is a closed form for $$a_n$$: $$a_n = \int_0^{\frac\pi2}\cos^n x\cos nx\ \mathsf dx = \frac{1}{2^{n+1}} \int_0^{\frac{\pi }{2}} \left(e^{i x}+e^{-i x}\right)^n \left(e^{i n x}+e^{-i n x}\right) \, dx = \frac\pi{2^{n+1}}.$$

• This is interesting. Could you please explain a bit more on how do you integrate the function in the form of complex exponentials? Commented Jan 11, 2020 at 5:57
• From $e^{ix} = \cos x + i\sin x$, $\cos(-x)=\cos x$, and $\sin(-x)=-\sin x$ we get $\cos x = \frac12(e^{ix}+e^{-ix})$, and integrating the exponential function is straightforward (e.g. $\int e^{ix}\ \mathsf dx = -ie^{ix} + C$). Commented Jan 11, 2020 at 6:58
• Well, now I am not so sure. Mathematica just gave me $$\int_0^{\frac\pi 2} \cos^nx\cos nx\ \mathsf dx = \frac\pi{2^{n+1}}.$$ I suspect this to be the actual result considering it is a function of $n$. Commented Jan 11, 2020 at 7:02
• I tried to follow as u suggested. but its not going properly i think, may be because I am not familiar with integrating functions like this, could you please help me to find the solution ? Commented Jan 11, 2020 at 7:48
• Something went wrong there. You have $\cos(x)=\frac{1}{2}(e^{ix}+e^{-ix})$, thus $\cos^n(x)=\frac{1}{2^n}(e^{ix}+e^{-ix})^n$ Commented Jan 11, 2020 at 10:12

$$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{{\displaystyle #1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\on}[1]{\operatorname{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\sr}[2]{\,\,\,\stackrel{{#1}}{{#2}}\,\,\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$$ \begin{align} \color{#44f}{a_{n}} & \equiv \color{#44f}{\int_{0}^{\pi/2}\cos^{n}\pars{x}\cos\pars{nx}\,\dd x} = \Re\int_{0}^{\pi/2}\cos^{n}\pars{x}\expo{\ic nx}\,\dd x \\[5mm] & = \left.\Re\int_{0}^{\pi/2}\pars{z + 1/z \over 2}^{n}z^{n} \,{\dd z \over \ic z}\right\vert_{\, z\ \equiv\ \exp\pars{\ic x}} = \left.{1 \over 2^{n}}\,\Im\int_{0}^{\pi/2}{\pars{1 + z^{2}}^{n} \over z} \,\dd z\right\vert_{\, z\ \equiv\ \exp\pars{\ic x}} \end{align} "Close" the integration -with an indent around $$\ds{z = 0}$$- in a quarter circle in the complex plane first quadrant. Namely, \begin{align} \color{#44f}{a_{n}} & \equiv \color{#44f}{\int_{0}^{\pi/2}\cos^{n}\pars{x}\cos\pars{nx}\,\dd x} = \Re\int_{0}^{\pi/2}\cos^{n}\pars{x}\expo{\ic nx}\,\dd x \\[5mm] & = \left.{1 \over 2^{n}}\,\Im\int_{0}^{\pi/2}{\pars{1 + z^{2}}^{n} \over z} \,\dd z\right\vert_{\, z\ \equiv\ \exp\pars{\ic x}} \\[5mm] & \sr{{\rm as}\ \epsilon\ \to\ 0^{+}}{\sim} -\,{1 \over 2^{n}}\,\ \overbrace{\Im\int_{-1}^{\epsilon}{\pars{1 - y^{2}}^{n} \over \ic y}\,\ic\,\dd y}^{\ds{= 0}}\ -\ {1 \over 2^{n}}\,\Im\ \overbrace{\int_{\pi/2}^{0}{1 \over \epsilon\expo{\ic\theta}}\epsilon\expo{\ic\theta}\ic\,\dd\theta} ^{\ds{= -\pi\ic/2}} \\[2mm] & - {1 \over 2^{n}}\,\ \overbrace{\Im\int_{\epsilon}^{1}{\pars{1 + x^{2}}^{n} \over x}\,\dd x}^{\ds{= 0}}\ =\ \bbx{\color{#44f}{\pi \over 2^{n + 1}}} \end{align}

Using $$e^{ix}=\cos x+i\sin x$$ and $$\cos x= \Re(e^{ix})$$, we can express the integrals into an exponential function.\begin{aligned} \int_0^{\frac{\pi}{2}} \cos ^n x \cos n x d x = & \Re \int_0^{\frac{\pi}{2}}\left(\frac{e^{x i}+e^{-x i}}{2}\right)^n e^{n x i} d x \\ = & \frac{1}{2^n} \Re\left[\sum_{k=0}^{n}\left(\begin{array}{l} n \\ k \end{array}\right)\int_0^{\frac{\pi}{2}}\left(e^{x i}\right)^{n-k} e^{-x i k} e^{n x i} d x\right] \\ = & \frac{1}{2^n}\left[\sum_{k=0}^{n}\left(\begin{array}{l} n \\ k \end{array}\right) \Re \int_0^{\frac{\pi}{2}} e^{2(n-k) x i} d x\right] \end{aligned} For any $$k\ne n$$, $$\Re\int_0^{\frac{\pi}{2}} e^{2(n-k) x i} d x = \Re\left[\frac{e^{2(n-k) x i}}{2(n-k) i}\right]_0^{\frac{\pi}{2}}=0$$ Now we can conclude that $$a_n =\frac{1}{2^n}\left(\begin{array}{c} n \\ n \end{array}\right) \frac{\pi}{2} =\frac{\pi}{2^{n+1}}$$ Hence $$\boxed{a_n:a_{n+1}=2}$$

In general, $$\int_0^{\frac{\pi}{2}} \cos ^n x \cos m x d x= \frac{\pi}{2^{n+1}}\left(\begin{array}{c} n \\ \frac{m+n}{2} \end{array}\right)$$