Improper integral of $\frac{\log\left(\sqrt{x^2+a^2}\right)}{x^2+b^2}$

It's easy to see that your integral is the same as $$ I(a) = \int_0^{\infty} \frac{\log{(x^2+a^2)}}{x^2+b^2} \, dx $$ Now, we can do the case $a=0$ fairly easily, by setting $x=b^2/y$: $$ \begin{align} I(0) &= 2\int_0^{\infty} \frac{\log{x}}{x^2+b^2} \, dx \\ &= 2\int_0^{\infty} \frac{\log{(b^2/y)}}{b^2/y^2+b^2} \frac{b}{y^2} \, dy \\ &= 2\int_0^{\infty} \frac{2\log{b}-\log{y}}{y^2+b^2} \, dy \\ &= 4\log{b} \int_0^{\infty} \frac{dy}{y^2+b^2} -I(0), \end{align} $$ so $$ I(0) = \frac{\pi}{b}\log{b}. $$ To get from here to nonzero $a$, differentiate under the integral sign: $$ I'(a) = \int_0^{\infty}\frac{\partial}{\partial a} \frac{\log{(x^2+a^2)}}{x^2+b^2} \, dx = \int_0^{\infty} \frac{2a \, dx}{(x^2+a^2)(x^2+b^2)} $$ But this is easy to calculate using partial fractions: we find $$ I'(a) = \frac{2a\pi}{2(b^2-a^2)} \left( \frac{1}{a} - \frac{1}{b} \right) = \frac{\pi}{b(a+b)} $$ Now $$ I(a) = I(0) + \int_0^{a} \frac{\pi}{b(A+b)}\, dA = \frac{\pi}{b}(\log{(b+a)}-\log{b}+\log{b}) = \frac{\pi}{b}\log{(a+b)}, $$ as desired.


A complex analysis method will work in the same way as that given in this answer, although the pole is in a different place from the branch point in your case, rather than coincident.


Suppose $a \gt b$ for now. Consider the contour integral in the complex plane

$$\oint_C dz \frac{\log{\left ( z^2+a^2 \right )}}{z^2+b^2} $$

where $C$ is a semicircle of radius $R$ in the upper half-plane with a detour down and up the imaginary axis about the branch point $z=i a$. In the limit as $R \to \infty$, the contour integral is equal to

$$\int_{-\infty}^{\infty} dx \frac{\log{\left ( x^2+a^2 \right )}}{x^2+b^2} + i \int_{\infty}^a dy \frac{\log{\left ( y^2-a^2 \right )}+i \pi}{b^2-y^2} + i \int_a^{\infty} dy \frac{\log{\left ( y^2-a^2 \right )}-i \pi}{b^2-y^2}$$

Note that the log terms in the latter two integrals vanish. Now, the contour integral is also equal to the residue of the pole of the integrand at $z=i b$. Thus

$$\int_{-\infty}^{\infty} dx \frac{\log{\left ( x^2+a^2 \right )}}{x^2+b^2} - 2 \pi \int_a^{\infty} \frac{dy}{y^2-b^2} = i 2 \pi \frac{\log{\left ( a^2-b^2 \right )}}{i 2 b} $$

Accordingly, after doing out that second integral and performing a little algebra, we get...

$$\frac12 \int_{-\infty}^{\infty} dx \frac{\log{\left ( x^2+a^2 \right )}}{x^2+b^2} = \frac{\pi}{b} \log{\left ( a+b \right )} $$

ADDENDUM

For $a \lt b$, the answer is the same as above but the contour is altered. This time, the contour $C$ must detour about the pole at $z=i b$ along each side of the branch cut with a semicircle of radius $\epsilon$. The contour integral is this equal to

$$\int_{-\infty}^{\infty} dx \frac{\log{\left ( x^2+a^2 \right )}}{x^2+b^2} + i PV \int_{\infty}^a dy \frac{\log{\left ( y^2-a^2 \right )}+i \pi}{b^2-y^2} + i PV \int_a^{\infty} dy \frac{\log{\left ( y^2-a^2 \right )}-i \pi}{b^2-y^2} \\ + i \epsilon \int_{\pi/2}^{-\pi/2} d\phi \, e^{i \phi} \frac{\log{\left [- \left (i b + \epsilon e^{i \phi} \right )^2-a^2 \right ]}+i \pi}{\left (i b + \epsilon e^{i \phi} \right )^2+b^2}+ i \epsilon \int_{3 \pi/2}^{\pi/2} d\phi \, e^{i \phi} \frac{\log{\left [ -\left (i b + \epsilon e^{i \phi} \right )^2-a^2 \right ]}-i \pi}{\left (i b + \epsilon e^{i \phi} \right )^2+b^2}$$

Note that the sum of the two final integrals - the pieces that go around the pole - is equal to the residue of the pole at $z=i b$ in the limit as $\epsilon \to 0$. The $\pm i \pi$ pieces cancel. Also note that the principal value integrals are the same as the corresponding integrals above for $a \gt b$. Thus, the result for $a \lt b$ is the same as that for $a \gt b$.