# Evaluating $\int_{-\infty}^{\infty}\frac{e^{ax}}{\cosh{x}}dx$ using contour integration

Let $$a \in \mathbb{C}$$ with $$-1 <$$ Re $$a < 1$$. By considering a rectangular contour with corners at $$R, R + i\pi, -R+ i\pi, -R,$$ show that

$$\int_{-\infty}^{\infty}\frac{e^{ax}}{\cosh{x}}dx = \pi\sec\left( \frac{\pi a}{2}\right)$$

and hence evaluate, for real $$n$$,

$$\int_{-\infty}^{\infty}\frac{\cos nx}{\cosh{x}}dx$$

I can do everything in the question except showing that the integrals along the two sides of the rectangle vanish as $$R$$ tends to infinity.

I have these two paths as $$\gamma_1(t) = R +it$$ for $$t\in[0,\pi]$$ and $$\gamma_2(t) = -R + (\pi-t)i$$ for $$t\in[0,\pi]$$. I'm pretty sure these are right, but I really can't see how the integral of $$\frac{e^{az}}{\cosh{z}}$$ goes to zero when you integrate along these.

• @Martin Vacas Vignolo: No, the integral isn't zero along the rectangle. There's a pole at $\frac{\pi i}{2}$, and the two main segments end up reinforcing each other (a negative for flipping the values, another for switching direction). – jmerry Dec 31 '18 at 1:34
• @jmerry The integral along the two vertical sides indeed goes to $0$ as $R\to\infty$ – Dylan Jan 1 at 10:49
• @Dylan: Not disputing that - it's what my answer was about. My comment above was about the integral as a whole, and how the horizontal segments contribute. – jmerry Jan 1 at 10:51
• @jmerry Nevermind, I saw that you were replying to someone else – Dylan Jan 1 at 10:54

I'll provide the complete solution to the integral. Inside the proof, I've detailed by the side integrals tend towards zero along with how to complete the proof, in case you were having trouble with it.

Denote the function $$f(z)$$ as$$f(z)=\frac {e^{az}}{\cosh z}$$And take the rectangular contour with vertices of $$\pm R$$ and $$\pm R+\pi i$$. Integrating about each section of the contour $$\mathrm C$$, the contour integral is equal to$$\begin{multline}\oint\limits_{\mathrm C}\mathrm dz\, f(z)=\int\limits_{-R}^{R}\mathrm dx\, f(x)+i\int\limits_0^{\pi}\mathrm dx\, f(R+\pi i)-\int\limits_{-R}^{R}\mathrm dx\, f(x+\pi i)-i\int\limits_0^{\pi}\mathrm dx\, f(-R+\pi i)\end{multline}$$Now let's observe the second, third, and fourth integral separately. From the function $$f(z)$$, it should be quite obvious what each of the integrands are\begin{align*}f(R+\pi i) & =-\frac {e^{a(R+\pi i)}}{\cosh R}\sim -e^{\pi a i}e^{R(a-1)}\\f(-R+\pi i) & =-\frac {e^{a(-R+\pi i)}}{\cosh R}\sim -e^{\pi a i}e^{-R(a+1)}\\f(x+\pi i) & =-\frac {e^{a(x+\pi i)}}{\cosh x}=-e^{\pi a i}f(x)\end{align*} Note that in the first two equations, I've used the fact that $$\operatorname{sech} x$$ behaves like $$e^{-x}$$ for large values of $$x$$. Now we use the fact that $$|a|<1$$. This means that $$a$$ will always be a fraction smaller than one. Hence, for the first equality, $$a-1<0$$. What this means is that the exponential function is actually decreasing which means as $$R\to\infty$$, then$$\int\limits_0^{\pi}\mathrm dx\, f(R+\pi i)\xrightarrow{\phantom{hello}}0$$Similarly, the second equality tends towards zero because $$a$$ will be a positive number if added by one, so the exponential function is once again negative. Therefore$$\int\limits_0^{\pi}\mathrm dx\, f(-R+\pi i)\xrightarrow{\phantom{hello}}0$$

