I wish to show that $$\sum_{n = 0}^\infty (-1)^n \left [\frac{2n + 1/2}{(2n + 1/2)^2 + 1} + \frac{2n + 3/2}{(2n + 3/2)^2 + 1} \right] = \frac{\pi}{\sqrt{2}} \frac{\cosh \left (\frac{\pi}{2} \right )}{\cosh (\pi)}.$$

The reason I wish to find such a sum is as follows. The question here called for the evaluation (I have added its value) of $$\int_0^\infty \frac{\sqrt{x} \cos (\ln x)}{x^2 + 1} \, dx = \frac{\pi}{\sqrt{2}} \frac{\cosh \left (\frac{\pi}{2} \right )}{\cosh (\pi)}.$$

As one of the comments, the OP remarked that they would like to see different approaches to the evaluation of the integral so I thought I would try my hand at one that does not rely on contour integration and the residue theorem. My approach was as follows: \begin{align} \int_0^\infty \frac{\sqrt{x} \cos (\ln x)}{x^2 + 1} \, dx &= \int_0^1 \frac{\sqrt{x} \cos (\ln x)}{x^2 + 1} \, dx + \int_1^\infty \frac{\sqrt{x} \cos (\ln x)}{x^2 + 1} \, dx\\ &= \int_0^1 \frac{\cos (\ln x) (x + 1)}{\sqrt{x} (1 + x^2)} \, dx, \end{align} after a substitution of $x \mapsto 1/x$ has been enforced in the second of the integrals. Now if we enforce a substitution of $x \mapsto e^{-x}$ one arrives at $$\int_0^\infty \frac{\sqrt{x} \cos (\ln x)}{x^2 + 1} \, dx = \int_0^\infty \frac{\cos x \cosh (x/2)}{\cosh x} \, dx.$$ Writing the hyperbolic functions in terms of exponentials we have \begin{align} \int_0^\infty \frac{\sqrt{x} \cos (\ln x)}{x^2 + 1} \, dx &= \int_0^\infty \frac{\cos x (e^{-x/2} + e^{-3x/2})}{1 + e^{-2x}} \, dx\\ &= \text{Re} \sum_{n = 0}^\infty (-1)^n \int_0^\infty \left [e^{-(2n + 1/2 - i) x} + e^{-(2n + 3/2 - i)x} \right ] \, dx\\ &= \text{Re} \sum_{n = 0}^\infty (-1)^n \left [\frac{1}{2n + 1/2 - i} + \frac{1}{2n + 3/2 - i} \right ] \tag1\\ &= \sum_{n = 0}^\infty (-1)^n \left [\frac{2n + 1/2}{(2n + 1/2)^2 + 1} + \frac{2n + 3/2}{(2n + 3/2)^2 + 1} \right], \end{align} which brings me to my sum.


Some thoughts on finding this sum

Rewriting the sum $S$ in (1) as follows: \begin{align} S &= \text{Re} \cdot \frac{1}{4} \sum_{n = 0}^\infty \left [\frac{1}{n + 1/8 - i/4} + \frac{1}{n + 3/8 - i/4} - \frac{1}{n + 5/8 - i/4} - \frac{1}{n + 7/8 - i/4} \right ]\\ &= \text{Re} \cdot \frac{1}{4} \sum_{n = 0}^\infty \left (\frac{1}{n + 1} - \frac{1}{n + 7/8 - i/4} \right ) + \frac{1}{4} \sum_{n = 0}^\infty \left (\frac{1}{n + 1} - \frac{1}{n + 5/8 - i/4} \right )\\ & \qquad - \frac{1}{4} \sum_{n = 0}^\infty \left (\frac{1}{n + 1} - \frac{1}{n + 3/8 - i/4} \right ) - \frac{1}{4} \sum_{n = 0}^\infty \left (\frac{1}{n + 1} - \frac{1}{n + 1/8 - i/4} \right )\\ &= \frac{1}{4} \text{Re} \left [\psi \left (\frac{7}{8} - \frac{i}{4} \right ) + \psi \left (\frac{5}{8} - \frac{i}{4} \right ) - \psi \left (\frac{3}{8} - \frac{i}{4} \right ) - \psi \left (\frac{1}{8} - \frac{i}{4} \right ) \right ]. \end{align} Here $\psi (z)$ is the digamma function. I was rather hoping to use the reflexion formula for the digamma function, but alas it does not seem to take me any closer to a final real solution.


Final thought

While it would be nice to see how to evaluate this sum, perhaps my approach was not the best so alternative methods to evaluate the integral that avoid this sum and does not rely on contour integration would also be welcome.


