Integral $\int_0^\infty\Big[\log\left(1+x^2\right)-\psi\left(1+x^2\right)\Big]dx$

This can be done by a kind of residue calculation. First of all by parity the integral is $\frac12 \int_{-\infty}^{\infty}$. Considering this as a contour integral in the $x$-plane, we would like to pull the contour to $i\infty$. There will be two obstacles:

  • an infinite number of poles of $\psi(x)$ given by $x_n=i\sqrt n$ with $n=1,2,3,\ldots$ Note that $$\operatorname{res}_{x=x_n}\psi\left(1+x^2\right)=\color{blue}{\frac{i}{2\sqrt n}}$$

  • a logarithmic branch cut $(i,i\infty)$ of the function $\ln(1+x^2)$. Note that on this branch cut the logarithm jumps by $\color{red}{2\pi i}$.

So we deform the contour to the following: a horizontal ray $r_L=(-\infty+i\sqrt N,-0+i\sqrt N)$, a contour $C$ going counterclockwise around the logarithmic branch cut from $-0+i\sqrt N$ to $-0+i\sqrt N$, and another horizontal ray $r_R=(+0+i\sqrt N,\infty+i\sqrt N)$. Now we have $$\int_C= \color{red}{2\pi i} \cdot i \left(\sqrt N-1\right)-2\pi i\sum_{1\leq n<N} \color{blue}{\frac i{2\sqrt n}}=\pi\left[2+\sum_{1\leq n<N}\frac1{\sqrt n}-2\sqrt{N}\right].$$ Using the known asymptotic behavior $\psi(z\to\infty)=\ln z+\frac1{2z}+O\left(z^{-2}\right)$, we can show that integrals over the rays $r_L$ and $r_R$ vanish in the limit $N\to\infty$.

Therefore the integral we are interested in is equal to $$\mathcal I=\frac12\lim_{N\to\infty}\int_C=\pi+\frac{\pi}{2}\lim_{N\to\infty}\left[\sum_{1\leq n<N}\frac1{\sqrt n}-2\sqrt{N}\right].$$ Finally, that the remaining limit is equal to $\zeta\left(\frac12\right)$ can be shown relatively easily: see, for instance, this approach.


Choi and Srivastava list a rather obscure, but useful, series:

$$\psi(x)-\log(x)=\sum_{k=0}^{\infty}\left(\log\left(1+\frac{1}{x+k}\right)-\frac{1}{x+k}\right)\tag{1}$$

Let $x\to x^{2}+1$, then we have:

$$\log(x^{2}+1)-\psi(x^{2}+1)=-\sum_{k=0}^{\infty}\left(\log\left(1+\frac{1}{x^{2}+k+1}\right)-\frac{1}{x^{2}+k+1}\right)$$

$$\int_{0}^{\infty}\left(\log(x^{2}+1)-\psi(x^{2}+1)\right)dx=-\int_{0}^{\infty}\sum_{k=0}^{\infty}\left(\log\left(1+\frac{1}{x^{2}+k+1}\right)-\frac{1}{x^{2}+k+1}\right)$$

Assuming one may can switch integral and sum:

$$\int_{0}^{\infty}\left(\log(x^{2}+1)-\psi(x^{2}+1)\right)dx=-\sum_{k=0}^{\infty}\int_{0}^{\infty}\left(\log\left(1+\frac{1}{x^{2}+k+1}\right)-\frac{1}{x^{2}+k+1}\right)$$

$$=-\frac{\pi}{2}\sum_{k=0}^{\infty}\frac{2\sqrt{k+1}\sqrt{k+2}-(2k+3)}{\sqrt{k+1}}\tag{2}$$

I admit I did not evaluate it manually (EDIT: I added some stuff below), but tech showed that the sum converges to $$-\zeta(1/2)-2$$

Thus, we finally have:

$$\frac{-\pi}{2}\left(-\zeta(1/2)-2\right)=\frac{\pi}{2}\zeta(1/2)+\pi$$

and

$$\int_{0}^{\infty}\left(\log(x^{2}+1)-\psi(x^{2}+1)\right)dx=\frac{\pi}{2}\zeta(1/2)+\pi$$

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

more on (1):

Begin with the Gamma identity: $$\Gamma(1+x)=\left(\frac{x}{e}\right)^{x}\prod_{k=0}^{\infty}\frac{\left(1+\frac{1}{x+k}\right)^{x+k}}{\left(1+\frac{1}{k}\right)^{k}}$$

log both sides of (1):

$$\log\Gamma(x+1)=x\log(x)-x+\sum_{k=0}^{\infty}\left[(x+k)\log\left(1+\frac{1}{x+k}\right)-k\log\left(1+\frac{1}{k}\right)\right]$$

diff both sides:

$$\psi(x+1)=\log(x)+\sum_{k=0}^{\infty}\left[\log\left(1+\frac{1}{x+k}\right)-\frac{1}{x+k+1}\right]$$

Thus, $$\psi(x)=\log(x)+\sum_{k=0}^{\infty}\left[\log\left(1+\frac{1}{x+k}\right)-\frac{1}{x+k}\right]$$

also, note $\lim_{n\to \infty}\left[\psi(x)-\log(x)\right]=0$

more on (2):

Partial N sums in terms of Zeta.

$$\lim_{N\to \infty}\sum_{k=0}^{N}\left(2\sqrt{k+2}-\frac{2k}{\sqrt{k+1}}-\frac{3}{\sqrt{k+1}}\right)\tag{3}$$

$$2\sum_{k=0}^{N}\sqrt{k+2}=-2\zeta\left(-1/2, N+3\right)+2\zeta(-1/2)-2\tag{4}$$

$$2\sum_{k=0}^{N}\frac{k}{\sqrt{k+1}}=\left[2\zeta(-1/2,N+2)+2\zeta(1/2,N+2)-2\zeta(1/2)+2\zeta(-1/2)\right]\tag{5}$$

$$3\sum_{k=0}^{N}\frac{1}{\sqrt{k+1}}=3\zeta(1/2)-3\zeta(1/2,N+2)\tag{6}$$

Put together (4), (5), (6) in accordance with (3). $\zeta(s,n)=\zeta(s)-\sum_{k=1}^{n-1}\frac{1}{k^{s}}$:

$$\begin{align}-2\zeta\left(-1/2, N+3\right)+2\zeta(-1/2)-2-\left[2\zeta(-1/2,N+2)+2\zeta(1/2,N+2)\\ -2\zeta(1/2)+2\zeta(-1/2)\right]-\left[3\zeta(1/2)-3\zeta(1/2,N+2)\right]\end{align}$$

$$=2\zeta(-1/2,N+2)-2\zeta(-1/2,N+3)+\zeta(1/2,N+2)-\zeta(1/2)-2\tag{7}$$

But, $ \;\ \;\ \;\ \begin{align}2\zeta(-1/2,N+2)-2\zeta(-1/2,N+3)=2\sqrt{N+2}\end{align}\\$

thus, (7) becomes:

$$2\sqrt{N+2}+\zeta(1/2,N+2)-\zeta(1/2)-2$$

and $$\lim_{N\to \infty}\left[2\sqrt{N+2}+\zeta(1/2,N+2)\right]=0$$

so all that remains is $$\boxed{-\zeta(1/2)-2}$$