# Evaluating $\int_0^\infty \frac{\log (1+x)}{1+x^2}dx$

Can this integral be solved with contour integral or by some application of residue theorem? $$\int_0^\infty \frac{\log (1+x)}{1+x^2}dx = \frac{\pi}{4}\log 2 + \text{Catalan constant}$$

It has two poles at $\pm i$ and branch point of $-1$ while the integral is to be evaluated from $0\to \infty$. How to get $\text{Catalan Constant}$? Please give some hints.

• Just as a quick thought, it is reasonable that the constant arrives, as we may have an infinite amount of residues which leads to an infinite series. – Jon Claus May 19 '13 at 8:23
• @JonClaus yeah it seems so ... on this particular case, the poles seems only $\pm i$ – Mula Ko Saag May 19 '13 at 8:25
• Your problem is a special case of this problem. Do not forget to upvote the answers if you benefit from them :). – Mhenni Benghorbal May 19 '13 at 8:33
• – lab bhattacharjee May 19 '13 at 13:50

If you're still interested in approaches that use contour integration, consider the function $$f(z) = \frac{\log(1+z) \log(-z)}{1+z^{2}}.$$

Using the principal branch of the logarithm, there is a branch cut along $[0,\infty)$ and a branch cut along $(-\infty, -1]$.

Then integrating counterclockwise around a keyhole contour deformed around the branch cuts (see here for a picture),

\begin{align} &\int_{\infty}^{0} \frac{\log(1+x) \big(\log(x) + i \pi \big)}{1+x^{2}} \ dx + \int_{0}^{\infty} \frac{\log(1+x) \big(\log (x) - i \pi \big)}{1+x^{2}} \ dx \\ &+\int_{-\infty}^{-1} \frac{\big(\log|1+x| + i \pi \big) \log(-x)}{1+x^{2}} \ dx + \int_{-1}^{-\infty} \frac{\big(\log|1+x| - i \pi \big) \log(-x)}{1+x^{2}} \ dx \\ &= - 2 \pi i \int_{0}^{\infty} \frac{\log(1+x)}{1+x^{2}} \ dx + 2 \pi i \int_{1}^{\infty} \frac{\log(x)}{1+x^{2}} \ dx \\ &= 2 \pi i \big( \text{Res} [f(z), i] + \text{Res} [f(z), -i] \big) \\ &= 2 \pi i \left(\frac{\log(1+i) \log(-i)}{2i} + \frac{\log(1-i)\log(i)}{-2i} \right) \\ &= 2 \pi i \left( - \frac{\pi}{4} \log(2)\right) . \end{align}

Therefore,

\begin{align} \int_{0}^{\infty} \frac{\log(1+x)}{1+x^{2}} \ dx &= \frac{\pi}{4} \log(2) + \int_{1}^{\infty} \frac{\log (x)}{1+x^{2}} \ dx \\ &= \frac{\pi}{4} \log(2) - \int_{1}^{0} \frac{\log(\frac{1}{u})}{1+ (\frac{1}{u})^{2}} \frac{1}{u^{2}} \ du \\ &= \frac{\pi}{4} \log(2) - \int^{1}_{0} \frac{\log u}{1+u^{2}} \ du \\ &= \frac{\pi}{4} \log(2) + G . \end{align}

\begin{align*} \int_{0}^{\infty} \frac{\log (x + 1)}{x^2 + 1} \, dx &= \int_{0}^{1} \frac{\log (x + 1)}{x^2 + 1} \, dx + \int_{1}^{\infty} \frac{\log (x + 1)}{x^2 + 1} \, dx \\ &= \int_{0}^{1} \frac{\log (x + 1)}{x^2 + 1} \, dx + \int_{0}^{1} \frac{\log (x^{-1} + 1)}{x^2 + 1} \, dx \quad (x \mapsto x^{-1}) \\ &= 2 \int_{0}^{1} \frac{\log (x + 1)}{x^2 + 1} \, dx - \int_{0}^{1} \frac{\log x}{x^2 + 1} \, dx \end{align*}

For the first integral, we plug

$$u = \frac{1-x}{1+x}, \quad dx = - \frac{2}{(u+1)^2} \, du.$$

Then it is easy to find that

$$\int_{0}^{1} \frac{\log (x + 1)}{x^2 + 1} \, dx = \int_{0}^{1} \frac{\log 2 - \log (u + 1)}{u^2 + 1} \, du = \frac{\pi}{4}\log 2 - \int_{0}^{1} \frac{\log (u + 1)}{u^2 + 1} \, du$$

and hence

$$\int_{0}^{1} \frac{\log (x + 1)}{x^2 + 1} \, dx = \frac{\pi}{8}\log 2.$$

For the second integral, we plug $x = e^{-t}$ and we have

