# how to calculate the value of $\int_{-\infty}^\infty \frac{e^{ax}}{\cosh x}\,dx$

So I have to evaluate $$\int_{-\infty}^\infty\frac{e^{ax}}{\cosh x} \, dx$$

I tried takeing the analytic expansion, and integrating over the real axis. I took this as being a half circle from $-\infty$ to $\infty$, minus the arc of the circle. over the arc I proved that the integral is zero, and I have left only with a sum of the residues of the function. With the help of a previous question I calculated the values of the residues, but I could not manage to converge the sum.

Help will be highly appreciated

• Please post the sum. Feb 13, 2018 at 4:39

The usual trick for this integral is to take a rectangular contour with vertices $\pm R$ and $\pm R+\pi i$ and let $R\to\infty$. This contains only one pole, simple at $z=\pi i/2$, and the integral over the top edge is closely related to that over the bottom edge (the one you care about).

• But then how do I evaluate the top edge? The integral that I get is very similar to the bottom integral but I don't see how to evaluate it Feb 13, 2018 at 5:02
• @Maxims What actually is that integral? Feb 13, 2018 at 5:15
• $\int_{-\infty}^\infty\frac{e^{ar}*e^{ia*\pi}}{e^{r}*e^{i*\pi}+e^{-r}*e^{-i*\pi}} \, dr$ . Where I used the substitution $z=e^{r+i*\pi}$ for $-\infty<r<\infty$ Feb 13, 2018 at 6:36

Assuming $a\in(-1,1)$ such integral equals $$\int_{0}^{+\infty}\frac{e^{ax}+e^{-ax}}{\cosh x}\,dx = 2 \int_{0}^{+\infty}\frac{\cosh(ax)}{\cosh x}\,dx =\frac{\pi}{\cos\frac{\pi a}{2}}\tag{1}$$ for instance by exploiting $$\int_{0}^{+\infty}\cosh(ax) e^{-(2m+1)x}\,dx =\frac{(2m+1)}{(2m+1)^2-a^2}\tag{2}$$ $$\sum_{m\geq 0}\frac{(2m+1)(-1)^m}{(2m+1)^2-a^2}\stackrel{\text{Herglotz trick}}{=} \frac{\pi}{4\cos\frac{\pi a}{2}}.\tag{3}$$

If we take the rectangular contour as in Lord Shark the Unknown's answer($$-R$$ to $$R$$ to $$R+\pi i$$ to $$-R+\pi i$$ to $$-R$$), we have, as he said, only one pole at $$\pi i \over 2$$ and not infinitely many.

We go along the contour in an anti clockwise direction.
Note: I assume that $$|a|<1$$, otherwise the integral does not converge. Also, the identity $$\cosh(x)=\frac{e^{x}+e^{-x}}{2}$$ will be of good use.

For the path on the real axis : $$x=t, dx=dt$$
$$\int_{-\infty}^{\infty}\frac{e^{at}}{\cosh(t)}dt$$

For the path from $$R$$ to $$R+\pi i$$ :
$$x=R+\pi i t, 0\leq t\leq 1, dx=\pi i dt$$
$$\int_{0}^{1} \frac{e^{a(R+\pi i t)}}{\frac{e^{(R+\pi i t)}+e^{-(R+\pi i t)}}{2}}\pi i dt$$.
Now, given that $$|a|<1$$, we get $$0$$ for $$R \to \infty$$ because for very large $$R$$, the term in the integral is proportional to $$\frac{e^{aR}}{e^R}=e^{(a-1)R}$$ which yields a negative exponent for $$|a|<1$$ and thus converges to $$0$$ for $$R \to \infty$$

For the path in the upper half plane parralel to the real axis :
$$x=t+\pi i, dx=dt$$
$$\int_{\infty}^{-\infty}\frac{e^{a(t+\pi i})}{cosh(t+\pi i)}dt=e^{a\pi i}\int_{\infty}^{-\infty}\frac{e^{at}}{cosh(t+\pi i)}dt=e^{a\pi i}\int_{\infty}^{-\infty}\frac{e^{at}}{-cosh(t)}dt=\\-e^{a\pi i}\int_{-\infty}^{\infty}\frac{e^{at}}{-cosh(t)}dt=e^{a\pi i}\int_{-\infty}^{\infty}\frac{e^{at}}{cosh(t)}dt$$

For the path from $$-R+\pi i$$ to $$-R$$ :
$$x=-R+t\pi i, dx=\pi idt, 1\geq t \geq 0$$
$$\int_{1}^{0} \frac{e^{a(-R+t\pi i)}}{\frac{e^{(-R+\pi i t)}+e^{-(-R+\pi i t)}}{2}}\pi idt$$ which tends to $$0$$ for $$R \to \infty$$ using a similar argument as before.

