A Tale of Two Integrals

Two integrals look almost the same, and even to those fairly well-versed in the art, are the same. But alas, as we shall see.

Consider the integral

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

This may be evaluated by subbing $x \mapsto \pi-x$ as follows:

$$\begin{align} I_1 &= \int_0^{\pi} dx \frac{(\pi-x) \sin{x}}{1+\cos^2{x}} \\&= \pi \int_0^{\pi} dx \frac{\sin{x}}{1+\cos^2{x}} – I_1 \end{align}$$

so that

$$2 I_1 = -\pi \int_0^{\pi} \frac{d(\cos{x})}{1+\cos^2{x}} = \pi \arctan{(\cos{0})} – \pi \arctan{(\cos{\pi})}$$


$$I_1 = \frac{\pi^2}{4} $$

Easy, right? Now consider

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

This integral looks pretty much the same as $I_1$, but the sub $x \mapsto \pi-x$ reveals nothing, the reason being that the sub changes the sign of the cosine in the numerator. Integration by parts, a seemingly obvious strategy, reveals an integral over $\arctan{(\sin{x})}$, which doesn’t help matters.

The strategy I propose is similar to that shown here. I will outline how this problem may be attacked using complex analysis. This is a surprisingly involved problem which I mistook for a much easier one in which the sines and cosines were reversed. But this is again a useful exercise in setting up a contour integral and applying the residue theorem. It is very satisfying to see that the correct result appears after all the analysis and manipulation.

First recognize that

$$\int_0^{\pi} dx \frac{x \cos{x}}{1+\sin^2{x}} = \left [\frac{\partial}{\partial \alpha} \int_0^{\pi} dx \frac{\sin{\alpha x}}{1+\sin^2{x}}\right ]_{\alpha=1}$$

The idea is to somehow stretch the integration interval over the unit circle. If we instead consider the integral

$$\begin{align}\int_0^{2 \pi} dx \frac{\sin{\alpha x}}{1+\sin^2{x}} &= \int_0^{\pi} dx \frac{\sin{\alpha x}}{1+\sin^2{x}}+\int_{\pi}^{2 \pi} dx \frac{\sin{\alpha x}}{1+\sin^2{x}} \\ &= (1+\cos{\pi \alpha}) \int_0^{\pi} dx \frac{\sin{\alpha x}}{1+\sin^2{x}}+\sin{\pi \alpha} \int_0^{\pi} dx \frac{\cos{\alpha x}}{1+\sin^2{x}}\end{align}$$

Note that the second integral on the RHS may be extended over $[-\pi,\pi]$ due to the evenness of the integrand.

We now have the desired integral expressed in terms of two integrals that now may be expressed in terms of an integral over the unit circle in the complex plane.

We consider the following integral:

$$i 4 \oint_{C_{\pm}} dz \frac{z^{1+\alpha}}{z^4-6 z^2+1} $$

where $C_{\pm}$ is a keyhole contour about the positive/negative real axis, traversing the unit circle counterclockwise, with semicircular detours about the respective poles about $\pm (\sqrt{2}-1)$.

For example, $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=-1+\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).

As one may see from the figure, this contour has 8 segments, the integrals over which I will now write out in detail. Let $z_0=\sqrt{2}-1$.

$$\int_{-\pi}^{\pi} d\phi \frac{e^{i \alpha \phi}}{1+\sin^2{\phi}} + i 4 e^{i \pi \alpha} \int_1^{z_0+\epsilon} dx \frac{x^{1+\alpha}}{x^4-6 x^2+1} \\ -4 \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{(e^{i \pi} z_0 + \epsilon e^{i \phi})^{1+\alpha}}{ (-z_0+\epsilon e^{i \phi})^4– 6 (-z_0+\epsilon e^{i \phi})^2 + 1} + i 4 e^{i \pi \alpha} \int_{z_0-\epsilon}^{\epsilon} dx \frac{x^{1+\alpha}}{x^4-6 x^2+1} \\ – 4 \epsilon \int_{\pi}^{-\pi} d\phi \, e^{i \phi} \frac{\epsilon^{1+\alpha} e^{i (1+\alpha) \phi}}{\epsilon^4 e^{i 4 \phi} – 6 \epsilon^2 e^{i 2 \phi}+1} + i 4 e^{-i \pi \alpha} \int_{\epsilon}^{z_0-\epsilon} dx \frac{x^{1+\alpha}}{x^4-6 x^2+1} \\ -4 \epsilon \int_0^{-\pi} d\phi \, e^{i \phi} \frac{(e^{-i \pi} z_0 + \epsilon e^{i \phi})^{1+\alpha}}{ (-z_0+\epsilon e^{i \phi})^4– 6 (-z_0+\epsilon e^{i \phi})^2 + 1} + i 4 e^{-i \pi \alpha} \int_{z_0+\epsilon}^{1} dx \frac{x^{1+\alpha}}{x^4-6 x^2+1}$$

which is equal to, in the limit as $\epsilon \to 0$,