\begin{align*} \int_{0}^{1} \frac{\log x}{x^2 + 1} \, dx &= - \int_{0}^{\infty} \frac{t e^{-t}}{1 + e^{-2t}} \, dt = - \sum_{n=0}^{\infty} (-1)^{n} \int_{0}^{\infty} t \, e^{-(2n+1)t} \, dt \\ &= - \sum_{n=0}^{\infty} \frac{(-1)^{n}}{(2n+1)^{2}} = - G, \end{align*}

where $G$ is the Catalan constant.

Therefore we have

$$\int_{0}^{\infty} \frac{\log (x + 1)}{x^2 + 1} \, dx = \frac{\pi}{4} \log 2 + G.$$

• Well done. +1.  – Potato May 19 '13 at 20:29
• hii ... could we do this via contour? – Mula Ko Saag May 21 '13 at 7:59

In this answer, the substitution $x=\frac{1-y}{1+y}$ is used to get $$\int_0^1\frac{\log(1+x)}{1+x^2}\mathrm{d}x=\frac\pi8\log(2)\tag{1}$$ We can use the substitution $x\mapsto1/x$ to get \begin{align} \int_1^\infty\frac{\log(1+x)}{1+x^2}\mathrm{d}x =\int_0^1\frac{\log(1+x)-\log(x)}{1+x^2}\mathrm{d}x\tag{2} \end{align} which implies $$\int_0^\infty\frac{\log(1+x)}{1+x^2}\mathrm{d}x =2\int_0^1\frac{\log(1+x)}{1+x^2}\mathrm{d}x-\int_0^1\frac{\log(x)}{1+x^2}\mathrm{d}x\tag{3}$$ Therefore, we can use \begin{align} \int_0^1x^k\log(x)\,\mathrm{d}x &=\frac1{k+1}\int_0^1\log(x)\,\mathrm{d}x^{k+1}\\ &=-\frac1{k+1}\int_0^1x^{k+1}\,\mathrm{d}\log(x)\\ &=-\frac1{k+1}\int_0^1x^k\,\mathrm{d}x\\ &=-\frac1{(k+1)^2}\tag{4} \end{align} to get \begin{align} \int_0^\infty\frac{\log(1+x)}{1+x^2}\mathrm{d}x &=2\int_0^1\frac{\log(1+x)}{1+x^2}\mathrm{d}x-\int_0^1\frac{\log(x)}{1+x^2}\mathrm{d}x\\ &=\frac\pi4\log(2)-\int_0^1\sum_{k=0}^\infty(-1)^kx^{2k}\log(x)\,\mathrm{d}x\\ &=\frac\pi4\log(2)+\sum_{k=0}^\infty\frac{(-1)^k}{(2k+1)^2}\\[4pt] &=\frac\pi4\log(2)+\mathrm{G}\tag{5} \end{align}


Hereafter we'll show a $\quad\color{#888}{\large\ds{\tt\ul{\mbox{simple and quite short}}}}\quad$ evaluation.

With $\ds{x \equiv \tan\pars{\theta}}$: \begin{align} \color{#00f}{\large\int_{0}^{1}{\ln\pars{x + 1} \over x^{2} + 1}\,\dd x}&= \int_{0}^{\pi/4}\ln\pars{\tan\pars{\theta} + 1}\,\dd\theta \\[3mm]&=\half\,\bracks{\int_{0}^{\pi/4}\ln\pars{\tan\pars{\theta} + 1}\,\dd\theta + \int_{0}^{\pi/4}\ln\pars{\tan\pars{{\pi \over 4} - \theta} + 1}\,\dd\theta} \\[3mm]&=\half\,\bracks{\int_{0}^{\pi/4}\ln\pars{\tan\pars{\theta} + 1}\,\dd\theta + \int_{0}^{\pi/4} \ln\pars{{1 - \tan\pars{\theta} \over 1 + \tan\pars{\theta}} + 1}\,\dd\theta} \\[3mm]&=\half\,\bracks{\int_{0}^{\pi/4}\ln\pars{\tan\pars{\theta} + 1}\,\dd\theta + \int_{0}^{\pi/4}\ln\pars{2 \over 1 + \tan\pars{\theta}}\,\dd\theta} \\[3mm]&=\half\int_{0}^{\pi/4}\ln\pars{2}\,\dd\theta =\color{#00f}{\large{1 \over 8}\,\pi\ln\pars{2}} \end{align}

Let $$I(a)=\int_0^\infty\frac{\ln(1+at)}{1+t^2}dt.$$ Then $I(0)=0$ and \begin{eqnarray} I'(a)&=&\int_0^\infty\frac{t}{(1+at)(1+t^2)}dt\\ &=&\frac{1}{1+a^2}\int_0^\infty\left(\frac{a+t}{1+t^2}-\frac{a}{1+at}\right)dt\\ &=&\frac{1}{2(1+a^2)}(2a\arctan t-2\ln(1+at)+\ln(1+t^2))\bigg|_{0}^\infty\\ &=&\frac{a\pi-2\ln a}{2(1+a^2)}. \end{eqnarray} So we have $$I(1)=\int_0^1\frac{a\pi-2\ln a}{2(1+a^2)}da=\frac{\pi}{4}\ln2+G$$ where wu use $$\int_0^1\frac{\ln a}{1+a^2}da=-G.$$

I realize this is an ancient post, but I thought it may be fun to try and evaluate this one using contours. It is not the most efficient method, but what the heck. It's about the challenge. I have not seen this one on the site done using contours, so I have been picking at it. Ron G?. where were ya', buddy :)

