How can i evaluate this integral with or without using CAS $\int_0^{\infty}\frac{\mathrm dx}{(x^2+1)\cosh(\pi x)}$
Similar to the question already mentioned by @Laxmi Narayan Bhandari, considering the infinite series $$\text{sech}(z)=\pi\sum_{k=0}^\infty (-1)^k\frac{ (2 k+1)}{\pi ^2 \left(k+\frac{1}{2}\right)^2+z^2}$$ Making the problem more general $$I=\int_0^\infty \frac{\text{sech}(a x)}{b x^2+1}\,dx \quad \text{with} \quad a>0 \quad \text{and} \quad b>0$$ we have $$\frac{\text{sech}(a x)}{b x^2+1}=4 \pi\sum_{k=0}^\infty(-1)^k\frac{ (2 k+1)}{\left(b x^2+1\right) \left(4 a^2 x^2+\pi ^2 (2 k+1)^2\right)}$$ Using partial fraction decomposition $$\frac{ 1}{\left(b x^2+1\right) \left(4 a^2 x^2+\pi ^2 (2 k+1)^2\right)}=$$ $$\frac{b}{\left(b x^2+1\right) \left(\pi ^2 b (2 k+1)^2-4 a^2\right)}-\frac{4 a^2}{\left(\pi ^2 b (2 k+1)^2-4 a^2\right) \left(4 a^2 x^2+\pi ^2 (2 k+1)^2\right)}$$ $$\int_0^\infty\frac{ dx}{\left(b x^2+1\right) \left(4 a^2 x^2+\pi ^2 (2 k+1)^2\right)}=$$ $$\frac{\pi \sqrt{b}}{2 \left(\pi ^2 b (2 k+1)^2-4 a^2\right)}-\frac{a}{(2 k+1) \left(\pi ^2 b (2 k+1)^2-4 a^2\right)}$$
After summations, $$\color{red}{I=\int_0^\infty \frac{\text{sech}(a x)}{b x^2+1}\,dx=\frac{\psi \left(\frac{a}{2 \pi\sqrt{b} }+\frac{3}{4}\right)-\psi \left(\frac{a}{2 \pi\sqrt{b} }+\frac{1}{4}\right)}{2 \sqrt{b}}}$$
If, as in your case, $a=\pi$ and $b=1$, the result is $$\int_0^\infty \frac{\text{sech}(\pi x)}{ x^2+1}\,dx=2-\frac \pi 2$$ and, if $a=\pi$ and $b=4$ as in the linked question $$\int_0^\infty \frac{\text{sech}(\pi x)}{ 4x^2+1}\,dx=\frac{\log (2)}{2}$$
For $a=\pi$, these are the only cases where the result simplifies.
Edit
Update
After @Gary comment, let $z=\frac{a}{2 \pi \sqrt{b}}$ which makes $$I \sqrt{b}=\frac 12 \Bigg[ {\psi \left(z+\frac{3}{4}\right)-\psi \left(z +\frac{1}{4}\right)}\Bigg]\sim\sum_{k=0}^\infty \frac {E_{2 k} } {(4z)^{2k+1} }$$
Using this expansion to build $P_{m,m+1}$ Padé approximants,we obtain very good approximations of $I \sqrt{b}$. For example $$P_{3,4}=\frac {52 z+64 z^3 } {9+224 z^2+256 z^4 }$$ shows an absolute relative error of $0.0015$% for $z=2$ and $$\Phi=\int_2^\infty \Big[I \sqrt{b}-P_{3,4}\Big]^2\,dz=5.01\times 10^{-13}$$
Recall the following two results:
$$\int_0^\infty e^{-bt}\cos\left(xt \right)\,dt=\frac{b}{b^2+x^2}\tag{1}$$
$$\int_0^\infty \frac{\cos\left(xt \right)}{\cosh\left(ax \right)}\,dx=\frac{\pi} {2a \cosh\left(\frac{\pi t}{2a} \right)} \tag{2}$$
$$ \begin{aligned} \int_0^\infty \frac{1}{(b^2+x^2)\cosh\left(ax \right)}\,dx&= \frac 1b\int_0^\infty \frac{1}{\cosh\left(ax \right)}\,\int_0^\infty e^{-bt}\cos\left(xt \right)\,dt\,dx\\ &= \frac 1b\int_0^\infty e^{-bt}\int_0^\infty \frac{\cos\left(xt \right)}{\cosh\left(ax \right)}\,dx\,dt\\ &= \frac 1b\int_0^\infty e^{-bt}\left(\frac{\pi} {2a \cosh\left(\frac{\pi t}{2a} \right)} \right)\,dt\\ &= \frac{\pi}{2 a b}\int_0^\infty \frac{ e^{-bt}} {\cosh\left(\frac{\pi t}{2a} \right)} \,dt\\ &= \frac{1}{b}\int_0^\infty \frac{ e^{-\frac{2ab}{\pi}t}} {\cosh\left(t \right)} \,dt \qquad \left(\frac{2ab}{\pi}w=t\right)\\ &= \frac{2}{b}\int_0^\infty \frac{ e^{-ct}} {e^{t}+e^{-t}} \,dt \qquad \left(c=\frac{2ab}{\pi}\right)\\ &= \frac{2}{b}\int_0^\infty \frac{ e^{-ct}e^{-t}} {1+e^{-2t}} \,dt\\ &= \frac{2}{b}\int_0^\infty e^{-ct}e^{-t}\left(\sum_{k=0}^\infty (-1)^{k}e^{-2kt} \right) \,dt\\ &= \frac{2}{b}\int_0^\infty e^{-ct}\left(\sum_{k=0}^\infty (-1)^{k}e^{-(2k+1)t} \right) \,dt\\ &= \frac{2}{b}\int_0^\infty e^{-ct}\left(\sum_{k=1}^\infty (-1)^{k-1}e^{-(2k-1)t} \right) \,dt\\ &= \frac{2}{b}\sum_{k=1}^\infty (-1)^{k-1}\,\int_0^\infty e^{-\left(c+(2k-1)\right)t} \,dt\\ &= \frac{2}{b}\sum_{k=1}^\infty \frac{(-1)^{k-1}}{\frac{2ab}{\pi}+(2k-1)}\\ &=\frac{2 \pi}{b}\sum_{k=1}^\infty \frac{(-1)^{k-1}}{2ab+(2k-1)\pi} \qquad \blacksquare \end{aligned} $$
$$ \begin{aligned} \int_0^\infty \frac{1}{(1+x^2)\cosh\left( \pi x \right)}\,dx&=2 \pi\sum_{k=1}^\infty \frac{(-1)^{k-1}}{2 \pi+(2k-1)\pi}\\ &=2 \sum_{k=1}^\infty \frac{(-1)^{k-1}}{2k+1}\\ &=-2 \sum_{k=1}^\infty \frac{(-1)^{k}}{2k+1}\\ &=2-2 \sum_{k=0}^\infty \frac{(-1)^{k}}{2k+1}\\ &=2-2 \frac \pi 4 \\ &=2-\frac \pi 2 \qquad \blacksquare \end{aligned} $$
$$ \begin{aligned} \int_0^\infty \frac{1}{(\pi^2+x^2)\cosh\left( x \right)}\,dx&=\frac{2 \pi}{\pi}\sum_{k=1}^\infty \frac{(-1)^{k-1}}{2 \pi+(2k-1)\pi}\\ &=\frac 2 \pi \sum_{k=1}^\infty \frac{(-1)^{k-1}}{2k+1}\\ &=-\frac 2 \pi \sum_{k=1}^\infty \frac{(-1)^{k}}{2k+1}\\ &=\frac 2 \pi-\frac 2 \pi \sum_{k=0}^\infty \frac{(-1)^{k}}{2k+1}\\ &=\frac 2 \pi-\frac 2 \pi \cdot \frac \pi 4 \\ &=\frac 2 \pi-\frac 1 2 \qquad \blacksquare \end{aligned} $$
$$ \begin{aligned} &\sum_{k=0}^{\infty}\frac{(-1)^k}{2k+1}\\ &=\frac{1}{2}\sum_{k=0}^{\infty}\frac{(-1)^k}{k+\frac{1}{2}}\\ &=\frac{1}{2}\sum_{k=0}^{\infty}(-1)^k\int_0^1t^{k+1/2-1}dt\\ &=\frac{1}{2}\int_0^1t^{-1/2}\left(\sum_{k=0}^{\infty}(-1)^kt^k\right)dt\\ &=\frac{1}{2}\int_0^1\frac{t^{-1/2}}{1+t}dt\\ &=\frac{1}{4}\left(\psi\left( \frac{3}{4}\right)-\psi\left( \frac{1}{4}\right) \right)\\ &=\frac{1}{4}\left(\pi \cot\left( \frac{\pi}{4}\right) \right)\\ &=\frac{\pi}{4}\\ \end{aligned} $$
Where We used the results
$$\int_0^1\frac{t^{x-1}}{1+t}dt=\frac{1}{2}\left(\psi\left( \frac{x+1}{2}\right)-\psi\left( \frac{x}{2}\right) \right)$$
and
$$\psi(1-x)-\psi(x)=\pi \cot(\pi x)$$