# Improper integration [duplicate]

Possible Duplicate:
How to evaluate these integrals by hand

I am trying to evaluate the following: $$\int_{-\infty}^\infty \frac{\cos x}{e^x+e^{-x}}\, dx$$ using the residue theorem but I could not do it. Any help will be much appreciated.

-

## marked as duplicate by joriki, Raymond Manzoni, Henry T. Horton, Matthew Pressland, AndrewDec 13 '12 at 16:12

This was done here. –  Raymond Manzoni Dec 13 '12 at 14:51
Hint, integral it in the rectangle $\{x+iy| -R\leq x\leq R, 0\leq y\leq a\}$, a is just a fixed number. –  ougao Dec 13 '12 at 14:51
In the first comment the height of rectangle $a=2\pi$ was chosen but $a=\pi$ should be faster (requiring only one zero). –  Raymond Manzoni Dec 13 '12 at 15:06
@Raymond: Why didn't you vote to close as duplicate? –  joriki Dec 13 '12 at 15:06
@Joriki: Yes I'll follow you on that. But I must admit that other people may enjoy to think about this... Ok this one is often asked but here is an example of thread that I liked thinking about before looking at the other (somewthat incomplete) answers... –  Raymond Manzoni Dec 13 '12 at 15:09

Let us put

$$f(z):=\frac{e^{iz}}{e^z+e^{-z}}=\frac{e^ze^{iz}}{e^{2z}+1}$$

We can see the poles of the function are $$2z_k=\pi i(1+2k)\Longleftrightarrow z_k=\frac{\pi i}{2}(1+2k)\,\,,\,\,k\in\Bbb Z$$

We're going to take the contour

$$C_R:=[-R,R]\cup\gamma_R:=\{z=Re^{it}\;;\;0\leq t\leq \pi\}\,\,,\,R\in\Bbb R^+$$

and since the poles are simple and taking into account that $\,\displaystyle{e^{\pm z_k}=(-1)^k\,(\pm i)}\,$:

$$Res_{z=z_k}(F)=\lim_{z\to z_k}(z-z_k)f(z)\stackrel{\text{L'Hospital}}=\lim_{z\to z_k}\frac{e^{iz}}{e^z-e^{-z}}=\frac{e^{-\frac{\pi(1+2k)}{2}}}{e^{z_k}-e^{-z_k}}=\frac{e^{-\frac{\pi(1+2k)}{2}}}{2i(-1)^k}$$

Since when $\,R\to\infty\,$ we're going to contain all the poles with positive imaginary part within $\,C_r\,$ (taking care the contour never touches one of the poles), we get

$$\sum_{Res(f)}=\frac{e^{-\pi/2}}{2i}\sum_{k=0}^\infty \left(-e^{-\pi}\right)^k=\frac{e^{-\pi/2}}{2i}\cdot\frac{1}{1+e^{-\pi}}=(-i)\frac{1}{4\cosh \pi/2}$$

so that

$$\oint_{C_R}f(z)\,dz=2\pi i\left(\sum_{Res(f)}\right)=\frac{\pi}{2\cosh\frac{\pi}{2}}$$

Finally, just check

$$\frac{\pi}{2\cosh\frac{\pi}{2}}=\lim_{R\to\infty}\oint_{C_R}f(z)\,dz=\int_{-\infty}^\infty\frac{e^{ix}}{e^x+e^{-x}}dx+\lim_{R\to\infty}\int_{\gamma_R}f(z)\,dz$$

and

$$\int_{\gamma_R}f(z)\,dz\xrightarrow [R\to\infty]{} 0$$

by Jordan's Lemma , since

$$z\in\gamma_R\Longrightarrow \max_{z\in\gamma_R}\left|\frac{e^{z}}{z^{2z}+1}\right|\leq\max_{z\in\gamma_R}\left|\frac{e^{Re^{it}}}{e^{2Re^{it}}+1}\right|\xrightarrow [R\to\infty]{}0$$

-