Integrals of the form
$$\int_{-\infty}^\infty \frac{p(x)}{\cosh x}\,dx,$$
where $p$ is a polynomial can be evaluated by shifting the contour of integration to a line $\operatorname{Im} z \equiv c$. We first check that the integrals over the vertical segments connecting the two lines tend to $0$ as the real part tends to $\pm\infty$:
$$\lvert \cosh (x+iy)\rvert^2 = \lvert \cosh x\cos y + i \sinh x\sin y\rvert^2 = \sinh^2 x + \cos^2 y,$$
so the integrand decays exponentially and
$$\left\lvert \int_{R}^{R + ic} \frac{p(z)}{\cosh z}\,dz\right\rvert
\leqslant \frac{K\,c}{\sinh R}\left(R^2+c^2\right)^{\deg p/2} \xrightarrow{R\to \pm\infty} 0.$$
Since $\cosh \left(z+\pi i\right) = -\cosh z$, and the only singularity of the integrand between $\mathbb{R}$ and $\mathbb{R}+\pi i$ is a simple pole at $\frac{\pi i}{2}$ (unless $p$ has a zero there, but then we can regard it as a simple pole with residue $0$) with the residue
$$\operatorname{Res}\left(\frac{p(z)}{\cosh z};\, \frac{\pi i}{2}\right) = \frac{p\left(\frac{\pi i}{2}\right)}{\cosh' \frac{\pi i}{2}} = \frac{p\left(\frac{\pi i}{2}\right)}{\sinh \frac{\pi i}{2}} = \frac{p\left(\frac{\pi i}{2}\right)}{i},$$
the residue theorem yields
$$\begin{align}
\int_{-\infty}^\infty \frac{p(x)}{\cosh x}\,dx
&= 2\pi\, p\left(\frac{\pi i}{2}\right) + \int_{\pi i-\infty}^{\pi i+\infty} \frac{p(z)}{\cosh z}\,dz\\
&= 2\pi\, p\left(\frac{\pi i}{2}\right) - \int_{-\infty}^\infty \frac{p(x+\pi i)}{\cosh x}\,dx\\
&= 2\pi\, p\left(\frac{\pi i}{2}\right) - \sum_{k=0}^{\deg p} \frac{(\pi i)^k}{k!}\int_{-\infty}^\infty \frac{p^{(k)}(x)}{\cosh x}\,dx.\tag{1}
\end{align}$$
Since $\cosh$ is even, only even powers of $x$ contribute to the integrals, hence we can from the beginning assume that $p$ is an even polynomial, and need only consider the derivatives of even order.
For a constant polynomial, $(1)$ yields
$$\int_{-\infty}^\infty \frac{dx}{\cosh x} = 2\pi - \int_{-\infty}^\infty \frac{dx}{\cosh x}\Rightarrow \int_{-\infty}^\infty \frac{dx}{\cosh x} = \pi.$$
For $p(z) = z^2$, we obtain
$$\begin{align}
\int_{-\infty}^\infty \frac{x^2}{\cosh x}\,dx &= 2\pi \left(\frac{\pi i}{2}\right)^2 - \int_{-\infty}^\infty \frac{x^2}{\cosh x}\,dx - (\pi i)^2\int_{-\infty}^\infty \frac{dx}{\cosh x}\\
&= - \frac{\pi^3}{2} - \int_{-\infty}^\infty \frac{x^2}{\cosh x}\,dx + \pi^3,
\end{align}$$
which becomes
$$\int_{-\infty}^\infty \frac{x^2}{\cosh x}\,dx = \frac{\pi^3}{4}.$$
$$I=\int\frac{\sin (a x)}{x \left(\pi ^2-a^2 x^2\right)}\,dx=\int \frac{\sin (t)}{(t-\pi)t(t+\pi) }\,dt$$
$$\frac{1}{(t-\pi)t(t+\pi) }=\frac 1 {\pi^2}\Bigg[\frac{1}{2 (t-\pi )}+\frac{1}{2 (t+\pi )}-\frac{1}{t} \Bigg]$$
Consider
$$\int \frac {\sin(t)}{t+k}\,dt=\int\frac {\sin(u-k)}{u}\,du=\cos (k)\int\frac{ \sin (u)}{u}\,du-\sin (k)\int\frac{ \cos (u)}{u}\,du$$ So now, you just face sine and cosine integrals.
Back to $x$, you will have
$$I=\frac 1{2\pi^2}\Big[2 \text{Si}(a x)+\text{Si}(ax-\pi )+\text{Si}(a x+\pi ) \Big]$$
$$J=\int_{-p}^{+p}\frac{\sin (a x)}{x \left(\pi ^2-a^2 x^2\right)}\,dx=\frac 1{\pi^2}\Big[2 \text{Si}(a p)+\text{Si}(ap-\pi )+\text{Si}(a p+\pi ) \Big]\sim \frac 4{\pi^2}\text{Si}(a p)$$ Now, using the asymptotics
$$K=\int_{-\infty}^{+\infty}\frac{\sin (a x)}{x \left(\pi ^2-a^2 x^2\right)}\,dx=\frac{2 |a|}{\pi a}$$
Best Answer
The infinite integral of $\frac{\sin x}{x}$ using complex analysis
You should learn here. Integral over "simple closed curve without singularities" should be zero by Cauchy-Goursat's Theorem. But integral on the real line or "semi-circle without real line" should not be like that, because they are not simple closed curves