Solve $\int_{-\infty}^{+\infty}\frac{1}{\cosh x}\ dx$ using residue theory [ANSWERED]

complex-analysishyperbolic-functionsimproper-integralsresidue-calculus

I was trying to solve this exercises which asked to first solve
$$I=\lim_{R\to +\infty}\oint_{\Gamma_R}\frac{1}{\cosh z}\ dz $$
where $\Gamma_R=\partial\{z=x+iy\in\mathbb{C}:-R\le x\le R, \ 0\le y\le \pi\}\equiv \partial D$. From this integral, obtain the following one:
$$J= \int_{-\infty}^{+\infty}\frac{1}{\cosh x}\ dx$$

My solution. Consider $f(z) = \frac{1}{\cosh z}$; this function, limited to the domain $D$, is analytical everywhere, besides in the point $z_0=i \frac{\pi}{2}$, where $\cosh z_0 = 0$. Hence:
$$\lim_{R\to +\infty}\oint_{\Gamma_R}\frac{1}{\cosh z}\ dz = 2\pi i \operatorname{Res} \left(f(z), z_0\right)$$
To calculate those residue, I used the fact that the numerator is non-zero, while the denominator is zero calculated in $z_0$, so the residue should be given by:
$$\operatorname{Res} \left(f(z), z_0\right)=\lim_{z\to z_0}\frac{1}{\frac{d}{dz}\cosh z}\equiv \frac{1}{\sinh\left(i\frac{\pi}{2}\right)}=-i$$
This implies that:
$$\lim_{R\to +\infty}\oint_{\Gamma_R}\frac{1}{\cosh z}\ dz =2\pi$$
To obtain the integral $J$ from this result, I noted that:
$$\oint_{\Gamma_R}\frac{1}{\cosh z}\ dz = \left(\int_{-R}^{+R} + \int_{C_R}\right)\frac{1}{\cosh z}\ dz$$
where $C_R = \{z=re^{i\theta}\in \mathbb{C} : |z| = R, \ 0\le \theta \le \pi\}$. Since
$$\left\lvert\int_{C_R}\frac{1}{\cosh z}\ dz\right\rvert\le \int_{C_R} \frac{2}{|e^z + e^{-z}|} \ dz \le 2\int_0^{2\pi}\frac{1}{||e^{R \cos\theta}|-|e^{-R\cos\theta}||}\ Rd\theta\le2\frac{R}{|e^{R}-e^{-R}|}\int_0^{2\pi} d\theta$$
converges to $0$ as $R\to +\infty$ because of the fact that $e^{-R} \to 0$ and $\frac{R}{e^R}\to 0$, it means that:
$$\lim_{R\to+\infty}\int_{-R}^{+R}\frac{1}{\cosh z}\ dz\equiv \lim_{R\to+\infty}\int_{-R}^{+R}\frac{1}{\cosh x}\ dx=\mathcal{P}\int_{-\infty}^{+\infty} \frac{1}{\cosh x} \ dx = \lim_{R\to +\infty}\oint_{\Gamma_R}\frac{1}{\cosh z}\ dz =2\pi$$
where $\mathcal{P}$ is the Cauchy principal part of the integral. The problem with this is that checking the result for $\int_{-\infty}^{+\infty} \frac{1}{\cosh x} \ dx$, this should be equal to $\pi$ and not to $2\pi$. I tried looking for mistakes, but I can't seem to find any. Can you please help me? Thanks in advance!

Best Answer

You correctly calculated the residue around the contour $\Gamma_R$ but $\Gamma_R$ consists of four line segments, instead of one line segment on the real line and the half-circle. If you calculate the residue within the segment and the half circle, then there are more and more poles as $R$ increases.

The correct way: Use similar technique to show the integral over the vertical segments $x=R$ and $x=-R$ vanishes as $R\rightarrow\infty$. As for the integral on the top segment $y=\pi$, note that $$\cosh(z+\pi i) = \frac{e^{z+\pi i} + e^{-(z+\pi i)}}{2}=-\cosh(z)$$

The minus sign is cancelled by the integral on the top is along the opposite direction as on the bottom. Therefore the integral on the bottom half is precisely half of $2\pi$.