# 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.

-
Hint: Maybe you don't have to evaluate this integral. What happens as $R \to \infty$? – Lukas Geyer Oct 27 '12 at 21:22
The integral above appears to go to 0 as R goes to infinity. However, why would I want R to go to infinity? I suppose I don't fully understand the hint – user44184 Oct 27 '12 at 21:58
@user44184, why you want to use the contour integration to obtain the identity in question? An answer to this question will give you a sufficient reason to take the limit $R \to \infty$. – Sangchul Lee Oct 28 '12 at 0:28
@sos440 - I think I understand the hint better now. We aim to compute the residues at each pole of f(z) in the upper half plane. But because the denominator of f consists of terms which are both exponential functions, we can think of them as sinusoids, so we only need to look at the points for which |Im(z)|<=pi (theta<=pi). However, we send R to infinity to analyze the entire upper half plane. I understand that the integral tends to 0 when parameterizing the left and right sides of the rectangle, but I'm struggling to understand for the top and bottom (see next comment for details). – user44184 Oct 28 '12 at 20:41
@sos440 - The top of the rectangle can be parameterized by $\gamma(z)=R+i{\pi}-2Rt$, $d{\gamma}=-i{\pi}t$ $0<t<1$. So we can write $\int_{\gamma}{f(z)dz}=\int_{t=0}^{1}\frac{e^{i(-R+i{\pi}-2Rt)}}{e^{R+i{\pi}-2Rt‌​}+e^{-{R+i{\pi}-2Rt}}}(-2Rdt)$. However, I'm struggling to figure out what happens as R approaches infinity. It appears to me as if the integral also approaches infinity, due to the $-2Rdt$ term. I suppose there is an $e^R$ term in the denominator, but I'm just not sure how to work it all out. – user44184 Oct 28 '12 at 20:53

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.

-