Evaluate $\int_0^{\frac{\pi}{2}}\frac{x^2}{1+\cos^2 x}dx$

Evaluate the following integral

$$\int_0^{\frac{\pi}{2}}\frac{x^2}{1+\cos^2 x}dx$$

This function does not have an elementary anti-derivative. How can we solve this?


This integral is deviously difficult. It may look like it has the solution I provided for this integral, but, as you will see, there is an additional wrinkle.

As in the linked solution, I will express the integral in a form in which I may attack via Cauchy's theorem. I will then deduce the contour over which we will need to apply Cauchy's theorem - this is the additional wrinkle.

So, to start, let's rewrite the integral, which I will denote $K$:

$$K=\int_0^{\pi/2} dx \frac{x^2}{1+\cos^2{x}} = 2 \int_0^{\pi/2} dx \frac{x^2}{3+\cos{2 x}} = \frac18 \int_{-\pi}^{\pi} dy \frac{y^2}{3+\cos{y}}$$

Along these lines, define

$$J(a) = \int_{-\pi}^{\pi} dy \frac{e^{i a y}}{3+\cos{y}}$$

so that

$$K = -\frac18 J''(0)$$

This then allows us to define the following contour integral

$$I(a) = \oint_C dz \frac{z^a}{z^2+6 z+1}$$

where, as I will explain below, $C$ is the following contour

crazy keyhole

which is a modified keyhole contour about the negative real axis within the unit circle. The modification is a pair of semicircular bumps of radius $\epsilon$ about the point $z=-3+2 \sqrt{2}$. These bumps are necessary because the integrand has a pole within the unit circle on the chosen branch cut of the integrand (i.e., the negative real axis).

The strategy is to express $I(a)$ in terms of $J(a)$ and other terms, which will then yield an expression for $J(a)$ by Cauchy's theorem. To do this, we write out $I(a)$ explicitly in terms of integrals along the eight pieces of the contour $C$. This is an exercise in parametrization which is better left to the reader. The result is

$$I(a) = \frac{i}{2} J(a) +e^{i \pi} \int_1^{3-2 \sqrt{2}+\epsilon} dx \frac{e^{i \pi a} x^a}{x^2-6 x+1} \\+ i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{ [e^{i \pi}(3-2 \sqrt{2})+\epsilon e^{i \phi}]^a}{(-3+2 \sqrt{2}+\epsilon e^{i \phi})^2+6 (-3+2 \sqrt{2}+\epsilon e^{i \phi})+1}\\ +e^{i \pi} \int_{3-2 \sqrt{2}-\epsilon}^{\epsilon} dx \frac{e^{i \pi a} x^a}{x^2-6 x+1} + i \epsilon \int_{\pi}^{-\pi} d\phi \, e^{i \phi} \frac{\epsilon^a e^{i a \phi}}{\epsilon^2 e^{i 2 \phi}+6 \epsilon e^{i \phi}+1}\\ +e^{-i \pi} \int_{\epsilon}^{3-2 \sqrt{2}-\epsilon} dx \frac{e^{-i \pi a} x^a}{x^2-6 x+1}\\ + i \epsilon \int_0^{-\pi} d\phi \, e^{i \phi} \frac{ [e^{-i \pi}(3-2 \sqrt{2})+\epsilon e^{i \phi}]^a}{(-3+2 \sqrt{2}+\epsilon e^{i \phi})^2+6 (-3+2 \sqrt{2}+\epsilon e^{i \phi})+1}\\+e^{-i \pi} \int_{3-2 \sqrt{2}+\epsilon}^1 dx \frac{e^{-i \pi a} x^a}{x^2-6 x+1} $$

Actually, one remark is worth making at this point. The parametrization of the semicircular bumps about the point $z=-3+2 \sqrt{2}$ requires us to invoke the correct representation of the minus sign. Thus, above the branch cut, $-3+2 \sqrt{2}=e^{i \pi} (3-2 \sqrt{2})$, while below the branch cut, $-3+2 \sqrt{2}=e^{-i \pi} (3-2 \sqrt{2})$. This is crucial to the analysis.

