Computing: $\int_\Bbb R\frac{dt}{\cosh (\pi t )+\cos (\pi x )}~~0We are given the following problem: prove the existence and compute integrals
$$I(x)=\int_\Bbb R\frac{dt}{\cosh (\pi t )+\cos (\pi x )} $$
$$J(x)=\int_\Bbb R\frac{dt}{\cosh (\pi t )-\cos (\pi x )} $$
where, $0<x<1.$

I have already proved the existence. Also I remarked that $J(1-x) =I(x)$
Now I am struggling to compute $I(x)$ any help?

 A: Let us assume $x$ is real and $0< x < 1$, and consider $$\DeclareMathOperator{\Res}{Res}    f(z) = \frac{z}{\cosh(\pi z) + \cos(\pi x)} $$
note that $$\cosh(\pi z) + \cos(\pi x) = 2\cos\left(\frac{i\pi z +\pi x}{2}\right)\cos\left(\frac{i\pi z -\pi x}{2}\right)$$
hence $f(z)$ has a first order pole at $z = i (4n \pm x \pm 1)$ for $n\in \mathbb{Z}$. 
Integrate it along the rectangular contour with height $2$ gives
\begin{equation}\tag{1} \int_{-\infty}^{\infty} f(t) dt - \int_{-\infty}^{\infty} f(t+2i) dt  = 2\pi i \Res[f(z),z=i(1-x)] +2\pi i \Res[f(z),z=i(1+x)]\end{equation}
$$\implies \int_{-\infty}^{\infty} \frac{-2 i}{\cosh(\pi t)+\cos(\pi x)} dt = \frac{{ - 4xi}}{{\sin (\pi x)}}$$
$$\implies \int_{-\infty}^{\infty} \frac{1}{\cosh(\pi t)+\cos(\pi x)} dt = \frac{{ 2x}}{{\sin (\pi x)}}$$

The second integral is analogous, except you now assume $1<x<2$ and $(1)$ is changed into:
$$\int_{-\infty}^{\infty} f(t) dt - \int_{-\infty}^{\infty} f(t+2i) dt  = 2\pi i \Res[f(z),z=i(x-1)] +2\pi i \Res[f(z),z=i(3-x)]$$
giving $$\int_{ - \infty }^\infty  {\frac{1}{{\cosh (\pi t) + \cos (\pi x)}}dt}  = \frac{{2x - 4}}{{\sin (\pi x)}}$$
for $1<x<2$.
A: 
Define the function $F:\left(-\pi,\pi\right)\rightarrow\mathbb{R}_{>0}$ via the improper integral,
$$\begin{align}
F{\left(\alpha\right)}
&:=\frac12\int_{-\infty}^{\infty}\frac{\mathrm{d}\tau}{\cosh{\left(\tau\right)}+\cos{\left(\alpha\right)}}.\tag{1}\\
\end{align}$$
One quick way to prove that the RHS of $(1)$ above converges for all $\alpha$ is through the inequality,
$$\small{\forall\left(\tau,\alpha\right)\in\mathbb{R}\times\left(-\pi,\pi\right):0<\frac{1}{\cosh{\left(\tau\right)}+\cos{\left(\alpha\right)}}\le\frac{1}{1+\frac{\tau^{2}}{2}+\cos{\left(\alpha\right)}}=\frac{2}{\tau^{2}+4\cos^{2}{\left(\frac{\alpha}{2}\right)}}}.$$

We can evaluate $F$ without resorting to tools from complex analysis by employing the hyperbolic analogue of the Weierstrass substitution.
Given $\alpha\in\left(-\pi,\pi\right)$, we obtain
$$\begin{align}
F{\left(\alpha\right)}
&=\frac12\int_{-\infty}^{\infty}\frac{\mathrm{d}\tau}{\cosh{\left(\tau\right)}+\cos{\left(\alpha\right)}}\\
&=\int_{0}^{\infty}\frac{\mathrm{d}\tau}{\cosh{\left(\tau\right)}+\cos{\left(\alpha\right)}}\\
&=\int_{0}^{\infty}\frac{\mathrm{d}\tau}{2\cosh^{2}{\left(\frac{\tau}{2}\right)}-1+\cos{\left(\alpha\right)}}\\
&=\int_{0}^{\infty}\frac{\mathrm{d}\tau}{2\cosh^{2}{\left(\frac{\tau}{2}\right)}-2\sin^{2}{\left(\frac{\alpha}{2}\right)}}\\
&=\int_{0}^{\infty}\mathrm{d}\tau\,\frac{\operatorname{sech}^{2}{\left(\frac{\tau}{2}\right)}}{2\left[1-\sin^{2}{\left(\frac{\alpha}{2}\right)}\operatorname{sech}^{2}{\left(\frac{\tau}{2}\right)}\right]}\\
&=\int_{0}^{\infty}\mathrm{d}\tau\,\frac{2^{-1}\operatorname{sech}^{2}{\left(\frac{\tau}{2}\right)}}{1-\sin^{2}{\left(\frac{\alpha}{2}\right)}\left[1-\tanh^{2}{\left(\frac{\tau}{2}\right)}\right]}\\
&=\int_{0}^{1}\mathrm{d}t\,\frac{1}{1-\sin^{2}{\left(\frac{\alpha}{2}\right)}\left(1-t^{2}\right)};~~~\small{\left[\tanh{\left(\frac{\tau}{2}\right)}=t\right]}\\
&=\int_{0}^{1}\mathrm{d}t\,\frac{1}{\cos^{2}{\left(\frac{\alpha}{2}\right)}+t^{2}\sin^{2}{\left(\frac{\alpha}{2}\right)}}\\
&=\sec^{2}{\left(\frac{\alpha}{2}\right)}\int_{0}^{1}\mathrm{d}t\,\frac{1}{1+t^{2}\tan^{2}{\left(\frac{\alpha}{2}\right)}}.\\
\end{align}$$
Then, for $0<\alpha<\pi$,
$$\begin{align}
F{\left(\alpha\right)}
&=\sec^{2}{\left(\frac{\alpha}{2}\right)}\int_{0}^{1}\mathrm{d}t\,\frac{1}{1+t^{2}\tan^{2}{\left(\frac{\alpha}{2}\right)}}\\
&=\frac{1}{\tan{\left(\frac{\alpha}{2}\right)}\cos^{2}{\left(\frac{\alpha}{2}\right)}}\int_{0}^{1}\mathrm{d}t\,\frac{\tan{\left(\frac{\alpha}{2}\right)}}{1+t^{2}\tan^{2}{\left(\frac{\alpha}{2}\right)}}\\
&=\frac{2}{\sin{\left(\alpha\right)}}\int_{0}^{\tan{\left(\frac{\alpha}{2}\right)}}\mathrm{d}x\,\frac{1}{1+x^{2}};~~~\small{\left[t\tan{\left(\frac{\alpha}{2}\right)}=x\right]}\\
&=\frac{\alpha}{\sin{\left(\alpha\right)}}.\blacksquare\\
\end{align}$$

