Show that $\int_{-\infty}^\infty\frac{\cos(x)}{e^x+e^{-x}}dx=\frac{\pi}{e^{\pi/2}+e^{-\pi/2}}$? Problem: I'm to show that $\int_{-\infty}^\infty\frac{\cos(x)}{e^x+e^{-x}}dx=\frac{\pi}{e^{\pi/2}+e^{-\pi/2}}$. I'm given the following hint: integrate $f(z)=\frac{e^{iz}}{e^z+e^{-z}}$ over the rectangle with vertices $+R$, $+R+i\pi$, $-R+i\pi$, and $-R$.
Attempted solution: I'm trying to figure out the hint first. I decided to parameterize the rectangle over each of its sides, take the integrals over each parameterizations, and then add the integrals. But I become stuck on my first such parameterization and integration:
$\gamma_1(t)=R+i{\pi}t$, $d{\gamma_1}=i{\pi}dt$, $\int_{\gamma_1}f(z)dz=\int_{t=0}^1{\frac{e^{i(R+i{\pi}t)}}{e^{R+i{\pi}t}+e^{-(R+i{\pi}t)}}(i{\pi}dt)}$
Is my approach correct, and, if so, how can I proceed with this integral? Typing a similar integral into Wolfram yielded a solution involving the "hypergeometric function", which I'm entirely unfamiliar with.
 A: The trick here is that the contour in consideration yields two copies of the integral to be evaluated. To see how this happens, let us consider the following contour as hinted out.

Let $C$ denote this contour, and let $\gamma$ denote the union of the left side contour and the right side contour. By the Cauchy integration formula, we have
$$ \oint_{C} \frac{e^{iz}}{e^{z} + e^{-z}} \, dz = 2\pi i \operatorname{Res}\limits_{z=i\pi/2} \frac{e^{iz}}{e^{z} + e^{-z}} = \pi e^{-\pi/2}.$$
Then we have
$$ \int_{-R}^{R} \frac{\cos x}{e^{x} + e^{-x}} \, dx + \int_{R+i\pi}^{-R+i\pi} \frac{e^{iz}}{e^{z} + e^{-z}} \, dz + \int_{\gamma} \frac{e^{iz}}{e^{z} + e^{-z}} \, dz = \pi e^{-\pi/2}. $$
The first integral converges to what we want to evaluate. For the second integral, we have
$$ \begin{align*}
\int_{R+i\pi}^{-R+i\pi} \frac{e^{iz}}{e^{z} + e^{-z}} \, dz
&= -\int_{-R}^{R} \frac{e^{i(z+i\pi)}}{e^{z+i\pi} + e^{-(z+i\pi)}} \, dz
 = e^{-\pi} \int_{-R}^{R} \frac{e^{iz}}{e^{z} + e^{-z}} \, dz \\
&= e^{-\pi} \int_{-R}^{R} \frac{\cos x}{e^{x} + e^{-x}} \, dx. 
\end{align*}$$
This confirms our claim that the contour $C$ yields two copy of the integral. Finally, the third integral over $\gamma$ vanishes as $R \to \infty$. Therefore by taking $R\to\infty$, we have
$$ (1 + e^{-\pi}) \int_{-\infty}^{\infty} \frac{\cos x}{e^{x} + e^{-x}} \, dx = \pi e^{-\pi/2},$$
hence the identity follows.
