## 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|$.

• Hi Ron, I am an undergraduate physics student, struggling through my first course involving Residue calculus. I have seen your answer on maths stack exchange regarding the Fourier transform of the sinc function. http://math.stackexchange.com/questions/281870/fourier-transform-of-frac-sinxx I understand the method you have used, and I know you have the right answer. However, when I compute using the same methods, just skipping some steps by using the half residue rule, I don’t get the two integrals cancelling for mod(v)>1/2pi and equal to pi for mod(v)0. As far as I can tell this is not true. If the result is i*pi then the upper half plane has been used, however in this case the exponential diverges.
Ignoring the contents of the bracketed exponent, just calling it a, you have that for the integral involving e^i*x*a equal to i*pi and also e^-i*x*a also equal to i*pi both for a>0, this clearly can’t be true.
I have spent 7 hours on this so far and I know you are right somehow, but I cannot reconcile the fact that if the bracketed term in the exponent is positive, but there is also a minus sign in the exponent, the result show be -i*pi not i*pi as you have it. And yet if you agree with me you do not get the rectangle function, which I know is correct. I apologise for such a poorly worded question, I hope you are able to help.
Cheers

• Hi Alex, thanks for writing and I am sorry that you spent so much time on this problem. I did this derivation over three years ago and I am shocked by its sloppiness. Not one of my best examples to follow! (What is equal to $\pm i \pi$ is not the integral but the Cauchy PV of the integral.) That all said, without seeing your work, perhaps the problem is that in the lower half-plane, the contour is traversed in the opposite direction. Thus, instead of integrating over the little bump at the origin from $[\pi,0]$ as in the upper case, one integrates from $[2 \pi,\pi]$ in the lower case. Is that the problem? Let me know.

And, really, if you want to learn contour integration from my work on Stack Exchange or even on this blog, there are much much much better examples than this frankly embarrassing one.

• Hi Ron thanks for the rapid reply. On our course we have been taught to use the Half Residue rule, whereby you apply half the usual residue if the pole lies on the contour as it does if you take a simple semicircular contour. The result was derived using the contour that you used. The residue of e^ikx/x and e^-ikx/x are both 1. If the k is positive then the upper half plane is used for e^ikx/x, in which case the real line is traversed left to right and hence the integral over the real line, when the radius of the semicircle is taken to infinity yields i*pi, a positive constant. For e^-ikx/x the lower half plane must be used, and so, as you say, the real line is traversed backwards, as such when the result yields i*pi the sign needs to be flipped because we want the real line from -inf to inf. As far as I am aware a antisymmetric argument holds for k being negative, in which case e^ikx/x must use the lower half plane and e^-ikx/x use the upper half. So the two integrals give the same result differing by a sign for k>0 and k<0, thus equaling 2ipi or -2ipi in either case. Which I know is incorrect. In your work through you have the exponent constant, which I have called k in both case, although it is actually different as you show, when it is greater than 0, both the e^ikx/x and e^-ikx/x integrals yield i*pi. I don't see how this can be true. On wolfram alpha if you enter e^-ix/x (i.e. k=1) the result in -i*pi for the Cauchy PV. Whereas you have written when the exponent is positive that the Cauchy PV is +i*pi.

• In fact, more succinctly, you have that for mod(v)<1/2pi the result is pi. mod(v)<1/2pi is equivalent to -1/2pi<v<1/2pi, matching the results you list this results in (1/2i)(i*pi-i*pi)=0 not pi as you have shown.

• Konstantinos wrote:

Dear Ron,

Firstly I would like to thank you for sharing knowledge through this website.
I am a master student of mathematical modelling in modern technologies and I am being involved with nonlinear optics in my Master thesis. My thesis objective is to find intersections of hyperbolic invariant manifolds of a dynamical system in order to prove soliton existence for NLSE. In order to find the condition for manifold intersection I have to calculate the integrals of the from of: integral from minus infinity to infinity of sech(t)sin(ωt+φ).
I would be grateful if you could give me some hints or even help me to evaluate it.

With respect,
Konstantinos

• Hi Konstantinos,

Thanks so much for writing in. The integral you describe looks like the Fourier transform of sech(t), which I derive here. The specific integral you describe has the value $\pi \operatorname{sech}{(\pi \omega/2)} \sin{\phi}$. I hope this helps.

Ron

• Konstantinos wrote:

Thank you very much for your reply! Your post gave me the answer and the way you handled the proof gave me a lot of enthusiasm! I would be grateful if you could answer me with some tittles of books regarding integration which you believe that their contribution to your way of thinking regarding integral solutions is of great importance.

• Probably the most valuable books I have are “Applied Analysis by the Hilbert Space Method” by Sam Holland, “Complex Analysis” by Ahlfors (the courses based on these two books were taught to me by Prof. Holland (the one who wrote the first book). Another very valuable reference is “Advanced Mathematical Methods for Scientists and Engineers” by Bender and Orszag, which despite the awful, vague title, is an invaluable resource for evaluating horrible sums, integrals, and differential equations. You may be tempted to acquire “The Cauchy Method of Residues” by Bialynicki-Birulda, but I feel the instruction tends toward the general in favor of the instructive – although there are valuable nuggets in there. The ultimate book – which every practitioner should have – is “A Course in Pure Mathematics” by Hardy; aside from the instruction being great, there are very difficult integrals and sums to conquer in there. Good luck!