Evaluating $\int_{-\infty}^{\infty}\frac{\ln\left(\frac{1}{2}+x+x^{2}\right)}{1+x^{2}}dx$

calculuscomplex-analysiscontour-integrationimproper-integralsintegration

(Motivation) This is an integral I made up for fun. WolframAlpha doesn't seem to come up with a closed form for it and I'm surprised there doesn't seem to be a duplicate after using Approach0, but I believe it equals

$$\pi\ln\left(\frac{5}{2}\right)$$

(Question) Since there seems to be a nice-looking closed form, could there be a cooler or more elegant way of solving this other than my attempt below?

If anyone is willing to look over my attempt and provide constructive criticism, I would greatly appreciate it as someone who seeks to expand his skills in complex analysis.

(Attempt) Let $f(z) = \displaystyle\frac{\log(1/2+z+z^2)}{1+z^2}$. Its poles are $z \in \left\{i,-i\right\}$ and its branch points are $\displaystyle z \in \left\{-\frac{1}{2}+\frac{i}{2}, -\frac{1}{2}-\frac{i}{2}\right\}$. For simplicity's sake, let $\displaystyle z_a = -\frac{1}{2}+\frac{i}{2}$ and $\displaystyle z_b = -\frac{1}{2}-\frac{i}{2}$. With these, we can rewrite $f(z)$ as
$$
\begin{align}
\frac{\log\left(\frac{1}{2}+z+z^{2}\right)}{1+z^{2}} &= \frac{\log\left(\left(z-z_{a}\right)\left(z-z_{b}\right)\right)}{1+z^{2}} \\
&= \frac{1}{1+z^{2}}\left(\log\left(\left|z-z_{a}\right|\cdot\left|z-z_{b}\right|\right)+i\operatorname{arg}\left(\left(z-z_{a}\right)\left(z-z_{b}\right)\right)\right) \\
&= \frac{1}{1+z^{2}}\left(\log\left|z-z_{a}\right|+\log\left|z-z_{b}\right|+i\operatorname{arg}\left(z-z_{a}\right)+i\operatorname{arg}\left(z-z_{b}\right)\right).
\end{align}
$$

But for the equalities to hold, define $\displaystyle \operatorname{arg}(z-z_a) \in \left(\frac{3\pi}{4},\frac{11\pi}{4}\right)$ and $\displaystyle \operatorname{arg}(z-z_b) \in \left(-\frac{11\pi}{4},-\frac{3\pi}{4}\right)$. Here is a visual of the keyhole contour.

Keyhole Contour

By Cauchy's Residue Theorem, we get

$$2\pi i \operatorname{Res}(f(z),z=i) = \left(\int_{-R}^{R}+\int_{\Gamma}+\int_{\lambda_1}+\int_{\gamma}+\int_{\lambda_2}\right)f(z)dz.$$
(I forgot to put this in the picture, but $\gamma$ has a small radius $r$ and the gaps between the branch cut and the $\lambda$s have a small length of $\epsilon$).

As $R \to \infty$ and $r \to 0$, it can be proved that $\displaystyle \int_{\Gamma}f(z)dz$ and $\displaystyle \int_{\gamma}f(z)dz$ go to $0$.