First, let's try splitting it up.

$$\int_{0}^{\infty}\frac{\log(x+1)}{x^{2}+1}dx=\int_{0}^{1}\frac{\log(x+1)}{x^{2}+1}dx+\int_{1}^{\infty}\frac{\log(x)}{x^{2}+1}dx+\int_{1}^{\infty}\frac{\log(1+1/x)}{x^{2}+1}dx$$

Note that the second one on the right will be used as a lemma since it evaluates to $$G, \;\ \text{the Catalan}$$.

The last integral can be shown to equal the first by a simple sub $$u=1/x$$, so that:

$$\int_{0}^{\infty}\frac{\log(x+1)}{x^{2}+1}dx=\int_{0}^{1}\frac{\log(x)}{x^{2}+1}dx+2\int_{0}^{1}\frac{\log(x+1)}{x^{2}+1}dx...........(1)$$

The idea is to evaluate $$\int_{0}^{1}\frac{\log(x+1)}{x^{2}+1}dx$$ via residues and use the catalan integral as a lemma, thus obtaining the result. Now, to show that

$$\int_{0}^{1}\frac{\log(x+1)}{x^{2}+1}dx=\frac{\pi}{8}\log(2)$$.

Use a quarter-circle in the first quadrant with a quarter circle indent around the pole at $i$. Thus avoiding the singularity at $x=-1$.

The first portion along the x-axis returns the integral in question by using $z=x$.

$1:$ $$\int_{0}^{1}\frac{\log(x+1)}{x^{2}+1}dx$$

$2$: Up along the arc, parameterize with $z=e^{it}, \;\ dz=ie^{it}dt$:

$$\int_{0}^{\frac{\pi}{2}}\frac{\log(1+e^{it})}{1+e^{2it}}ie^{it}dt$$

$3$: around the indent at $i$, parameterize with $z=i+\epsilon e^{i\phi}, \;\ dz=i\epsilon e^{i\phi}d\phi$

$$-\int_{-\frac{\pi}{2}}^{0}\frac{\log(1+i+\epsilon e^{i\phi})}{(i+\epsilon e^{i\phi})^{2}+1}i\epsilon e^{i\phi}d\phi$$

$4$: down the y-axis, parameterize with $z=iy, \;\ dz=idy$

$$-\int_{0}^{1}\frac{\log(1+iy)}{(iy)^{2}+1}idy$$

Now, some gymnastics are in order:

1 is OK the way it is. Maybe call it $I$.

2 can be whittled away at by using some identities such as:

$\log(1+e^{it})=1/2\log(2+2\cos(t))+\frac{it}{2}$ and $\frac{e^{it}}{1+e^{2it}}=1/2\sec(t)$

make these subs into 2:

$$i\int_{0}^{\infty}\frac{(1/2\log(2+2\cos(t))+\frac{it}{2})}{2\cos(t)}dt$$

$$=\frac{i}{4}\int_{0}^{\frac{\pi}{2}}\frac{\log(2+2\cos(t))}{\cos(t)}dt-1/4\int_{0}^{\frac{\pi}{2}}t\sec(t)dt$$

part 3 can be whittled at in order to get a contribution:

$$-\int_{\frac{-\pi}{2}}^{0}\frac{\log(1+i+\epsilon e^{i\phi})}{\epsilon^{2}e^{2i\phi}+2\epsilon ie^{i\phi}}i\epsilon e^{i\phi}d\phi$$

factor out $i\epsilon e^{i\phi}$, then let $\epsilon \to 0$:

$$-\int_{-\frac{\pi}{2}}^{0}\frac{\log(1+i+\epsilon e^{i\phi})}{i\epsilon e^{i\phi}(-\epsilon ie^{i\phi}+2)}i\epsilon e^{i\phi}d\phi$$

$$-\int_{-\frac{\pi}{2}}^{0}\frac{\log(1+i)}{2}d\phi=\frac{-\pi}{8}\log(2)-\frac{\pi^{2}}{16}i$$

