Consider the integral
\[I_n=\int_0^\pi\cos(nx)\cos^n x\,\mathrm{d}x, \qquad n\in\mathbb{N}.\]We will evaluate it in three ways: integrate the oscillating factor to find a recurrence, use angle addition to reduce it to a Wallis integral, and finally use Euler’s formula to isolate a constant term. All three give
\[\boxed{I_n=\frac{\pi}{2^n}.}\]For the recurrence, we also include $n=0$, with $I_0=\pi$. Every integrand below is continuous on its interval, and every sum is finite, so no convergence or interchange-of-limits argument is needed. The appendix gives another version of the second method, using a full multiple-angle expansion and mixed-power Wallis integrals.
1. Integration by parts: a recurrence
For $n\geq1$, integrate $\cos(nx)$ and differentiate $\cos^n x$:
\[u=\cos^n x, \qquad \mathrm{d}v=\cos(nx)\,\mathrm{d}x.\]Then $v=\sin(nx)/n$ and $\mathrm{d}u=-n\cos^{n-1}x\sin x\,\mathrm{d}x$. Integration by parts gives
\[I_n=\left[\frac{\cos^n x\sin(nx)}n\right]_0^\pi +\int_0^\pi\cos^{n-1}x\sin x\sin(nx)\,\mathrm{d}x.\]The boundary term vanishes because $n$ is an integer. Thus
\[I_n=\int_0^\pi\cos^{n-1}x\sin x\sin(nx)\,\mathrm{d}x.\]Apply the product-to-sum identity to the two sine factors:
\[\sin x\sin(nx)=\frac12\bigl[\cos((n-1)x)-\cos((n+1)x)\bigr].\]The integration-by-parts expression therefore becomes
\[I_n=\frac12\int_0^\pi\cos^{n-1}x \bigl[\cos((n-1)x)-\cos((n+1)x)\bigr]\,\mathrm{d}x.\]Now return to the original integral and factor out one power of cosine:
\[I_n=\int_0^\pi\cos^{n-1}x\bigl[\cos x\cos(nx)\bigr]\,\mathrm{d}x.\]This time, the cosine product-to-sum identity gives a plus sign:
\[\cos x\cos(nx)=\frac12\bigl[\cos((n-1)x)+\cos((n+1)x)\bigr].\]Thus the original expression can also be written as
\[I_n=\frac12\int_0^\pi\cos^{n-1}x \bigl[\cos((n-1)x)+\cos((n+1)x)\bigr]\,\mathrm{d}x.\]Add the two expressions for $I_n$. Inside the integral, the $\cos((n+1)x)$ terms cancel, while the $\cos((n-1)x)$ terms add:
\[2I_n=\frac12\int_0^\pi\cos^{n-1}x \bigl[2\cos((n-1)x)\bigr]\,\mathrm{d}x.\]Canceling the factor of $2$ against $1/2$ leaves exactly the defining integral for $I_{n-1}$:
\[2I_n=\int_0^\pi\cos^{n-1}x\cos((n-1)x)\,\mathrm{d}x=I_{n-1}.\]We have obtained the recurrence
\[\boxed{I_n=\frac12 I_{n-1},\qquad n\geq1.}\]Starting from $I_0=\pi$ therefore yields
\[\boxed{I_n=2^{-n}I_0=\frac{\pi}{2^n}.}\]2. Angle addition: reduction to a Wallis integral
For $n\geq1$, start with the angle-addition formula
\[\cos(nx)=\cos((n-1)x)\cos x-\sin((n-1)x)\sin x.\]Multiplying by $\cos^n x$ and integrating gives
\[I_n=\int_0^\pi\cos((n-1)x)\cos^{n+1}x\,\mathrm{d}x -\int_0^\pi\sin((n-1)x)\sin x\cos^n x\,\mathrm{d}x.\]Integrate the second term by parts, taking
\[u=\sin((n-1)x), \qquad v=-\frac{\cos^{n+1}x}{n+1}.\]The boundary term vanishes because $\sin((n-1)x)=0$ at both endpoints. Therefore,
\[\int_0^\pi\sin((n-1)x)\sin x\cos^n x\,\mathrm{d}x =\frac{n-1}{n+1}\int_0^\pi\cos((n-1)x)\cos^{n+1}x\,\mathrm{d}x.\]Substituting back yields
\[I_n=\frac2{n+1}\int_0^\pi\cos((n-1)x)\cos^{n+1}x\,\mathrm{d}x.\]Each repetition lowers the frequency by one and raises the cosine power by one. For $n\geq2$, we can write the successive reductions directly:
\[I_n= \frac2{n+1}\cdot\frac4{n+2} \int_0^\pi\cos((n-2)x)\cos^{n+2}x\,\mathrm{d}x =\cdots=\frac2{n+1}\cdot\frac4{n+2}\cdots\frac{2n}{2n} \int_0^\pi\cos^{2n}x\,\mathrm{d}x =\frac{2^n(n!)^2}{(2n)!}\int_0^\pi\cos^{2n}x\,\mathrm{d}x.\]For $n=1$, the first reduction already reaches the same final expression. By symmetry and the Wallis formula,
\[\int_0^\pi\cos^{2n}x\,\mathrm{d}x =2\int_0^{\pi/2}\cos^{2n}x\,\mathrm{d}x =\pi\frac{(2n)!}{4^n(n!)^2}.\]Consequently,
\[\boxed{I_n=\frac{2^n(n!)^2}{(2n)!} \frac{\pi(2n)!}{4^n(n!)^2}=\frac\pi{2^n}.}\]3. Euler’s formula: the constant term
Take the real part of a complex integral:
\[I_n=\operatorname{Re}\int_0^\pi e^{inx}\cos^n x\,\mathrm{d}x.\]Euler’s formula packages both factors into a single power:
\[e^{inx}\cos^n x=(e^{ix}\cos x)^n =\left(\frac{1+e^{2ix}}2\right)^n.\]Expanding by the binomial theorem gives
\[I_n=\frac1{2^n}\operatorname{Re} \sum_{k=0}^{n}\binom nk\int_0^\pi e^{2ikx}\,\mathrm{d}x.\]Every nonconstant exponential integrates to zero: for integers $k\geq1$,
\[\int_0^\pi e^{2ikx}\,\mathrm{d}x =\frac{e^{2ik\pi}-1}{2ik}=0.\]Only $k=0$ remains, contributing $\pi$. Thus
\[\boxed{I_n=\frac\pi{2^n}.}\]The first method uses product-to-sum identities to combine the original integral with its integration-by-parts form. The second lowers the frequency while raising the cosine power, until a single Wallis integral remains. The third makes the cancellation immediate: all nonconstant complex exponentials vanish on integration, leaving just the constant coefficient $2^{-n}$.
Appendix: multiple-angle expansion and generalized Wallis integrals
The Wallis integral used in the second method contains only a power of cosine. Its mixed-power extension contains powers of both sine and cosine. For nonnegative integers $a$ and $b$, define
\[W_{a,b}=\int_0^{\pi/2}\sin^{2a}x\cos^{2b}x\,\mathrm{d}x.\]This is a generalized Wallis integral: the ordinary even-power cosine integral is the special case $a=0$. The mixed-power formula can be viewed as a fuller version of the Wallis formula, but “generalized” is more precise than “complete”: it extends the family rather than correcting an incomplete formula. In fact, the beta integral also allows noninteger powers; the even integer powers here are exactly what this problem needs.
The mixed-power Wallis formula
For $a\geq1$, integrate by parts with $u=\sin^{2a-1}x$ and $\mathrm{d}v=\sin x\cos^{2b}x\,\mathrm{d}x$. The boundary term vanishes, and we obtain
\[W_{a,b}=\frac{2a-1}{2b+1}W_{a-1,b+1}.\]Since $\cos^2x=1-\sin^2x$, we also have $W_{a-1,b+1}=W_{a-1,b}-W_{a,b}$. Substitution and rearrangement give
\[W_{a,b}=\frac{2a-1}{2(a+b)}W_{a-1,b}.\]The remaining cosine integral obeys the ordinary Wallis recurrence:
\[W_{0,b}=\frac{2b-1}{2b}W_{0,b-1}, \qquad W_{0,0}=\frac\pi2.\]Iterating the two recurrences yields the mixed-power formula
\[\boxed{W_{a,b}=\frac\pi2 \frac{(2a)!(2b)!}{4^{a+b}a!\,b!\,(a+b)!}.}\]Expanding the multiple angle
Instead of reducing the frequency one step at a time, repeatedly apply the sine and cosine addition formulas to expand the multiple angle fully:
\[\cos(nx)=\sum_{k=0}^{\lfloor n/2\rfloor} (-1)^k\binom n{2k}\cos^{n-2k}x\sin^{2k}x.\]The identity follows by induction from the addition formulas, without complex exponentials. Multiplying by $\cos^n x$ gives
\[I_n=\sum_{k=0}^{\lfloor n/2\rfloor}(-1)^k\binom n{2k} \int_0^\pi\cos^{2n-2k}x\sin^{2k}x\,\mathrm{d}x.\]Each integrand is symmetric about $\pi/2$. Its integral is therefore $2W_{k,n-k}$, which the mixed-power formula evaluates as
\[\int_0^\pi\cos^{2n-2k}x\sin^{2k}x\,\mathrm{d}x =\frac{\pi(2k)!(2n-2k)!}{4^n k!(n-k)!\,n!}.\]After multiplying by $\binom n{2k}$ and canceling factorials, we obtain
\[I_n=\frac\pi{4^n} \sum_{k=0}^{\lfloor n/2\rfloor}(-1)^k\binom nk\binom{2n-2k}{n}.\]Evaluating the finite sum
Denote the sum above by $S_n$, and let $[t^n]P(t)$ mean the coefficient of $t^n$ in a polynomial $P(t)$. For $k>\lfloor n/2\rfloor$, the coefficient $\binom{2n-2k}{n}$ is zero, so we may extend the sum to $n$:
\[S_n=[t^n]\sum_{k=0}^{n}(-1)^k\binom nk(1+t)^{2n-2k}.\]The binomial theorem collapses the polynomial inside the coefficient:
\[\sum_{k=0}^{n}(-1)^k\binom nk(1+t)^{2n-2k} =\bigl((1+t)^2-1\bigr)^n.\]Since $(1+t)^2-1=t(t+2)$, we get
\[S_n=[t^n]\,t^n(t+2)^n=2^n.\]Thus this expanded version of the Wallis method gives the same result:
\[\boxed{I_n=\frac\pi{4^n}\,2^n=\frac\pi{2^n}.}\]