For the contour integrals over $\lambda_1$ and $\lambda_2$, let them approach the branch cut $\Lambda$. So
$$
\begin{align}
& \lim_{R \to \infty}\lim_{\lambda_1, \lambda_2 \to \Lambda}\left(\int_{\lambda_1} + \int_{\lambda_2}\right)f(z)dz \\
=& \lim_{R \to \infty}\lim_{\epsilon \to 0}\int_{Rz_{a}}^{z_{a}}f\left(z+i\epsilon\right)d\left(z+i\epsilon\right) + \lim_{R \to \infty}\lim_{\epsilon \to 0}\int_{z_{a}}^{Rz_{a}}f\left(z-i\epsilon\right)d\left(z-i\epsilon\right) \\
=& \lim_{R \to \infty}\lim_{\epsilon \to 0}\int_{Rz_{a}}^{z_{a}}\frac{d\left(z+i\epsilon\right)}{1+\left(z+i\epsilon\right)^{2}}\left(\log\left|z+i\epsilon-z_{a}\right|+\log\left|z+i\epsilon-z_{b}\right|+i\operatorname{arg}\left(z+i\epsilon-z_{a}\right)+i\operatorname{arg}\left(z+i\epsilon-z_{b}\right)\right) \\
&+ \lim_{R \to \infty}\lim_{\epsilon \to 0}\int_{Rz_{a}}^{z_{a}}\frac{d\left(z-i\epsilon\right)}{1+\left(z-i\epsilon\right)^{2}}\left(\log\left|z-i\epsilon-z_{a}\right|+\log\left|z-i\epsilon-z_{b}\right|+i\operatorname{arg}\left(z-i\epsilon-z_{a}\right)+i\operatorname{arg}\left(z-i\epsilon-z_{b}\right)\right) \\
=& -\int_{z_a}^{i\infty}\frac{dz}{1+z^2}\left(\log\left|z-z_{a}\right|+\log\left|z-z_{b}\right|+\frac{11\pi i}{4}+i\operatorname{arg}\left(z-z_{b}\right)\right) \\
&+ \int_{z_a}^{i\infty}\frac{dz}{1+z^2}\left(\log\left|z-z_{a}\right|+\log\left|z-z_{b}\right|+\frac{3\pi i}{4}+i\operatorname{arg}\left(z-z_{b}\right)\right) \\
=& -2\pi i \int_{z_a}^{i\infty}\frac{dz}{1+z^2} \\
&= i\pi\left(\frac{\pi}{2}+\arctan\left(\frac{1}{2}\right)\right)-\frac{\pi}{2}\ln\left(5\right). \\
\end{align}
$$

Next, we will evaluate the residue at the simple pole $z=i$ like this:

$$2\pi i \operatorname{Res}(f(z),z=i) = 2\pi i \lim_{z \to i}\frac{\left(z-i\right)\log\left(\frac{1}{2}+z+z^{2}\right)}{\left(z-i\right)\left(z+i\right)} = \pi\ln\left(\frac{\sqrt{5}}{2}\right)+i\pi\left(\frac{\pi}{2}+\arctan\left(\frac{1}{2}\right)\right).$$

Gathering everything together and taking the appropriate limits, we get

$$\pi\ln\left(\frac{\sqrt{5}}{2}\right)+i\pi\left(\frac{\pi}{2}+\arctan\left(\frac{1}{2}\right)\right) = \int_{-\infty}^{\infty}f\left(x\right)dx + 0 + i\pi\left(\frac{\pi}{2}+\arctan\left(\frac{1}{2}\right)\right)-\frac{\pi}{2}\ln\left(5\right) + 0.$$

In conclusion,

$$\int_{-\infty}^{\infty}\frac{\ln\left(\frac{1}{2}+x+x^{2}\right)}{1+x^{2}}dx = \pi\ln\left(\frac{5}{2}\right).$$

Best Answer

A simpler method using contour integration:

$$\begin{align} \int_{-\infty}^{\infty} \frac{\ln\left(\frac{1}{2}+x+x^{2}\right)}{1+x^{2}} \, \mathrm dx &= 2 \, \Re \int_{-\infty}^{\infty} \frac{\ln \left(x+ \frac{1}{2} + \frac{i}{2} \right)}{1+x^{2}} \, \mathrm dx\\ &= 2 \, \Re \left( 2 \pi i \operatorname{Res} \left[\frac{\ln \left(z+ \frac{1}{2}+\frac{i}{2}\right)}{1+z^{2}}, i \right] \right) \\ &= 2 \, \Re \left(\pi \ln\left( \frac{3i}{2}+ \frac{1}{2} \right)\right) \\ &= 2 \pi \ln \left(\sqrt{\frac{10}{4}} \right) \\ &= \pi \ln \left(\frac{5}{2} \right) \end{align}$$