$$\int_{-\pi}^{\pi} d\phi \frac{e^{i \alpha \phi}}{1+\sin^2{\phi}} + i 4 e^{i \pi \alpha} PV \int_1^0 dx \frac{x^{1+\alpha}}{x^4-6 x^2+1} \\ + i 4 e^{-i \pi \alpha} PV \int_0^1 dx \frac{x^{1+\alpha}}{x^4-6 x^2+1} – \frac{\pi z_0^{\alpha}}{2 \sqrt{2}} \left (e^{i \pi \alpha} + e^{-i \pi \alpha} \right ) $$

The contour integral is equal to $i 2 \pi$ times the residue at the pole $z=\sqrt{2}-1$, or $2 \pi z_0^{\alpha}/(2 \sqrt{2}) e^{i \pi \alpha}$. Thus, we have

$$\int_{-\pi}^{\pi} d\phi \frac{\cos{\alpha \phi}}{1+\sin^2{\phi}} = \frac{\pi}{\sqrt{2}} z_0^{\alpha} (1+\cos{\pi \alpha}) – 8 \sin{\pi \alpha} \, PV \int_0^1 dx \frac{x^{1+\alpha}}{x^4-6 x^2+1}$$

Using the contour $C_+$, we can find the value of the other integral:

$$\int_0^{2 \pi} d\phi \frac{\sin{\alpha \phi}}{1+\sin^2{\phi}} = \frac{\pi}{\sqrt{2}} z_0^{\alpha} \sin{\pi \alpha} (1+\cos{\pi \alpha}) – 8 \sin^2{\pi \alpha} \, PV \int_0^1 dx \frac{x^{1+\alpha}}{x^4-6 x^2+1}$$

Putting this altogether, we finally find that

$$\int_0^{\pi} dx \frac{\sin{\alpha x}}{1+\sin^2{x}} = \frac{\pi}{2 \sqrt{2}} \left (\sqrt{2}-1 \right )^{\alpha} \sin{\pi \alpha} – 8 \sin^2{\frac{\pi \alpha}{2}} PV \int_0^1 dx \frac{x^{1+\alpha}}{x^4-6 x^2+1}$$

Taking the derivative and setting $\alpha=1$ on both sides, we find that

$$\int_0^{\pi} dx \frac{x \cos{x}}{1+\sin^2{x}} = -\frac12 \left (1-\frac1{\sqrt{2}} \right )\pi^2 – 8 PV \int_0^1 dx \frac{x^2 \log{x}}{x^4-6 x^2+1} $$


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

The integrals individually may be expressed in terms of polylogs:

$$\int_0^1 dx \frac{\log{x}}{x-(\sqrt{2}+1)} = \operatorname{Li}_2{(\sqrt{2}-1)} $$
$$\int_0^1 dx \frac{\log{x}}{x+(\sqrt{2}+1)} = \operatorname{Li}_2{(-(\sqrt{2}-1))} $$

$$PV \int_0^1 dx \frac{\log{x}}{x-(\sqrt{2}-1)} = \frac{\pi^2}{3} – \frac12 \log^2{(1+\sqrt{2})}- \operatorname{Li}_2{(\sqrt{2}-1)} $$

$$\int_0^1 dx \frac{\log{x}}{x+(\sqrt{2}-1)} = \operatorname{Li}_2{(-(\sqrt{2}+1))} $$


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

We apply the following identities for $z \lt 0$ and $0 \lt z \lt 1$ respectively:

$$\operatorname{Li}_2{(z)} + \operatorname{Li}_2{\left(\frac1{z}\right )} = -\frac{\pi^2}{6}-\frac12 \log^2{(-z)} $$

$$\operatorname{Li}_2{\left(\frac{1-z}{1+z}\right )} – \operatorname{Li}_2{\left(-\frac{1-z}{1+z}\right )} = \operatorname{Li}_2{(-z)}-\operatorname{Li}_2{(z)} + \frac{\pi^2}{4} + \log{z} \log{\left(\frac{1+z}{1-z}\right )}$$

In the first identity, let $z=-(\sqrt{2}-1)$; in the second identity, let $z=\sqrt{2}-1$. For the latter case, it is fortuitous that $z=(1-z)/(1+z)$. We get

$$\operatorname{Li}_2{(-(\sqrt{2}-1))}+\operatorname{Li}_2{(-(\sqrt{2}+1))}=-\frac{\pi^2}{6}-\frac12 \log^2{(\sqrt{2}+1)} $$

$$\operatorname{Li}_2{(\sqrt{2}-1)}-\operatorname{Li}_2{(-(\sqrt{2}-1))} = \frac{\pi^2}{8} – \frac12 \log^2{(\sqrt{2}+1)} $$

We may now start putting this altogether:

$$ 8 PV \int_0^1 dx \frac{x^2 \log{x}}{x^4-6 x^2+1} = \left (1+\frac1{\sqrt{2}} \right ) \left [\frac{\pi^2}{8} – \frac12 \log^2{(\sqrt{2}+1)}\right ]\\ – \left (1-\frac1{\sqrt{2}} \right ) \left [\frac{9 \pi^2}{24} + \frac12 \log^2{(\sqrt{2}+1)} \right ] $$

With just a little more arithmetic, we may finally conclude that

$$\int_0^{\pi} dx \frac{x \cos{x}}{1+\sin^2{x}} = \log^2{(\sqrt{2}+1)} – \frac{\pi^2}{4} $$

One Comment

Leave a Reply