# Complex integral with Residues Theorem

I've been going crazy with this complex integral I have to estimate with the Residues Theorem. I'm obviously missing a sign or something else, but I fear I may be committing a conceptual mistake.

$$\int_{0}^{\infty} \frac{\log x}{x^2-1} \mathrm{d}x$$

I choose to solve this integral by computing the following complex integral:

\begin{align*} \int_{\gamma} \frac{\log^2 z}{z^2-1}dz &= \lim_{\epsilon \to 0} \bigg{[} \int_{0}^{R} dx \frac{\log^2 (x+i\epsilon)}{(x+i\epsilon)^2-1}+\int_{R}^{0} dx \frac{\log^2 (x-i\epsilon)}{(x-i\epsilon)^2-1} \\ &+\int_{2\pi}^{0}d\theta i \epsilon e^{i\theta} \frac{\log^2 (\epsilon e^{i\theta})}{(\epsilon e^{i\theta})^2-1} +\int_{2\pi}^{0}d\theta i \epsilon e^{i\theta} \frac{\log^2 (1+\epsilon e^{i\theta})}{(1+\epsilon e^{i\theta})^2-1} \bigg{]} + \int_{\tilde \gamma}dz \frac{\log^2 z}{z^2-1} \end{align*}

Where $$\gamma$$ is the "keyhole" path, and $$\tilde\gamma$$ is the circle centered in $$z=0$$ with $$R$$ radius. If $$R\rightarrow\infty$$, then:

\begin{align*} &=\int_{0}^{\infty} dz \frac{\log^2 (x)}{x^2-1}-\int_{0}^{\infty} dx \frac{(\log (x)+2\pi i)^2}{x^2-1} \\ &=-4\pi i \int_{0}^{\infty}dx\frac{\log (x)}{x^2-1}+ 4 \pi^2 \int_{0}^{\infty} dx \frac{1}{x^2-1}=-4\pi i \int_{0}^{\infty}dx\frac{\log (x)}{x^2-1} \end{align*}

since $$\int_{0}^{\infty}\frac{1}{x^2-1}\mathrm{d}x = 0.$$

I can estimate the complex integral with the Residues theorem:

$$\int_{\gamma} \frac{\log^2 z}{z^2-1}dz=2\pi i \mathrm{Res}[f(z), -1]=i \pi^3$$

and this means that:

$$\int_{0}^{\infty} \frac{\log (x)}{x^2-1}\mathrm{d}x=-\frac{\pi^2}{4}$$

which is wrong, since the correct result should be $$\frac{\pi^2}{4}$$.

Is there something wrong with my procedure?

• The contour should not cross the singularity pole.
– Zau
Commented Jul 6, 2016 at 13:36
• Try integrating along $\partial G$ with $G=\{z\in\mathbb C\,\mid\,r<|z|<R,\,\operatorname{Im} z>0\}$. (I am currently busy but will post this approach later.) Commented Jul 6, 2016 at 14:49

The issue lies with the contour along the real axis from the lower half plane. Note the singularity at $x=1$ of the integrand