We consider the limit as $\epsilon \to 0$; in this limit, the above simplifies considerably:

$$I(a) = \frac{i}{2} J(a) + i 2 \sin{\pi a} \: PV \int_0^1 dx \frac{x^a}{x^2-6 x+1} - i \frac{\pi}{4 \sqrt{2}} 2 \cos{\pi a} \: (3-2 \sqrt{2})^a$$

where $PV$ denotes the Cauchy principal value. By Cauchy's theorem, $I(a)=0$; this produces an expression for $J(a)$:

$$J(a) = \frac{\pi}{\sqrt{2}} \cos{\pi a} \: (3-2 \sqrt{2})^a - 4 \sin{\pi a}\: PV \int_0^1 dx \frac{x^a}{x^2-6 x+1}$$

All we need to do now is use the above expression for $K=-\frac18 J''(0)$; the result is

$$K = \pi \, PV \int_0^1 dx \frac{\log{x}}{x^2-6 x+1} + \frac{\pi^3}{8 \sqrt{2}} - \frac{\pi}{8 \sqrt{2}} \log^2{(3-2 \sqrt{2})}$$

To complete this analysis, we evaluate the above integral. Note that it is a principal value, as the integration interval includes a pole of the integrand. To this effect, we note that

$$\frac1{x^2-6 x+1} = \frac1{4 \sqrt{2}} \left (\frac1{x-(3+2 \sqrt{2})} - \frac1{x-(3-2 \sqrt{2})} \right )$$

We use the following formulae, when $b \gt 1$,:

$$\int_0^1 dx \frac{\log{x}}{x-b} = \text{Li}_2{\left ( \frac1{b}\right )}$$

and

$$PV\int_0^1 dx \frac{\log{x}}{x-1/b} =\frac{\pi^2}{3} - \frac12 \log^2{\left ( \frac1{b}\right )} - \text{Li}_2{\left ( \frac1{b}\right )}$$

Thus, using the value $b=3+2 \sqrt{2}$, we find that

$$PV \int_0^1 dx \frac{\log{x}}{x^2-6 x+1} = \frac1{4 \sqrt{2}} \left [2 \text{Li}_2{(3-2 \sqrt{2})} - \frac{\pi^2}{3} + \frac12 \log^2{(3-2 \sqrt{2})} \right ] $$

Putting this all together, we find that the $\log^2$ terms cancel and we have

$$K = \int_0^{\pi/2} dx \frac{x^2}{1+\cos^2{x}} = \frac{\pi}{2 \sqrt{2}} \text{Li}_2{(3-2 \sqrt{2})} + \frac{\pi^3}{24 \sqrt{2}}$$

To summarize, we replaced the $x^2$ in the original integral by a factor of $e^{i a y}$, which then became a factor of $z^a$ in a contour integral. The integrand of the contour integral not only has a branch point at $z=0$, but also a pole on the branch cut. The contour of the contour integral then needed to have a detour around this pole on the branch cut. Using Cauchy's theorem, we got an expression for the integral over $e^{i a y}$, and differentiating twice, we got an expression for the original integral in terms of the principal value of another integral. The problem then reduced to evaluating the principal value of that integral.