$$ \begin{align}\newcommand{\Re}{\operatorname{Re}} &\sum_{n=0}^\infty(-1)^n\left[\frac{2n+1/2}{(2n+1/2)^2+1}+\frac{2n+3/2}{(2n+3/2)^2+1}\right]\tag1\\ &=\frac12\sum_{n\in\mathbb{Z}}(-1)^n\left[\frac{2n+1/2}{(2n+1/2)^2+1}+\frac{2n+3/2}{(2n+3/2)^2+1}\right]\tag2\\ &=\frac14\sum_{n\in\mathbb{Z}}(-1)^n\left[\frac{n+\frac14}{\left(n+\frac14\right)^2+\frac14}+\frac{n+\frac34}{\left(n+\frac34\right)^2+\frac14}\right]\tag3\\ &=\frac18\sum_{n\in\mathbb{Z}}(-1)^n\left[\frac1{n+\frac14-\frac i2}+\frac1{n+\frac14+\frac i2}+\frac1{n+\frac34-\frac i2}+\frac1{n+\frac34+\frac i2}\right]\tag4\\ &=\frac18\left[\frac\pi{\sin\left(\pi\!\left(\frac14-\frac i2\right)\right)}+\frac\pi{\sin\left(\pi\!\left(\frac14+\frac i2\right)\right)}+\frac\pi{\sin\left(\pi\!\left(\frac34-\frac i2\right)\right)}+\frac\pi{\sin\left(\pi\!\left(\frac34+\frac i2\right)\right)}\right]\tag5\\ &=\frac{\pi\sqrt2}8\left[ \frac{\cosh\left(\frac\pi2\right)+i\sinh\left(\frac\pi2\right)}{\cosh(\pi)}+ \frac{\cosh\left(\frac\pi2\right)-i\sinh\left(\frac\pi2\right)}{\cosh(\pi)}+ \frac{\cosh\left(\frac\pi2\right)-i\sinh\left(\frac\pi2\right)}{\cosh(\pi)}\right.\\ &\left.\phantom{=\frac{\pi\sqrt2}8}+ \frac{\cosh\left(\frac\pi2\right)+i\sinh\left(\frac\pi2\right)}{\cosh(\pi)}\right]\tag6\\ &=\frac\pi{\sqrt2}\frac{\cosh(\pi/2)}{\cosh(\pi)}\tag7 \end{align} $$ Explanation:
$(2)$: use symmetry
$(3)$: pull factor of $\frac12$ out front
$(4)$: partial fractions
$(5)$: use $(3)$ from this answer
$(6)$: evaluate the sine of a complex number
$(7)$: simplify


$$I=\int_0^\infty \frac{\sqrt{x} \cos (\ln x)}{x^2 + 1} \, dx$$

Here is an easy way to compute this integral.

Let's start with a classic integral:

$$\int_0^\infty \frac{y^{a-1}}{1+y}dy=\frac{\pi}{\sin(\pi a)};0<a<1$$

(First calculated by Euler)

The change of variable $y=x^2$ gives

$$I(a)=\int_0^\infty \frac{x^a}{1+x^2}dx=\frac{\pi}{2\cos(\frac{\pi}{2} a)};-1<a<1$$

Now let's note that $\frac{\pi}{2\cos(\frac{\pi}{2} a)}$ as a function of $a$ is regular on the whole complex plane excluding points

$$a=2n+1 ;n\in Z$$

That means it is an analytic continuation of integral $I(a)$ from $(-1,1)$ to the complex plane

So we can safely take $a$ as a complex variable, say $a+ib$

Thus

$$\int_0^\infty \frac{x^{a+ib}}{1+x^2}dx=\frac{\pi}{2\cos(\frac{\pi}{2} (a+ib))}$$

Now separate here real and imaginary parts taking into account that

$$x^{a+ib}=x^a\cos(b\ln x)+ix^a\sin(b\ln x)$$

Choosing real part we finally get

$$I=\int_0^\infty \frac{x^a \cos (b\ln x)}{x^2 + 1} \, dx$$

$$=\frac{\pi}{2}\frac{\cos(\frac{\pi}{2} a)\cosh(\frac{\pi}{2} b)}{\cos^2(\frac{\pi}{2} a)\cosh^2(\frac{\pi}{2} b)+\sin^2(\frac{\pi}{2} a)\sinh^2(\frac{\pi}{2} b)}$$

Choose here $a=\frac{1}{2}$ and $b=1$ to get desired integral