$$\frac{(\log(x)+i2\pi)^2}{x^2-1}=\frac{\log^2(x)}{x^2-1}+i4\pi \frac{\log(x)}{x^2-1}-\bbox[5px,border:2px solid #C0A000]{4\pi^2 \frac{1}{x^2-1}} \tag 1$$

due to the presence of the third term on the right-hand side of $(1)$, which is highlighted in box.

In order to avoid this singularity, we must deform the keyhole around $x=1$ with a "small" semicircle. Therefore, we introduce the integral

\begin{align} \lim_{\nu \to 0}\left(\int_{2\pi}^\pi \frac{(\log(1+\nu e^{i\phi})+i2\pi)^2}{(1+\nu e^{i\phi})^2-1}\,i\nu e^{i\phi}\,d\phi\right) &=4\pi^2\lim_{\nu \to 0}\left(\int_\pi^{2\pi} \frac{1}{(1+\nu e^{i\phi})^2-1}\,i\nu e^{i\phi}\,d\phi\right)\\\\ &=4\pi^2\lim_{\nu \to 0}\left(\int_\pi^{2\pi} \frac{i}{2+\nu e^{i\phi}}\,d\phi\right)\\\\ &=i2\pi^3 \end{align}

When accounting for this omission, we find that

$$-i4\pi \int_0^\infty \frac{\log(x)}{x^2-1}\,dx+i2\pi^3=i\pi^3$$

whereupon solving for the integral of interest yields

$$\bbox[5px,border:2px solid #C0A000]{\int_0^\infty \frac{\log(x)}{x^2-1}\,dx=\frac{\pi^2}{4}}$$

as expected!

\begin{align} -\lim_{\epsilon \to 0}\int_0^\infty \frac{\log^2(x-i\epsilon)}{(x-i\epsilon)^2-1}\,dx&=4\pi^2 \lim_{\epsilon \to 0}\int_0^\infty \frac{1}{(x-i\epsilon)^2-1}\,dx\\\\ &=4\pi^2 \lim_{\epsilon \to 0}\left.\left(\frac{\log\left(\frac{x-1-i\epsilon}{x+1-i\epsilon}\right)}{2}\right) \right|_0^\infty\\\\ &=-i2\pi^3 \end{align}

which is the same result as before.

• @MarcoCantarini Marco, thank you! Much appreciative. And don't you hate when that happens? I type so slowly that I am on the other side often. Any way, I hope your doing well. Mark Commented Jul 6, 2016 at 16:01
• Well, if someone has to beat me I'm glad it's you. You are probably the most polite person here and one of the most gifted. Well done again Mark ;) Commented Jul 6, 2016 at 16:15
• Wow! That just made my day. And let me return by saying that you have posted some exceptionally creative solutions that have more than impressed me. Commented Jul 6, 2016 at 16:20

A different way to approach this would be to substitute $x = \sqrt{t}$, the integral then becomes

$$\frac{1}{4}\int_{0}^{\infty}\frac{t^{-\frac{1}{2}}\log(t)dt}{t-1}$$

This looks similar to the standard integral:

$$\int_{0}^{\infty}\frac{x^{-p}dx}{x+1}dx = \frac{\pi}{\sin(\pi p)}$$

which is easily evaluated using a keyhole contour, so we may try to use this integral to evaluate the desired integral. We can bring down a factor $\log(x)$ by differentiating w.r.t. $p$, but how do we change the $1$ to $-1$ in the denominator? A simple trick that sidesteps all the complications due to introducing a singularity at $x=1$ in intermediary results, is to consider the integral:

$$I(p,a) = \int_{0}^{\infty}\frac{x^{-p}dx}{x+a}dx = \frac{\pi a^{-p}}{\sin(\pi p)}$$

This is valid for positive $a$, but the analytic continuation to negative $a$ can be used without problems. Taking minus the derivative of $I(a,p)$ w.r.t. $p$ yields:

$$-\frac{\partial I(p,a)}{\partial p} = \int_{0}^{\infty}\frac{x^{-p}\log(x)dx}{x+a}dx = \frac{\pi a^{-p}}{\sin(\pi p)}\left[\pi\cot(\pi p)+\log(a)\right]$$

We can analytically continue this allowing for complex $a$, one needs to define $\log(a)$ to make both the logarithm and $a^{-p}$ well defined. For negative $a$ not equal to $-1$ there is a singularity in the integrand at $x = -a$. The interpretation of the finite analytical continuation of the integral is then as follows. Instead of integrating from 0 to infinity, you could have integrated along a contour from 0 to infinity that makes room for the singularity at $x = -a$ to appear in an analytical way. This is therefore the analytical continuation of the integral, so using the analytic continuation will automatically deform the contour in the right way. The imaginary part that then appears is due to the contour deforming to avoid the singularity, and this will depend from which direction you push the singularity on the positive real axis.

Now, for $a = -1$ the original integral is well defined, so the result will be real and won't depend on whether we put $a = \exp(i\pi)$ or $a = \exp(-i\pi)$ as long as we make sure the branch cut of $\log(a)$ does not cause jumps along the way of changing $a$ from positive to the negative value. This means that $\log(a) = i\pi$ if we choose $a = \exp(i\pi)$ while it is $-i\pi$ if we choose $a = \exp(-i\pi)$. The result is then easily found to be:

$$\int_{0}^{\infty}\frac{x^{-p}\log(x)dx}{x-1}dx = \pi^2\left[\cot^2(\pi p) + 1\right]$$

which yields the result $\frac{\pi^2}{4}$ for the original integral.

$\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{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{\mathrm{i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\Li}[1]{\,\mathrm{Li}} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

The identity $${1 \over x \pm \ic 0^{+}} \color{#f00}{=} \mathrm{P.V.}\pars{1 \over x}\ \mp\ \ic\pi\,\delta\pars{x}$$ is quite useful whenever a singularity 'sits' on a branch-cut. The equality $\ds{\color{#f00}{=}}$ is understood 'under the integral sign'.

1. The integral $\ds{\oint{\ln^{2}\pars{z} \over z^{2} - 1}\,\dd z}$ ( we'll use the OP branch-cut ) has the value \begin{align} 2\pi\ic\,{\bracks{\ln\pars{\verts{-1}} + \pi\ic}^{\,2} \over -1 - 1} & = \pi^{3}\ic\tag{1} \end{align}
2. $\ul{Above\ the\ real\ axis}$: \begin{align} &\int_{0}^{\infty}{\bracks{\ln\pars{x} + 0\ic}^{2} \over \pars{x - 1 + \ic 0^{+}}\pars{x + 1}}\,\dd x \\[3mm] = &\ \mathrm{P.V.}\int_{0}^{\infty}{\bracks{\ln\pars{x} + 0\ic}^{2} \over \pars{x - 1}\pars{x + 1}}\,\dd x - \ic\pi\int_{0}^{\infty}{\bracks{\ln\pars{x} + 0\ic}^{2} \over x + 1}\,\delta\pars{x - 1}\,\dd x \\[3mm] = &\ \int_{0}^{\infty}{\ln^{2}\pars{x} \over x^{2} - 1}\,\dd x\tag{2} \end{align}
3. $\ul{Below\ the\ real\ axis}$: \begin{align} &\int_{\infty}^{0}{\bracks{\ln\pars{x} + 2\pi\ic}^{\,2} \over \pars{x - 1 - \ic 0^{+}}\pars{x + 1}}\,\dd x \\[3mm] = &\ -\mathrm{P.V.}\int_{0}^{\infty}{\bracks{\ln\pars{x} + 2\pi\ic}^{\,2} \over \pars{x - 1}\pars{x + 1}}\,\dd x - \ic\pi\int_{0}^{\infty}{\bracks{\ln\pars{x} + 2\pi\ic}^{\,2} \over x + 1}\,\delta\pars{x - 1}\,\dd x \\[3mm] = &\ -\int_{0}^{\infty}{\ln^{2}\pars{x} \over x^{2} - 1}\,\dd x - 4\pi\ic\int_{0}^{\infty}{\ln\pars{x} \over x^{2} - 1}\,\dd x + 4\pi^{2}\,\ \underbrace{\mathrm{P.V.}\int_{0}^{\infty}{\dd x \over x^{2} - 1}}_{\ds{=\ 0}} + 2\pi^{3}\ic\tag{3} \end{align}
4. But, "$\ds{\pars{1} = \pars{2} + \pars{3}}$": \begin{align} \pi^{3}\ic & = -4\pi\ic\int_{0}^{\infty}{\ln\pars{x} \over x^{2} - 1}\,\dd x + 2\pi^{3}\ic\quad\imp \int_{0}^{\infty}{\ln\pars{x} \over x^{2} - 1}\,\dd x = {\pi^{3}\ic - 2\pi^{3}\ic \over -4\pi\ic} \end{align}
$$\begin{array}{|c|}\hline\mbox{}\\ \ds{\quad\color{#f00}{\int_{0}^{\infty}{\ln\pars{x} \over x^{2} - 1}\,\dd x} = \color{#f00}{\pi^{2} \over 4}\quad} \\ \mbox{}\\ \hline \end{array}$$