I need some help on computing this integral.
I thought of this when solving another question on S.E.
Evaluate$$I=\int_{0}^{2\pi} |\cos^n t|\ dt $$ for $n \in \mathbb{Z}$.
Observation: This integral doesn't converge for negative values of $n$, so it would just be sufficient to consider $n \in \mathbb{N}$ where $\mathbb{N}=$ {$0,1,2,...$}
I've tried evaluating this integral for even and odd values of $n$.
Even Values:
For $n=0$, $I=2\pi$
For $n=2$, $I=\pi$
For $n=4$, $I=\frac{3\pi}{4}$
Odd Values:
For $n=1$, $I=4$
For $n=3$, $I=\frac{8}{3}$
For $n=5$, $I=\frac{32}{15}$
The problem is that I am unable to find a pattern in the even and odd "sequences". Any help will be deeply appreciated. I have also searched S.E for this question but nothing came up.
HINT:
$$I=\int_{0}^{2\pi} |\cos^n t|\ dt$$ $$=\int_0^\frac\pi2 |\cos^n t| dt+\int_\frac\pi2^\pi |\cos^n t| dt+\int_\pi^\frac{3\pi}2 |\cos^n t| dt+\int_\frac{3\pi}2^{2\pi} |\cos^n t| dt $$
Now $\displaystyle |x|=\begin{cases} x &\mbox{if } x\ge0 \\-x & \mbox{if } x<0 \end{cases} $
For even $n$ each integral becomes $\cos^nt$
For odd we know, $\cos t\ge0\iff 0\le t\le\frac\pi2$ or $3\frac\pi2\le t\le2\pi$
Set $u=t-\frac\pi2$ in the second integral, $v=t-\pi$ in the third and $w=t-\frac{3\pi}2$ in the fourth integral
Now using reduction formulae $\left(\displaystyle I_n=\int_0^{\frac\pi2}\cos^nxdx=\frac{n-1}nI_{n-2}\right)$, can you derive the iterative formula of $I_n$
You can use $$\int_0^{\frac\pi2}\cos^nxdx=\int_0^{\frac\pi2}\sin^nxdx $$ which can be derived applying $\displaystyle\int_a^bf(x)dx=\int_a^bf(a+b-x)dx,$