A real integral evaluated over a rectangular contour
When an integrand combines exponential functions with a rational factor such as \(\frac{1}{x^2+\pi^2}\), a rectangular contour of height \(2\pi\) can exploit the periodicity of \(e^z\) in the imaginary direction while building the rational factor from the difference of two simple fractions. Using this technique, we will prove that for every \(a \in \mathbb{R}\),
Setting up the rectangular contour
Consider the complex function
Notice why \(f(z)\) is well suited to the horizontal lines \(\operatorname{Im} z = \pm \pi\): on those lines \(e^{x \pm i\pi} = -e^x\) and \(e^{2(x \pm i\pi)} = e^{2x}\), so the exponential factor \(\frac{e^z}{e^{2z}+e^{2a}}\) takes the exact same value \(-\frac{e^x}{e^{2x}+e^{2a}}\) on both horizontal edges, while the remaining factor \(\frac{1}{z}\) produces
Let \(\Gamma\) be the positively oriented rectangle in the complex plane with vertices \(R-i\pi\), \(R+i\pi\), \(-R+i\pi\), and \(-R-i\pi\), where \(R > |a|\):
Computing the residues inside the contour
Inside \(\Gamma\), the denominator \((e^{2z}+e^{2a})z\) vanishes at three points, each of which is a simple pole of \(f(z)\):
- At \(z = 0\), the residue is
- The solutions of \(e^{2z} = -e^{2a} = e^{2a \pm i\pi}\) with \(\operatorname{Im} z \in (-\pi, \pi)\) are \(z_\pm = a \pm \frac{i\pi}{2}\). At a simple zero \(z_0\) of \(e^{2z}+e^{2a}\), differentiating the denominator gives \(\frac{d}{dz}(e^{2z}+e^{2a})\big|_{z=z_0} = 2e^{2z_0} = -2e^{2a}\). Since \(e^{a \pm i\pi/2} = \pm i e^a\), the residues at \(z_\pm\) are
By the residue theorem,
Relating the contour integral to the real integral
Breaking \(\Gamma\) into its four sides and parameterizing the bottom and top edges by \(z = x \mp i\pi\) for \(x \in [-R, R]\), we have
Bounding the vertical segments
On the right vertical edge \(z = R + iy\) with \(y \in [-\pi, \pi]\), we have \(|R+iy| \geq R\) and, by the reverse triangle inequality for \(R > |a|\),
Hence
Similarly, on the left vertical edge \(z = -R + iy\), we have \(|e^z| = e^{-R}\) and \(|e^{-2R+2iy} + e^{2a}| \geq e^{2a} - e^{-2R}\) for \(R > |a|\), so
From bounds (3) and (4), both vertical integrals tend to \(0\) as \(R \to \infty\). Equating (1) and (2) in the limit \(R \to \infty\) and dividing by \(-2\pi i\) yields