An improper integral : $\int_{0}^\infty {\ln(a^2+x^2)\over{b^2+x^2}}dx$ How to evaluate the following improper integral:$$\int_{0}^\infty {\ln(a^2+x^2)\over{b^2+x^2}}dx,$$ where $a,b>0$.

I tried to suppose $$f(a)=\int_0^\infty {\ln(a^2+x^2)\over{b^2+x^2}}dx,$$ based on the convergence theorem, and then I tried $${df(a)\over da}=\int_0^\infty {2a\over {(a^2+x^2)(b^2+x^2)}}dx = {\pi\over b(b+a)},$$and then $$f(a)={\pi\over b}\ln(b+a)+C,$$where $C$ is a constant, but I don't know how to find the constant $C$. Could anyone tell me that, and explain why? Or could anyone find other methods to evaluate the integral? If you could, please explain. Thanks.
 A: Another approach using contour integration is to consider the function $$ f(z) = \frac{\ln(z+ia)}{b^{2}+z^{2}} \, , \quad  a, b >0.$$
Since the branch point of $f(z)$ is in the lower half-plane, we can integrate $f(z)$ around a contour consisting of the line segment $[-R,R]$ and the upper half of the circle $|z|=R$.
Letting $R \to \infty$, the integral vanishes along the upper half of the circle $|z|=R$.
So we have
$$ \begin{align} \int_{0}^{\infty} \frac{\ln(a^{2}+x^{2})}{b^{2}+x^{2}} \, dx &=  \text{Re}   \int_{-\infty}^{\infty} \frac{\ln(x+ia)}{b^{2}+x^{2} } \, dx \\ &= \text{Re}\,  \left( 2\pi i \ \text{Res}[f(z),ib] \right) \\ &= \frac{\pi}{b} \,   \ln(a+b)  . \end{align}$$
A: Let us assume for definiteness that $a> b>0$ and use parity to write the integral as
$$I=\frac12\int_{-\infty}^{\infty}\frac{\ln(a^2+x^2)}{b^2+x^2}dx.$$
In the complex $x$-plane, the integral has two poles $x=\pm i b$ and two logarithmic branch points $x=\pm ia$. We introduce two branch cuts running from these points to $\pm i\infty$, and deform the contour of integration trying to pull it to e.g. $i\infty$. The result will be determined by two contributions: 


*

*the residue at $x=ib$, equal to 
$$\frac12\cdot 2\pi i\cdot \frac{\ln(a^2-b^2)}{2ib}=\frac{\pi}{2b}\ln(a^2-b^2),$$

*the jump on the logarithmic branch cut emanating from $x=ia$, producing
$$-\frac12\cdot 2\pi  \int_{0}^{\infty}\frac{ds}{(a+s)^2-b^2}=-\frac{\pi}{2b}\ln\frac{a-b}{a+b}.$$
The sum of the two contributions gives
$$I=\frac{\pi}{b}\ln(a+b).$$
A: Based on your calculations we have 

$$f(a)={\pi\over b}\ln(b+a)+C\implies C=f(0)-{\pi\over b}\ln(b).$$

So, we need to find $f(0)$ which can be found using the original integral as

$$f(0)= 2\int_{0}^{\infty} \frac{\ln(x)}{b^2+x^2}dx.$$