$\newcommand{\+}{^{\dagger}}% \newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}% \newcommand{\dd}{{\rm d}}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\fermi}{\,{\rm f}}% \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}% \newcommand{\half}{{1 \over 2}}% \newcommand{\ic}{{\rm i}}% \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow}% \newcommand{\isdiv}{\,\left.\right\vert\,}% \newcommand{\ket}[1]{\left\vert #1\right\rangle}% \newcommand{\ol}[1]{\overline{#1}}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}}% \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}% \newcommand{\sech}{\,{\rm sech}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$ Following $\large\verb*@RonGordon*$ fine answer, there is another way to evaluate ${\rm I}\pars{a}$ without introducing the 'little bumps' in the $C$ contour. For this purpose, it's useful to use the identities: $$ {1 \over \omega \pm \ic 0^{+}} = \pp{1 \over \omega} \mp \ic\pi\delta\pars{\omega} \quad\mbox{where}\quad\pp\ \mbox{denotes the}\ {\it\mbox{Principal Part}}. $$ \begin{align} K& = {1 \over 8}\int_{-\pi}^{\pi}{y^{2} \over 3 + \cos\pars{y}}\,\dd y = -\,{1 \over 8}\,\lim_{a \to 0} \totald[2]{}{a}\int_{-\pi\ +\ 0^{+}}^{\pi\ -\ 0^{+}} {\expo{\ic ay} \over 3 + \cos\pars{y}}\,\dd z \\[3mm]&= {1 \over 4}\ic\lim_{a \to 0}\totald[2]{}{a} \oint_{-\pi\ +\ 0^{+}}^{\pi\ -\ 0^{+}}{z^{a} \over z^{2} + 6z + 1}\,\dd z \\[3mm]&= {1 \over 4}\ic\lim_{a \to 0}\totald[2]{}{a}\left\lbrack% \overbrace{\oint_{C}{z^{a} \over z^{2} + 6z + 1}\,\dd z}^{\ds{=\ 0}}\right. \\[3mm]&\left.\vphantom{\Huge A^{A^{A}}}- \int_{-1}^{0} {\pars{-x}^{a}\expo{\ic\pi a} \over \pars{x + \ic 0^{+} - z_{+}}\pars{x - z_{-}}}\,\dd x - \int^{-1}_{0} {\pars{-x}^{a}\expo{-\ic\pi a} \over \pars{x - \ic 0^{+} - z_{+}}\pars{x - z_{-}}}\,\dd x\right\rbrack \end{align} where $\ds{z_{\pm} = -3 \pm 2\root{2}\,,\quad -1 < z_{+} < 0\,,\quad z_{-} < -1}$.

\begin{align} K&={1 \over 4}\,\ic\,\lim_{a \to 0}\totald[2]{}{a}\left\lbrack% -\expo{\ic\pi a}\int_{0}^{1} {x^{a}\,\dd x \over \pars{x - \ic 0^{+} + z_{+}}\pars{x + z_{-}}}\right. \\[3mm]&\left.\phantom{{1 \over 4}\,\ic\,\lim_{a \to 0}\totald[2]{}{a}\bracks{}}+ \expo{-\ic\pi a}\int_{0}^{1} {x^{a}\,\dd x \over \pars{x + \ic 0^{+} + z_{+}}\pars{x + z_{-}}}\right\rbrack \\[3mm]&= {1 \over 4}\,\ic\,\lim_{a \to 0}\totald[2]{}{a}\bracks{% -2\ic\sin\pars{\pi a}\ \pp\int_{0}^{1} {{x^a}\,\dd x \over \pars{x + z_{+}}\pars{x + z_{-}}} -2\pi\ic\cos\pars{\pi a}\,{1 \over -z_{+} + z_{-}}} \\[3mm]&=\pi\ \pp\int_{0}^{1} {\ln\pars{x} \over \pars{x + z_{+}}\pars{x + z_{-}}}\,\dd x + {\root{2} \over 16}\,\pi^{3} \\[3mm]&= {\root{2} \over 8}\,\pi\bracks{\int_{0}^{1}{\ln\pars{x} \over x + z_{-}}\,\dd x - \pp\int_{0}^{1}{\ln\pars{x} \over x + z_{+}}\,\dd x} + {\root{2} \over 16}\,\pi^{3} \\[3mm]&= {\root{2} \over 8}\,\pi\bracks{{\rm Li_{2}}\pars{-3 - \root{2}} - \pp\int_{0}^{1}{\ln\pars{x} \over x + z_{+}}\,\dd x} + {\root{2} \over 16}\,\pi^{3} \end{align}

Also \begin{align} \pp\int_{0}^{1}{\ln\pars{x} \over x + z_{+}}\,\dd x &=\lim_{\epsilon \to 0^{+}}\bracks{% \int_{0}^{-z_{+} - \epsilon}{\ln\pars{x} \over x + z_{+}}\,\dd x + \int_{-z_{+} + \epsilon}^{1}{\ln\pars{x} \over x + z_{+}}\,\dd x} \end{align}