What's left now is$$\oint\limits_{\mathrm C}\mathrm dz\, f(z)=(1+e^{\pi a i})\int\limits_{-\infty}^{\infty}\mathrm dx\, f(x)$$The contour integral is also equal to $$2\pi i$$ times the sum of its residues. The rectangular contour encloses only one singularity at $$z=\tfrac {\pi i}2$$ of order one. Therefore, the calculations are as follows\begin{align*}\operatorname*{Res}_{z\, =\, \tfrac {\pi i}2}f(z) & =\lim\limits_{z\,\to\,\tfrac {\pi i}2}\frac {\left(z-\tfrac {\pi i}2\right)e^{az}}{\cosh z}\\ & =\frac {e^{\pi a i/2}}i\end{align*}Thus\begin{align*}\int\limits_{-\infty}^{\infty}\mathrm dx\, f(x) & =\frac {2\pi e^{\pi a i/2}}{1+e^{\pi a i}}\end{align*}

Dividing both the numerator and denominator by $$e^{\pi a i/2}$$ for simplification finally gives the closed form as$$\int\limits_{-\infty}^{\infty}\mathrm dx\,\frac {e^{ax}}{\cosh x}\color{blue}{=\pi\sec\left(\frac {\pi a}2\right)}$$The proof for the second part of the question can be completed by replacing $$a$$ with $$ni$$ and taking the real part of both sides.

Let's write everything in terms of exponentials; the integrand is $$\frac{2\exp(ax)}{\exp(x)+\exp(-x)}$$. For $$x$$ with large positive real part, the first term $$e^x$$ of the denominator is much larger than the second term $$e^{-x}$$, so the overall fraction is very close to $$\frac{2\exp(ax)}{\exp(x)}=2e^{(a-1)x}$$. Now we use that condition about $$a$$ - since its real part is less than $$1$$, $$a-1$$ has negative real part, and $$e^{(a-1)x}$$ goes to zero (exponentially fast, not that we really need that). Well, OK, we need more than just a large real part for $$x$$ there; we also need it to be close to the real axis in angular terms, so that multiplying by $$a-1$$ doesn't rotate it back to the right-hand half-plane. Fortunately, the vertical edge of the rectangle we're looking at is close to the real axis.
For the vertical edge at $$-R$$, we do the same thing, except that it's $$e^{-x}$$ that dominates the denominator, and $$a+1$$ has positive real part.

Let $$a=b+ci$$. First rewrite the function in exponential form

$$f(z) = \frac{e^{az}}{\cosh z} = \frac{2e^{az}}{e^z+e^{-z}} = \frac{2e^{(1+a)z}}{e^{2z}+1}$$

On the straight line from $$R$$ to $$R+i\pi$$ the integral is

$$\int_{y\in(0,\pi)} f(R+iy)dy = \int_0^\pi \frac{e^{(1+a)(R+iy)}}{e^{2(R+iy)}+1}dy$$

The ML inequality gives an upper bound for the magnitude of this integral

$$\left\vert \int_0^\pi \frac{e^{(1+a)(R+iy)}}{e^{2(R+iy)}+1}dy \right\vert \le \pi \max \left\vert\frac{e^{(1+a)(R+iy)}}{e^{2(R+iy)}+1} \right\vert$$

where

$$|e^{(1+b+ci)(R+iy)}| = e^{(1+b)R-cy} \le e^{(b+1)R}$$

And from the triangle inequality

$$|e^{2(R+iy)}-(-1)| \ge ||e^{2(R+iy)}|-|-1|| = e^{2R}-1$$

Thus

$$\left\vert \int_{y\in(0,\pi)} f(R+iy)dy \right\vert \le \frac{\pi e^{(1+b)R}}{e^{2R}-1}$$

As $$R\to \infty$$, the upper bound goes to $$0$$

$$\frac{\pi e^{(1+b)R}}{e^{2R}-1} \to \pi e^{-(1-b)R} \to 0$$

and hence the integral must also go to $$0$$.

You can apply the same process for the other vertical line, replacing $$R$$ with $$-R$$

$$\left\vert \int_{y\in(0,\pi)} f(-R+iy)dy \right\vert \le \frac{\pi e^{-(1+b)R}}{1-e^{-2R}} \to \pi e^{-(1+b)R} \to 0$$