To evaluate the last integral see here.
A: Since we have 
$$
\int_0^\infty\frac{\log(a^2+x^2)}{b^2+x^2}\mathrm{d}x=\frac\pi{b}\log(b+a)+C\tag{1}
$$
Let's look what happens when $a\to\infty$. Looking at the right side of $(1)$, we have
$$
\frac\pi{b}\log(b+a)+C
=\frac\pi{b}\log(a)+C+\frac\pi{b}\log(1+b/a)\tag{2}
$$
Looking at the left side of $(1)$, we have
$$
\frac1b\int_0^\infty\frac{\log(a^2+b^2x^2)}{1+x^2}\mathrm{d}x
=\frac\pi{b}\log(a)+\frac1b\int_0^\infty\frac{\log(1+b^2x^2/a^2)}{1+x^2}\mathrm{d}x\tag{3}
$$
Subtracting $(3)$ from $(2)$ yields
$$
C=\frac1b\int_0^\infty\frac{\log(1+b^2x^2/a^2)}{1+x^2}\mathrm{d}x-\frac\pi{b}\log(1+b/a)\tag{4}
$$
Dominated Convergence says that the integral on the right side of $(4)$ vanishes as $a\to\infty$ and $\frac\pi{b}\log(1+b/a)$ vanishes as well. Therefore, $C=0$.
A: $\newcommand{\+}{^{\dagger}}
 \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{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
$\ds{\int_{0}^{\infty}{\ln\pars{a^{2} + x^{2}} \over b^{2} + x^{2}}\,\dd x:
     \ {\large ?}}$

\begin{align}&\color{#c00000}{\int_{0}^{\infty}
{\ln\pars{a^{2} + x^{2}} \over b^{2} + x^{2}}\,\dd x}
=\Re\ \overbrace{\int_{-\infty}^{\infty}
{\ln\pars{\verts{a} + \ic x} \over b^{2} + x^{2}}\,\dd x}
^{\ds{\verts{a} + \ic x \equiv t\ \imp\ x = \pars{\verts{a} - t}\ic}}
\\[3mm]&=\Re\int_{\verts{a} -\infty\ic}^{\verts{a} + \infty\ic}
{\ln\pars{t} \over b^{2} + \bracks{\pars{\verts{a} - t}\ic}^{2}}
\,\pars{-\ic\,\dd t}
\\[3mm]&=-\Im\int_{\verts{a} -\infty\ic}^{\verts{a} + \infty\ic}
{\ln\pars{t} \over \bracks{t - \pars{\verts{a} - \verts{b}}}\bracks{t - \pars{\verts{a} + \verts{b}}}}\,\dd t
\end{align}

In order to perform the integration, we set the $\ds{\ln}$-branch cut along the negative semi-axis
$\ds{\pars{~\ln\pars{z} = \ln\pars{\verts{z}} + {\rm Arg}\pars{z}\ic\,,\quad z \not=0\,,\quad\verts{{\rm Arg}\pars{z}} < \pi~}}$ and close the contour to "the right"
$\ds{\pars{~t > \verts{a}~}}$.
It's closed with an radius $R$ arc
$\ds{~\braces{\pars{x,y}\ \mid\ \pars{x - \verts{a}}^2 + y^{2} = R^{2}\,,\quad
     x > \verts{a}}~}$. It's trivially checked that its contribution vanishes in the limit $\ds{R \to \infty}$ such that:
\begin{align}&\color{#66f}{\large\int_{0}^{\infty}
{\ln\pars{a^{2} + x^{2}} \over b^{2} + x^{2}}\,\dd x}
=-\Im\bracks{-2\pi\ic\,{{\ln\pars{\verts{a} + \verts{b}}} + 0\,\ic
\over \pars{\verts{a} + \verts{b}} - \pars{\verts{a} - \verts{b}}}}
\\[3mm]&=\color{#66f}{\large{\pi \over \verts{b}}\,
\ln\pars{\vphantom{\LARGE A}\verts{a} + \verts{b}}}
\end{align}
A: Letting $y=\frac{x}{b} $ yields
$$
\begin{aligned}
I &=b \int_0^{\infty} \frac{\ln \left(a^2+b^2 y^2\right)}{b^2+b^2 y^2} d y \\
&=\frac{1}{b} \int_0^{\infty} \frac{\ln \left(b^2 y^2+a^2\right)}{1+y^2} d y
\end{aligned}
$$
By my post,
$$
\begin{aligned}
\boxed{I =\frac{1}{b} \pi \ln \left(\sqrt{a^2}+\sqrt{b^2}\right)=\frac{\pi}{b} \ln (a+b)}
\end{aligned}
$$