For the residue, we use $$\frac{g(x)}{h'(x)}=\frac{e^{ax}}{\sinh(x)}=\frac{e^{a\frac{\pi i}{2}}}{i}$$

Our original integral is $$I$$. With the Residue theorem, we get :
$$I+0+Ie^{a\pi i}+0=I(1+e^{a\pi i})+0+0=2\pi i \sum$$ Res $$=2\pi i \frac{e^{a\frac{\pi i}{2}}}{i}=2\pi e^{\frac{a\pi i}{2}}$$
Thus $$I=\frac{2\pi e^{\frac{a\pi i}{2}}}{(1+e^{a\pi i})}=\frac{2\pi}{e^{\frac{-a\pi i}{2}}+e^{\frac{a\pi i}{2}}}=\frac{\pi}{\cos(\frac{a\pi i}{2})}$$

$$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$$ \begin{align} &\bbox[10px,#ffd]{\left.\int_{-\infty}^{\infty}{\expo{ax} \over \cosh\pars{x}}\,\dd x\,\right\vert_{\ -1\ <\ \Re\pars{a}\ <\ 1}} = \int_{0}^{\infty}{2\cosh\pars{ax} \over \cosh\pars{x}}\,\dd x \\[5mm] & = 2\int_{0}^{\infty}{\cosh\pars{ax}\sinh\pars{x} \over \cosh\pars{x}\sinh\pars{x}}\,\dd x \\[5mm] & = 2\int_{0}^{\infty}{\bracks{\sinh\pars{x - ax} + \sinh\pars{x + ax}}/2 \over \sinh\pars{2x}/2}\,\dd x \\[5mm] \stackrel{x\ \mapsto\ x/4}{=}\,\,\, &\ {1 \over 2}\int_{0}^{\infty}{\bracks{\sinh\pars{\bracks{1 - a}x/4} + \sinh\pars{\bracks{1 + a}x/4}} \over \sinh\pars{x/2}}\,\,\dd x \\[5mm] = &\ \mrm{f}\pars{1 - a \over 2} + \mrm{f}\pars{1 + a \over 2}\label{1}\tag{1} \quad\mbox{where}\quad \mrm{f}\pars{\xi} \equiv {1 \over 2}\int_{0}^{\infty}{\sinh\pars{\xi x/2} \over \sinh\pars{x/2}}\,\dd x \end{align}

Moreover,

$$\mrm{f}\pars{\xi} = {1 \over 2}\int_{0}^{\infty}{\expo{\xi x/2} - \expo{-\xi x/2} \over \expo{x/2} - \expo{-x/2}}\,\dd x = 2\int_{0}^{\infty}{\expo{-\pars{1 - \xi}x/2} - \expo{-\pars{1 + \xi}x/2} \over 1 - \expo{-x}}\,\dd x$$

With $$\ds{\pars{~\expo{-x} \equiv t \implies x = -\ln\pars{t}~}}$$:

\begin{align} \mrm{f}\pars{\xi} & = {1 \over 2}\int_{0}^{1}{t^{-1/2 - \xi/2} - t^{-1/2 + \xi/2} \over 1 - t^{}}\,\dd x \\[5mm] & = {1 \over 2}\pars{% \int_{0}^{1}{1 - t^{-1/2 + \xi/2} \over 1 - t}\,\dd x - \int_{0}^{1}{1 - t^{-1/2 - \xi/2} \over 1 - t}\,\dd x} \\[5mm] & = {1 \over 2}\bracks{% \Psi\pars{{1 \over 2} + {\xi \over 2}} - \Psi\pars{{1 \over 2} - {\xi \over 2}}} \end{align} where $$\ds{\Psi}$$ is the Digamma Function. With Euler Reflection Formula: \begin{align} \mrm{f}\pars{\xi} & = {1 \over 2}\braces{\pi\cot\pars{\pi\bracks{{1 \over 2} - {\xi \over 2}}}} = {1 \over 2}\,\pi\tan\pars{{\pi \over 2}\,\xi}\label{2}\tag{2} \end{align}

With \eqref{1} and \eqref{2}

$$\bbx{\left.\int_{-\infty}^{\infty}{\expo{ax} \over \cosh\pars{x}}\,\dd x\,\right\vert_{\ -1\ <\ \Re\pars{a}\ <\ 1} = \pi\sec\pars{\pi a \over 2}}$$