# 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?

• Try the symmetrical substitution $x = \frac{\pi}{2} - x$. – Ayesha Jan 10 '14 at 2:37
• @Ayesha: how does that help? – Robert Israel Jan 10 '14 at 3:10
• its helpful if the limits were from $0$ to $\pi$ – Suraj M S Jan 10 '14 at 3:12
• Why are there close votes? Some of us enjoy working out these integrals. Please stop. – Ron Gordon Jan 11 '14 at 14:56

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

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.

• Is there a reason why you couldn't put the branch cut on the positive real axis. That would seem simpler. – Random Variable Jan 11 '14 at 14:39
• @RandomVariable: it would, but the integral necessarily is over $[-\pi,\pi]$. The $x^2$ in the integral makes this necessary. Perhaps there is a way around this, but as of right now, I don't know it. – Ron Gordon Jan 11 '14 at 14:45
• I have a question. For the $J(a)$ you defined, if we use the change of variable $z=e^{iy}$ then we get $$J(a)=-2i\int_{|z|=1}\frac{z^a}{z^2+6z+1}dz$$. Then using Cauchy's integral formula we can get $J(a)$, then differentiate twice and plug in $a=0$ we should get the desired answer. But it seems this way does not lead to the correct answer. What is the problem of this method? – Justin Jan 11 '14 at 20:58
• @Justin: the problem lies with the branch point at $z=0$. The contour chosen must be chosen so as to exclude the branch point from the interior of the contour. – Ron Gordon Jan 11 '14 at 21:02
• @Ron Gordon Thanks. That makes sense. One more question, could you please explain how to take the derivative of the principal value? That will help a lot – Justin Jan 11 '14 at 23:06


\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}

• Thank you for the kind words. What is your $C$ then? Is it my $C$, but without the bumps? – Ron Gordon Jan 11 '14 at 14:52
• Yes. Without the bumps. – Felix Marin Jan 11 '14 at 17:31
• Thank you for providing an alternative method. – Justin Jan 12 '14 at 6:44
• Not to put too fine a point on this, but it looks to me like you are applying a formalism designed to deal with the bumps inherently. In other words, you really haven't gotten rid of the bumps. Rather, you just know in advance what effect they will have on the solution. – Ron Gordon Jan 14 '14 at 18:05

Mathematica returns $$\frac{12 \pi \text{Li}_2\left(3-2 \sqrt{2}\right)+\pi ^3}{24 \sqrt{2}},$$ which does not look so appetizing.