Big trouble in evaluating an Improper integral in complex analysis I am having trouble in evaluating $\int_{0}^\infty \left(\frac{\log(x^2+1)}{x^2+1}\right)dx$.
I proceeded by taking  $\int_{C}\left(\frac{\log(z+i)}{z^2+1}\right)dz$. I don't know how to draw contour here and my attempt lies in that. I could show that $\lim_{R\to\infty}\int_{C_R}\left(\frac{\log(z+i)}{z^2+1}\right)dz=0$, but I couldn't show that $\lim_{r\to 0}\int_{\tau_R}\left(\frac{\log(z+i)}{z^2+1}\right)dz=0$.Please help me through this problem.
I'll appreciate any help towards this.
PS:
$C=[R,r]\cup \{-\tau_{r}\} \cup [r,R] \cup C_{R}$, [considering counterclockwise sense] the branch cut that I used was $[-\pi/2,3\pi/2]$
 A: Let's work with what you've got. $\log{(z+i)}$ has a singularity at $z=-i$, and we can see that this is a branch point since the function looks like $\log{\varepsilon}$ there. The initial chunk of the contour we have passes along the real axis, so it is sensible to choose a branch cut for $\log{(z+i)}$ which does not intersect this. We may as well choose the part of the imaginary axis below $-i$: $\{ iy: y \leqslant -1 \}$, but any unbounded simple curve not crossing the real axis will do.
Now, there is the question of specifying the branch, which is equivalent to choosing the value of $\log{i}$: the value of $\log{(z+i)}$ at $z=0$. Since $e^{i\pi(2n+1/2)} = i $, this could be any of the values $\left(2n+\frac{1}{2}\right)\pi i$. Choose a specific $n$ and stick with it.
Okay, we've sorted our function. Now let's sort out a contour. It should be clear that whatever the branch,
$$ \frac{\log{(z+i)}}{z^2+1} = o(\lvert z\rvert^{-3/2}), $$
say, as $\lvert z \rvert \to \infty$, for any sequence of $z$ not going near the branch cut (probably don't need this restriction, but never mind). Therefore, we can sensibly close the contour in the upper half-plane, by considering $\gamma=\gamma_1+\gamma_2$, where $\gamma_1=[-R,R]$, and $\gamma_2=\{ Re^{it}: 0<t<\pi \}$, a semicircle in the upper half-plane centred at $0$.
Right, everything's set; now the residue theorem,
$$ \int_{\gamma} \frac{\log{(z+i)}}{z^2+1} \, dz = 2\pi i \sum_{a \text{ inside }\gamma} \operatorname{Res}_{z=a}\frac{\log{(z+i)}}{z^2+1} $$
As far as the left-hand side goes, $\int_{\gamma}=\int_{\gamma_1}+\int_{\gamma_2}$. We have $\int_{\gamma_1} \to I$, where
$$ I = \int_{-\infty}^{\infty} \frac{\log{(x+i)}}{x^2+1} \, dx, $$
where $x$ is used because the integral variable is real. We'll sort that out at the end. $\int_{\gamma_2} \to 0$ as $R \to \infty$ since the integrand is bounded above by a multiple of $R^{-3/2}$, and the length of the contour by $\pi R$, so the integral tends to zero by the fundamental supremum bound.
For the right-hand side, there is only one singularity inside $\gamma$: a pole at $z=i$. This has residue
$$ \lim_{z \to i} (z-i) \frac{\log{(z+i)}}{(z+i)(z-i)} = \frac{\log{2i}}{2i}, $$
and hence we have
$$  \int_{-\infty}^{\infty} \frac{\log{(x+i)}}{x^2+1} \, dx = \pi\log{2i} $$
Okay, now we need to relate this to the actual integral we are dealing with. On the left,
$$ \log{(x+i)} = \log{\sqrt{(x+i)(x-i)}} + i\theta = \frac{1}{2}\log{(1+x^2)} +i\theta, $$
where $\theta$ is the angle of $x+i$ to the positive real axis ($\arctan{x}$?), plus $2n\pi i$ so as to be on the correct branch of the logarithm. Thus
$$ \frac{1}{2}\int_{-\infty}^{\infty} \frac{\ln{(1+x^2)}+i\theta}{x^2+1} \, dx = \pi\log{2i} = \pi\ln{2}+\pi[(2n+1/2)\pi] i, $$
where I write $\ln$ (under protest) to mean the logarithm that is real-valued on the positive real axis, as in $\log{z} = \ln{\lvert z \rvert}+i\theta$.
Equating real parts gives the result you want,
$$ \frac{1}{2}\int_{-\infty}^{\infty} \frac{\ln{(1+x^2)}}{x^2+1} \, dx =\pi\ln{2}. $$
What about the imaginary parts? Well, $\theta = (2n+1/2)\pi + f(x)$, where $f$ is odd (think about how the angle works), so the integral of $f$ divided by the even $1+x^2$ is zero. For the rest, we find
$$ (2n+1/2)\pi \int_{-\infty}^{\infty} \frac{dx}{1+x^2} = (2n+1/2)\pi \times \pi \\
\int_{-\infty}^{\infty} \frac{dx}{1+x^2} = \pi, $$
which

*

*We knew already, and

*Shows that it didn't matter what branch/value of $n$ we chose.

