Calculate the value of $\int_0^\infty \frac{\sqrt{x}\cos(\ln(x))}{x^2+1}\,dx$

As @Adrian suggested, define $\log z =\log |z|+i\arg(z)$ where $\arg(z)\in (0,2\pi)$ and let the contour be a keyhole contour.
enter image description here

Then $$ \left|\int_{\gamma_R}\frac{e^{(1/2+i)\log z}}{z^2+1}\,dz\right|\le \int_{\gamma_R}\frac{e^{1/2 \log|z|-\arg(z)}}{R^2-1}\,|dz|\le C\frac{R^{3/2}}{R^2-1}\stackrel{R\to\infty}\longrightarrow 0, $$ $$ \left|\int_{\gamma_r}\frac{e^{(1/2+i)\log z}}{z^2+1}\,dz\right|\le \int_{\gamma_r}\frac{e^{1/2 \log|z|-\arg(z)}}{1-r^2}\,|dz|\le Cr^{3/2}\stackrel{r\to 0}\longrightarrow 0. $$ Thus it follows by residue theorem $$ \lim_{\epsilon\to 0}\left(\int_{\gamma_\epsilon} f(z)dz +\int_{\gamma_{-\epsilon}} f(z)dz\right) =2\pi i\left(\text{res}_{z=i}f(z)+\text{res}_{z=-i}f(z)\right). $$ We find$$ \lim_{\epsilon\to 0}\int_{\gamma_\epsilon} f(z)dz=\int_0^\infty \frac{\sqrt{x}e^{i\ln x}}{x^2+1}\,dx, $$ $$ \lim_{\epsilon\to 0}\int_{\gamma_{-\epsilon}} f(z)dz=-\int_0^\infty \frac{e^{(1/2+i)(\ln x+2\pi i)}}{x^2+1}\,dx=+e^{-2\pi}\int_0^\infty \frac{\sqrt{x}e^{i\ln x}}{x^2+1}\,dx. $$ And also $$ \text{res}_{z=i}f(z)=\frac{e^{(1/2+i)\frac{\pi i}{2}}}{2i}=\frac{e^{-\pi/2+\pi i/4}}{2i}, $$ $$ \text{res}_{z=-i}f(z)=-\frac{e^{(1/2+i)\frac{3\pi i}{2}}}{2i}=-\frac{e^{-3\pi/2+3\pi i/4}}{2i}. $$ Thus the given integral is $$ \frac{\pi}{1+e^{-2\pi}}\Re\left(e^{-\pi/2+\pi i/4}-e^{-3\pi/2+3\pi i/4}\right)=\frac{\pi\cosh(\frac{\pi}{2})}{\sqrt{2}\cosh(\pi)}\sim 0.4805. $$ (I found that this value coincides with the integral numerically by wolframalpha.)


Integrating by parts twice, we get $$ \int_0^\infty\cos(x)\,e^{-ax}\,\mathrm{d}x=\frac{a}{a^2+1}\tag1 $$ Therefore, $$ \begin{align} \int_0^\infty\frac{\sqrt{x}\cos(\log(x))}{x^2+1}\,\mathrm{d}x &=\int_{-\infty}^\infty\frac{\cos(x)}{e^{2x}+1}e^{3x/2}\,\mathrm{d}x\tag2\\ &=\int_{-\infty}^\infty\frac{\cos(x)}{e^{2x}+1}e^{x/2}\,\mathrm{d}x\tag3\\ &=\int_0^\infty\frac{\cos(x)}{e^x+e^{-x}}\left(e^{x/2}+e^{-x/2}\right)\mathrm{d}x\tag4\\ &=\int_0^\infty\cos(x)\sum_{k=0}^\infty(-1)^k\left(e^{-(4k+1)x/2}+e^{-(4k+3)x/2}\right)\mathrm{d}x\tag5\\ &=\frac12\sum_{k=0}^\infty(-1)^k\left[\frac{k+\frac14}{\left(k+\frac14\right)^2+\frac14}+\frac{k+\frac34}{\left(k+\frac34\right)^2+\frac14}\right]\tag6\\[6pt] &=\frac\pi{\sqrt2}\frac{\cosh(\pi/2)}{\cosh(\pi)}\tag7 \end{align} $$ Explanation:
$(2)$: substitute $x\mapsto e^x$
$(3)$: substitute $x\mapsto-x$
$(4)$: average $(2)$ and $(3)$ and apply symmetry
$(5)$: expand into power series
$(6)$: apply $(1)$
$(7)$: use $(7)$ from this answer