part 4: $-ilog(1+iy)=\tan^{-1}(y)-\frac{i}{2}\log(y^{2}+1)$

$$-i/2\int_{0}^{1}\frac{\log(1+y^{2})}{1-y^{2}}dy+\int_{0}^{1}\frac{\tan^{-1}(y)}{1-y^{2}}dy$$

Now, finally, take the real parts of all of those portions.

The real parts are part 1, the real part of the integral evaluated in part 3, and the arctan integral from part 4:

since the pole was avoided, there are none inside the contour. Set all this to 0.

$$\int_{0}^{1}\frac{\log(x+1)}{x^{2}+1}dx-\int_{0}^{\frac{\pi}{2}}\frac{t}{4\cos(t)}dt-\frac{\pi}{8}\log(2)+\int_{0}^{1}\frac{\tan^{-1}(y)}{1-y^{2}}dy=0$$

The trick now is to cancel those two integrals. This will happen if they are the same. Yet, they are divergent. This may seem like one of Ron's "deus ex machina" tricks.

This can be shown by making the Weierstrass sub into $\int_{0}^{\frac{\pi}{2}}t\sec(t)dt$:

$y=\tan(t/2), \;\ \cos(t)=\frac{1-y^{2}}{1+y^{2}}, \;\ dt=\frac{2}{y^{2}+1}dy$

$$\int_{0}^{1}\frac{2\tan^{-1}(y)}{4\left(\frac{1-y^{2}}{1+y^{2}}\right)}\cdot \frac{2}{y^{2}+1}dy=\int_{0}^{1}\frac{\tan^{-1}(y)}{1-y^{2}}dy$$

Thus, they are equivalent and can be cancelled.

All that remains is the $$\int_{0}^{1}\frac{\log(x+1)}{x^{2}+1}dx-\frac{\pi}{8}\log(2)=0$$

Combining this with the Catalan/log integral in $(1)$ up top, and the other integral of the form just done, the final result is:

$$\int_{0}^{\infty}\frac{\log(x+1)}{x^{2}+1}dx=\int_{0}^{1}\frac{\log(x)}{x^{2}+1}dx+2\int_{0}^{1}\frac{\log(x+1)}{x^{2}+1}dx$$

$$\int_{0}^{\infty}\frac{\log(x+1)}{x^{2}+1}dx=G+2\left(\frac{\pi}{8}\log(2)\right)$$

$$\boxed{\frac{\pi}{4}\log(2)+G}$$

I will propose a solution using Feynman's trick. Let $$f(\alpha)=\int_0^\infty \frac{\log(1+\alpha x)}{1+x^2}\ dx$$ where $f(1)$ is the integral we seek to evaluate. By differentiation under the integral sign we have $$f'(\alpha)=\int_0^\infty\frac{\partial}{\partial\alpha}\frac{\log(1+\alpha x)}{1+x^2}\ dx\\ =\int_0^\infty \frac{x}{(1+x^2)(1+\alpha x)}\ dx.$$

Now we apply partial fraction decomposition: suppose that $$\frac{x}{(1+x^2)(1+\alpha x)}=\frac{Ax+B}{1+x^2}+\frac{C}{1+\alpha x}$$ for some constants $A,B,C$. By combining the fractions and collecting the terms we obtain the linear system of equations $$\begin{cases}A+\alpha B=1\\ \alpha A+C=0\\B+C=0\end{cases}$$ which we easily find to be equivalent to $$\begin{cases}A=\frac{1}{1+\alpha^2}\\B=\frac{\alpha}{1+\alpha^2}\\C=-\frac{\alpha}{1+\alpha^2}\end{cases}$$ From this we conclude that $$f'(\alpha)=\int_0^\infty \frac{Ax+B}{1+x^2}+\frac{C}{1+\alpha x}\ dx\\ =\left[\frac12 A\log(1+x^2)+B\arctan{x}+\frac{C}{\alpha}\log(1+\alpha x)\right]_{x=0}^\infty\\ =\frac\pi2 \frac{\alpha}{1+\alpha^2}-\frac{\log{\alpha}}{1+\alpha^2}$$ It is easy to see by looking at the definition that $f(0)=0$. From this it follows that $f(\alpha_0)=\int_0^{\alpha_0} f'(\alpha)\ d\alpha$, and in particular $$f(1)=\int_0^1 \frac\pi2 \frac{\alpha}{1+\alpha^2}-\frac{\log{\alpha}}{1+\alpha^2}\ d\alpha\\ =\frac{\pi}{2}\left[\frac12 \log(1+\alpha^2)\right]_{\alpha=0}^1-\int_0^1 \frac{\log \alpha}{1+\alpha^2}\ d\alpha\\ = \frac{\pi}{4}\log2+G$$ as desired.