## The art of using the Residue Theorem in evaluating definite integrals

As many of you know, using the Residue Theorem to evaluate a definite integral involves not only choosing a contour over which to integrate a function, but also choosing a function as the integrand. Many times, this is an easy task when integrating, say, rational functions over the real line. Sometimes there are less trivial but still well-known techniques, such as multiplying a function to be integrated over the positive reals by $\log{z}$ and integrating over a keyhole contour. And sometimes we just have to fumble our way through, as I will illustrate with the following example.

The problem is to evaluate

$$\int_{0}^{\infty} dx \frac {\sinh ax \sinh bx}{\cosh cx}$$

Consider the contour integral

$$\oint_C dz \frac{\sinh{a z} \sinh{b z}}{\sinh{c z}}$$

where $C$ is the rectangle $-R-i \pi/(2 c), R-i \pi/(2 c), R+i \pi/(2 c), -R+i \pi/(2 c)$. Note that

$$\sinh{c (x \pm i \pi/2 c)} = \pm i \cosh{c x}$$

Therefore the contour integral is

$$\int_{-R}^R dx \, \frac{\sinh{a(x-i \pi/(2 c))} \sinh{b(x-i \pi/(2 c))}}{-i \cosh{c x}}\\ +i \int_{-\pi/(2 c)}^{\pi/(2 c)} dy \, \frac{\sinh{a (R+i y)} \sinh{b (R+i y)}}{\sinh{c (R+i y)}}\\ + \int_{R}^{-R} dx \, \frac{\sinh{a(x+i \pi/(2 c))} \sinh{b(x+i \pi/(2 c))}}{i \cosh{c x}} \\-i \int_{\pi/(2 c)}^{-\pi/(2 c)} dy \, \frac{\sinh{a (R-i y)} \sinh{b (R-i y)}}{\sinh{c (R-i y)}}$$

Note that, for the second and fourth integrals to vanish as $R \to \infty$, we must have $|a|+|b| \lt |c|$; assume this is the case. The contour integral then becomes, after simplification (the algebra of which I will spare the reader) (*):

$$i 2 \cos \left(\frac{\pi a}{2 c}\right) \cos \left(\frac{\pi b}{2 c}\right) \int_{-\infty}^{\infty} dx \frac{ \sinh (a x) \sinh (b x)}{\cosh{c x}}\\-i 2 \sin \left(\frac{\pi a}{2 c}\right) \sin \left(\frac{\pi b}{2 c}\right) \int_{-\infty}^{\infty} dx \frac{\cosh (a x) \cosh (b x)}{\cosh{c x}}$$

Note that we don’t quite have the integral we want. So now consider

$$\oint_C dz \frac{\cosh{a z} \cosh{b z}}{\sinh{c z}}$$

and as a result of similar steps as above, the contour integral becomes (**)

$$i 2 \cos \left(\frac{\pi a}{2 c}\right) \cos \left(\frac{\pi b}{2 c}\right) \int_{-\infty}^{\infty} dx \frac{ \cosh (a x) \cosh (b x)}{\cosh{c x}}\\-i 2 \sin \left(\frac{\pi a}{2 c}\right) \sin \left(\frac{\pi b}{2 c}\right) \int_{-\infty}^{\infty} dx \frac{\sinh (a x) \sinh (b x)}{\cosh{c x}}$$

We can eliminate the integral we are not seeking by multiplying $\text{(*)}$ by $\cos \left(\frac{\pi a}{2 c}\right) \cos \left(\frac{\pi b}{2 c}\right)$ and $\text{(**)}$ by $\sin \left(\frac{\pi a}{2 c}\right) \sin \left(\frac{\pi b}{2 c}\right)$. Thus, really, we are then seeking

$$\oint_C dz \, \frac{f(z)}{\sinh{c z}}$$

where

$$f(z) = \cos \left(\frac{\pi a}{2 c}\right) \cos \left(\frac{\pi b}{2 c}\right) \sinh{a z} \sinh{b z} + \sin \left(\frac{\pi a}{2 c}\right) \sin \left(\frac{\pi b}{2 c}\right) \cosh{a z} \cosh{b z}$$

The contour integral now takes the form

$$i 2 \left [\cos^2 \left(\frac{\pi a}{2 c}\right) \cos^2 \left(\frac{\pi b}{2 c}\right) – \sin^2 \left(\frac{\pi a}{2 c}\right) \sin^2 \left(\frac{\pi b}{2 c}\right) \right ] \int_{-\infty}^{\infty} dx \frac{\sinh (a x) \sinh (b x)}{\cosh{c x}}$$

This is equal to $i 2 \pi$ times the residue of $f(z) \operatorname{csch}{c z}$ at the pole $z=0$, which is simply $f(0)/c$. Using the symmetry of the integral, we finally have

\begin{align}\int_{0}^{\infty} dx \frac{\sinh (a x) \sinh (b x)}{\cosh{c x}} &= \frac{\pi}{2 c} \frac{\sin \left(\frac{\pi a}{2 c}\right) \sin \left(\frac{\pi b}{2 c}\right )}{\cos^2 \left(\frac{\pi a}{2 c}\right) \cos^2 \left(\frac{\pi b}{2 c}\right) – \sin^2 \left(\frac{\pi a}{2 c}\right) \sin^2 \left(\frac{\pi b}{2 c}\right) } \\ &= \frac{\pi}{4 c} \frac{\cos{\left(\frac{\pi (a-b)}{2 c}\right)}-\cos{\left(\frac{\pi (a+b)}{2 c}\right)}}{\cos{\left(\frac{\pi (a-b)}{2 c}\right)} \cos{\left(\frac{\pi (a+b)}{2 c}\right)}}\\ &= \frac{\pi}{4 c} \left [\sec{\left(\frac{\pi (a+b)}{2 c}\right)}-\sec{\left(\frac{\pi (a-b)}{2 c}\right)} \right ] \end{align}

where, again, $|a|+|b|\lt|c|$.

### A crazy-ass integral, the evaluation of which got a lot of love at Math.SE

There are a lot of integrals posted at Math.SE. I attempt to evaluate quite a few of them. Many times, I fail spectacularly; you will typically not hear of those because I feel there is nothing to say. Occasionally, I succeed; of course, you will hear about those because I post and then post again […]