# Using complex method to evaluate $\int_0^\infty\frac{\ln(1+x)}{1+x^2}dx$

Evaluate$$I=\int_0^\infty\frac{\ln(1+x)}{1+x^2}dx$$ I know the answer and other methods to solve this integral. I want to know what is wrong with my attempt.
Let $f(z)=\frac{\ln(1+z)\ln z}{1+z^2}$, where $\Im\ln(1+z)\in(-\pi,\pi]$ and $\Im \ln z\in[0,2\pi)$.
Take the "keyhole contour" $C=C_+\cup C_R\cup C_-\cup C_r$.
Edit: $C_+$: the upside of the positive real axis, $C_-$: the downside of the positive real axis, $C_R$: big circle around the origin, $C_r$: small circle around the origin.
$$\int_Cf(z)dz=2\pi i(\operatorname{Res}_{z=i}f(z)+\operatorname{Res}_{z=-i}f(z))=\frac12\pi^2 i(\ln(1+i)-3\ln(1-i))$$ As $r\to 0$ and $R\to\infty$, $\int_{C_R}f(z)dz$ and $\int_{C_r}f(z)dz$ vanish.
$$(\int_{C_+}+\int_{C_-})f(z)dz=\int_0^\infty\frac{\ln(1+x)}{1+x^2}(\ln x+2\pi i-\ln x)dx$$ Hence I get $$I=\frac{1}{2\pi i}(\int_{C_+}+\int_{C_-})f(z)dz=\frac14\pi(\ln(1+i)-3\ln(1-i))$$ which is wrong.

• Can you describe the contour in detail? (starting from where? ending where?) – Szeto Jul 7 '18 at 10:43
• @Szeto I haven't looked at the problem closely, it seems like he hasn't really defined the bounds of the Contour, and also how does he know that: $$I=\frac{1}{2\pi i}(\int_{C_+}+\int_{C_-})f(z)dz=\frac14\pi(\ln(1+i)-3\ln(1-i))$$ is incorrect ? – Zophikel Jul 7 '18 at 12:11
• @Zophikel In addition, I found it difficult to apply residue theorem directly, as the integration limits are not at the branch points. – Szeto Jul 7 '18 at 14:27
• @Szeto i've been studying Contour Integrals for a while know and it dosen't seem like one can integrate around the contour without using the Residue Theorem – Zophikel Jul 7 '18 at 14:43
• Possible duplicate of Contour method to solve $\int^\infty_0\frac{\ln(1+x)}{1+x^2}\,dx$. Not sure whether this addresses the askers problem, but I want to pre-empt reproductions of old answers here. Also. – Jyrki Lahtonen Jul 8 '18 at 7:37

One problem with the solution in the question is that the difference between $\log(1+z)\log(z)$ above and below the branch cut is not $2\pi i\log(1+z)$ because $$(\log(1+z)+2\pi i)(\log(z)+2\pi i)-\log(1+z)\log(z)=2\pi i(\log(1+z)+\log(z))-4\pi^2$$

Felix Marin gives a contour integration solution in this answer, so I will give a real variable solution here. \begin{align} &\int_0^\infty\frac{\log(1+x)}{1+x^2}\,\mathrm{d}x\tag1\\ &=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\tag2\\ &=2\int_0^{\pi/4}\log(1+\tan(x))\,\mathrm{d}x-\int_0^1\sum_{k=0}^\infty(-1)^kx^{2k}\log(x)\,\mathrm{d}x\tag3\\ &=2\int_0^{\pi/4}\log(\cos(x)+\sin(x))\,\mathrm{d}x-2\int_0^{\pi/4}\log(\cos(x))\,\mathrm{d}x+\sum_{k=0}^\infty\frac{(-1)^k}{(2k+1)^2}\tag4\\ &=2\int_0^{\pi/4}\log(\sqrt2\cos(\pi/4-x))\,\mathrm{d}x-2\int_0^{\pi/4}\log(\cos(x))\,\mathrm{d}x+G\tag5\\[6pt] &=\frac\pi4\log(2)+G\tag6 \end{align} Explanation:
$(2)$: $\int_1^\infty\frac{\log(1+x)}{1+x^2}\,\mathrm{d}x\overset{x\mapsto1/x}=\int_0^1\frac{\log(1+x)-\log(x)}{1+x^2}\,\mathrm{d}x$
$(3)$: substitute $x\mapsto\tan(x)$ on left and use Taylor series on the right
$(4)$: $1+\tan(x)=\frac{\cos(x)+\sin(x)}{\cos(x)}$ and $\int_0^1x^k\log(x)\,\mathrm{d}x=\frac1{(k+1)^2}$
$(5)$: cosine of a difference and definition of Catalan's Constant
$(6)$: cancellation$\vphantom{\sum\limits_{k=0}^\infty}$

Edit: I thought I had answered this before, but I couldn't find my previous answer until I noticed Jyrki's "Also" link. This solution is close, but has a difference in computing $\int_0^1\frac{\log(1+x)}{1+x^2}\,\mathrm{d}x$.

• But I used $\Im \ln(1+z)\in(-\pi,\pi]$. The branch cut of $\ln(1+z)$ is on the left side of the complex plane. I think the main problem of my solution is not considering the branch cut of $\ln(1+z)$. – Kemono Chen Jul 12 '18 at 9:35
• @LittleCuteKemono: That branch cut and $C_R$ intersect; they are not allowed to do so. – robjohn Jul 12 '18 at 12:32