Residue theorem (source code)

= Residue theorem
{title2=$\oint_\Gamma f(z)\,dz=2\pi i\sum_j\operatorname{Res}(f,a_j)$}
{wiki}

= Cauchy's residue theorem
{c}
{synonym}

Let $\Gamma$ be a piecewise smooth <contour> forming a <simple closed curve>, positively oriented: travel counterclockwise, with the interior on the left. Suppose $f$ is <holomorphic> on an <open set> containing $\Gamma$ and its interior, except at finitely many <isolated singularities> $a_1,\ldots,a_m$ strictly inside. Then
$$
\oint_\Gamma f(z)\,dz=2\pi i\sum_{j=1}^m\operatorname{Res}(f,a_j).
$$
No <isolated singularity> may lie on $\Gamma$: the ordinary <contour integral> must be defined there. Reversing the direction of the <contour> reverses the sign of the answer. The theorem applies to <essential singularities> as well as <poles>. https://ocw.mit.edu/courses/18-04-complex-variables-with-applications-spring-2018/3c58ce71ec6f7573804221d76158a0bd_MIT18_04S18_topic8.pdf[Orloff, MIT Topic 8, section 8.5]{ref}

Return to $f(z)=1/(z^2+1)$. A counterclockwise <circle> $|z|=2$ encloses both <simple poles>, so
$$
\oint_{|z|=2}\frac{dz}{z^2+1}
=2\pi i\left(-\frac{i}{2}+\frac{i}{2}\right)=0.
$$
Yet $f$ is nonzero everywhere it is defined. A zero <contour integral> does not imply a zero <function>, or even absence of <poles>: the enclosed <residues> can cancel. By contrast, the counterclockwise <circle> $|z-i|=1/2$ encloses only $i$, giving
$$
\oint_{|z-i|=1/2}\frac{dz}{z^2+1}
=2\pi i\left(-\frac{i}{2}\right)=\pi.
$$
The picture compares these two selections. Changing the shape of a <contour> while keeping the same enclosed <poles> leaves the <contour integral> unchanged, provided the <contour deformation> stays where $f$ is <holomorphic>.

\Image[/residue-contour-selection.png]
{title=Two contour choices for $1/(z^2+1)$: cancellation around both poles, and integral $\pi$ around $i$}

This is the practical appeal of the <residue theorem>: local <Laurent coefficients> determine a global <contour integral>. For a <rational function>, a few <simple pole> computations can replace a long parametrized calculation. It also makes real <improper integrals> accessible by treating the <real line> as part of a closed <contour> in the <complex plane>.

To compute $I=\int_{-\infty}^{\infty}dx/(1+x^2)$, take $R>1$ and travel along the <real line> from $-R$ to $R$, then return along the upper <semicircle> $A_R$, parametrized by $z=Re^{it}$ for $0\leq t\leq\pi$. This <contour> is positively oriented and encloses the <simple pole> $i$ only; $-i$ is outside. Hence
$$
\int_{-R}^{R}\frac{dx}{1+x^2}
+\int_{A_R}\frac{dz}{1+z^2}=\pi.
$$
The added arc must be controlled before taking a limit. On $A_R$, the <reverse triangle inequality> gives $|z^2+1|\geq R^2-1$, and the <arc length> is $\pi R$. The <estimation lemma> therefore yields
$$
\left|\int_{A_R}\frac{dz}{1+z^2}\right|
\leq\frac{\pi R}{R^2-1}\longrightarrow0.
$$
The denominator grows quadratically while the <arc length> grows only linearly. This quantitative comparison, rather than a sketch alone, explains why closing the <contour> does not alter the limiting real <improper integral>. It even supplies an error bound: the difference between $\pi$ and the finite real <integral> is at most $\pi R/(R^2-1)$.

For a numerical check, $R=10$ gives the finite real <integral> $2\arctan(10)\approx2.94226$, leaving about $0.19934$ to reach $\pi$. The arc bound is $10\pi/99\approx0.31733$, comfortably larger than that error. The graph shows both quantities approaching zero. The exact tail here can be checked with the <antiderivative> $\arctan x$; the <residue theorem> method remains useful for <improper integrals> where a convenient real <antiderivative> is unavailable.

\Image[/residue-real-integral.png]
{title=Upper semicircle orientation and convergence of the real integral, with the bound $\pi R/(R^2-1)$}

Finally, both one-sided <improper integrals> converge absolutely: for $|x|\geq1$, $0<1/(1+x^2)\leq1/x^2$, whose tails are integrable. Thus the symmetric limit computes the ordinary <improper integral>, not merely a <Cauchy principal value>, and
$$
\int_{-\infty}^{\infty}\frac{dx}{1+x^2}=\pi.
$$
Closing below instead would enclose the <simple pole> $-i$. With the same left-to-right traversal of the <real line>, that <contour> is clockwise, so its <contour integral> is $-2\pi i\operatorname{Res}(f,-i)=\pi$ again. This provides a useful sign check: the opposite <residue> is accompanied by the opposite direction around the enclosed region.

The same strategy extends to many other <rational functions>: choose a <contour>, identify its enclosed <isolated singularities>, compute their <residues>, and bound the added pieces. The choice of <contour> and the bound are as much part of the calculation as the <residues>. https://ocw.mit.edu/courses/18-04-complex-variables-with-applications-spring-2018/f69bc227ae476839819fb18e5b283072_MIT18_04S18_topic9.pdf[Orloff, MIT Topic 9, sections 9.1–9.3]{ref}