# Improper integral complex analysis $\int_{-\infty}^\infty \frac{e^{ax} \, dx}{\cosh(x)}$

I tried the following problem but I don't think I got the right answer. I checked it by substituting $a=\frac{1}{2}$ into the integral and putting that through Wolfram Alpha but it didn't match the answer I found when I substituted $a=\frac{1}{2}$ into my final answer. So I would be so grateful if someone could tell me where I went wrong. I'm not sure if there's an easier contour than a rectangle but if there is please don't suggest any because I was required to solve this problem using a rectangular contour. Thank you in advance! :)

Problem:

Evaluate $$\int_{-\infty}^\infty \frac{e^{ax} \, dx}{\cosh(x)}$$ where $-1<\operatorname{Re}(a)<1$ using a rectangular contour integral and residue calculus.

My attempt:

$$\cosh(z)=\cos(iz)=0$$ $$z=\frac{i\pi}{2}-k\pi i,k\in Z$$

Let $L>0$ be a real number, and $C_1, C_2, C_3, C_4$ be the line segments that go from $-L$ to $L$, from $L$ to $L+\pi i$, from $L + \pi i$ to $-L+\pi i$ and from $-L+\pi i$ to $-L$, respectively. Let $C = C_1 + C_2 + C_3 + C_4$, a rectangular contour surrounding the singularity $z=\frac{i\pi}{2}$.

$$\oint_C\frac{e^{az} \, dz}{\cosh(z)}=\int_{-L}^L \frac{e^{ax}dx}{\cosh(x)} + \int_0^\pi \frac{e^{a(L+iy)}i \, dy}{\cosh(L+iy)}+\int_L^{-L} \frac{e^{a(x+\pi i)} \, dx}{\cosh(x+\pi i)}+\int_\pi^0 \frac{e^{a(-L+iy)}i \, dy}{\cosh(-L+iy)}$$

Now,

$$\oint_C\frac{e^{az} \, dz}{\cosh(z)}=2\pi i \operatorname{Res} \left(\frac{e^{az}}{\cosh(z)};\frac{i\pi}{2}\right) =2\pi i \lim_{z \rightarrow \frac{i\pi}{2}}\frac{e^{az}(z-\frac{i\pi}{2})}{\cosh(z)}=-ie^{\frac{ai\pi}{2}}$$ and

$$\int_{-L}^L \frac{e^{ax} \,dx}{\cosh(x)}+\int_L^{-L} \frac{e^{a(x+\pi i)} \, dx}{\cosh(x+\pi i)} = (1+e^{a\pi i})\int_{-L}^L \frac{e^{ax} \, dx}{\cosh(x)}$$ using the fact that $\cosh(x+\pi i)=-\cosh(x)$.

$$\Rightarrow -ie^{\frac{ai\pi}{2}} = (1+e^{a\pi i})\int_{-L}^L \frac{e^{ax} \, dx}{\cosh(x)} + \int_0^\pi \frac{e^{a(L+iy)}i \, dy}{\cosh(L+iy)}+\int_\pi^0 \frac{e^{a(-L+iy)}i \, dy}{\cosh(-L+iy)}$$

Then after showing that $\int_0^\pi \frac{e^{a(L+iy)}i \, dy}{\cosh(L+iy)}$, $\int_\pi^0 \frac{e^{a(-L+iy)}i\,dy}{\cosh(-L+iy)} \rightarrow 0$ as $L\rightarrow \infty$ we find that

$$-ie^{\frac{ai\pi}{2}} = (1+e^{a\pi i})\int_{-\infty}^\infty \frac{e^{ax} \, dx}{\cosh(x)}$$

$$\Rightarrow \int_{-\infty}^\infty \frac{e^{ax} \, dx}{\cosh(x)} = \frac{-i e^{\frac{ai\pi}{2}}}{(1+e^{a\pi i})}$$

Let $I(a)$ be given by the integral

$$I(a)=\int_{-\infty}^\infty \frac{e^{ax}}{\cosh(x)}\,dx \tag 1$$

To evaluate the integral in $(1)$, we analyze the contour integral

$$J(a)=\oint_C \frac{e^{az}}{\cosh(z)}\,dz$$

where $C$ is the closed rectangular contour with vertices at $-L$, $L$, $L+i\pi$, and $-L+i\pi$. From the residue theorem, we have

\begin{align} J(a)&=2\pi i \text{Res}\left(\frac{e^{az}}{\cosh(z)}, z=i\pi/2\right)\\\\ &=2\pi i \frac{e^{ia\pi/2}}{\sinh(i\pi/2)}\\\\ &=2\pi e^{ia\pi/2} \tag 2 \end{align}

In addition, as $L\to \infty$ the contributions to $J(a)$ from integrating over the vertical strips vanish. Therefore, we find that

\begin{align} \lim_{L\to \infty}J(a)&=\int_{-\infty}^{\infty}\frac{e^{ax}}{\cosh(x)}\,dx+\int_{\infty}^{-\infty}\frac{e^{a(x+i\pi)}}{\cosh(x+i\pi)}\\\\ &=(1+e^{ia\pi})\int_{-\infty}^{\infty}\frac{e^{ax}}{\cosh(x)}\,dx \tag 3 \end{align}

Equating $(2)$ and $(3)$ reveals

$$(1+e^{ia\pi})I(a)=2\pi e^{ia\pi/2}$$

whence we find

$$\bbox[5px,border:2px solid #C0A000]{I(a)=\frac{\pi}{\cos(\pi a/2)}}$$

• Thank you so much! I found my mistake - I forgot to multiply the residue by $2\pi i$ – user342661 Jun 16 '16 at 4:21
• You're welcome. My pleasure. And very pleased to hear that you found the error. -Mark – Mark Viola Jun 16 '16 at 4:23