Residue theorem: Let <math>U</math> be a simply connectedopen subset of the complex plane containing a finite list of points Template:Tmath, Template:Tmath, and a function <math>f</math> holomorphic on Template:Tmath. Letting <math>\gamma</math> be a closed rectifiable curve in Template:Tmath, and denoting the residue of <math>f</math> at each point <math>a_k</math> by <math>\operatorname{Res}(f, a_k)</math> and the winding number of <math>\gamma</math> around <math>a_k</math> by Template:Tmath, the line integral of <math>f</math> around <math>\gamma</math> is equal to <math>2\pi i</math> times the sum of residues, each counted as many times as <math>\gamma</math> winds around the respective point:
<math display=block>
\oint_\gamma f(z)\, dz = 2\pi i \sum_{k=1}^n \operatorname{I}(\gamma, a_k) \operatorname{Res}(f, a_k).
</math>
If <math>\gamma</math> is a positively orientedsimple closed curve, <math>\operatorname{I}(\gamma, a_k)</math> is <math>1</math> if <math>a_k</math> is in the interior of <math>\gamma</math> and <math>0</math> if not, therefore
<math display=block>
\oint_\gamma f(z)\, dz = 2\pi i \sum \operatorname{Res}(f, a_k)
</math>
with the sum over those <math>a_k</math> inside Template:Tmath.[1]
The relationship of the residue theorem to Stokes' theorem is given by the Jordan curve theorem. The general plane curveTemplate:Mvar must first be reduced to a set of simple closed curves <math>\{\gamma_i\}</math> whose total is equivalent to <math>\gamma</math> for integration purposes; this reduces the problem to finding the integral of <math>f\, dz</math> along a Jordan curve <math>\gamma_i</math> with interior Template:Tmath. The requirement that <math>f</math> be holomorphic on <math>U_0 = U \smallsetminus \{a_k\}</math> is equivalent to the statement that the exterior derivative <math>d(f\, dz) = 0</math> on Template:Tmath. Thus if two planar regions <math>V</math> and <math>W</math> of <math>U</math> enclose the same subset <math>\{a_j\}</math> of Template:Tmath, the regions <math>V \smallsetminus W</math> and <math>W \smallsetminus V</math> lie entirely in Template:Tmath, hence
<math display=block>
\int_{V \smallsetminus W} d(f \, dz) - \int_{W \smallsetminus V} d(f \, dz)
</math>
is well-defined and equal to zero. Consequently, the contour integral of <math>f\, dz</math> along <math>\gamma_j = \partial V</math> is equal to the sum of a set of integrals along paths Template:Tmath, each enclosing an arbitrarily small region around a single <math>a_j</math> — the residues of <math>f</math> (up to the conventional factor <math>2\pi i</math> at Template:Tmath. Summing over Template:Tmath, we recover the final expression of the contour integral in terms of the winding numbers Template:Tmath.
In order to evaluate real integrals, the residue theorem is used in the following manner: the integrand is extended to the complex plane and its residues are computed (which is usually easy), and a part of the real axis is extended to a closed curve by attaching a half-circle in the upper or lower half-plane, forming a semicircle. The integral over this curve can then be computed using the residue theorem. Often, the half-circle part of the integral will tend towards zero as the radius of the half-circle grows, leaving only the real-axis part of the integral, the one we were originally interested in.
Since Template:Math is an entire function (having no singularities at any point in the complex plane), this function has singularities only where the denominator Template:Math is zero. Since Template:Math, that happens only where Template:Math or Template:Math. Only one of those points is in the region bounded by this contour. Because Template:Math is
<math display="block">\begin{align}
\frac{e^{itz}}{z^2+1} & =\frac{e^{itz}}{2i}\left(\frac{1}{z-i}-\frac{1}{z+i}\right) \\
& =\frac{e^{itz}}{2i(z-i)} -\frac{e^{itz}}{2i(z+i)} ,
\end{align}</math>
the residue of Template:Math at Template:Math is
<math display="block">\operatorname{Res}_{z=i}f(z)=\frac{e^{-t}}{2i}.</math>
According to the residue theorem, then, we have
<math display="block">\int_C f(z)\,dz=2\pi i\cdot\operatorname{Res}\limits_{z=i}f(z)=2\pi i \frac{e^{-t}}{2i} = \pi e^{-t}.</math>
The contour Template:Mvar may be split into a straight part and a curved arc, so that
<math display="block">\int_{\mathrm{straight}} f(z)\,dz+\int_{\mathrm{arc}} f(z)\,dz=\pi e^{-t}</math>
and thus
<math display="block">\int_{-a}^a f(z)\,dz =\pi e^{-t}-\int_{\mathrm{arc}} f(z)\,dz.</math>
Using some estimations, we have
<math display="block">\left|\int_{\mathrm{arc}}\frac{e^{itz}}{z^2+1}\,dz\right| \leq \pi a \cdot \sup_{\text{arc}} \left| \frac{e^{itz}}{z^2+1} \right| \leq \pi a \cdot \sup_{\text{arc}} \frac{1}{|z^2+1|} \leq \frac{\pi a}{a^2 - 1},</math>
and
<math display="block">\lim_{a \to \infty} \frac{\pi a}{a^2-1} = 0.</math>
The estimate on the numerator follows since Template:Math, and for complex numbersTemplate:Mvar along the arc (which lies in the upper half-plane), the argument Template:Mvar of Template:Mvar lies between 0 and Template:Pi. So,
<math display="block">\left|e^{itz}\right| = \left|e^{it|z|(\cos\varphi + i\sin\varphi)}\right|=\left|e^{-t|z|\sin\varphi + it|z|\cos\varphi}\right|=e^{-t|z| \sin\varphi} \le 1.</math>
<math display="block">\int_{-\infty}^\infty\frac{e^{itz}}{z^2+1}\,dz=\pi e^t,</math>
and finally we have
<math display="block">\int_{-\infty}^\infty\frac{e^{itz}}{z^2+1}\,dz=\pi e^{-\left|t\right|}.</math>
(If Template:Math then the integral yields immediately to elementary calculus methods and its value is Template:Pi.)
Evaluating zeta functions
The fact that Template:Math has simple poles with residue 1 at each integer can be used to compute the sum
<math display="block"> \sum_{n=-\infty}^\infty f(n).</math>
Consider, for example, Template:Math. Let Template:Math be the rectangle that is the boundary of Template:Math with positive orientation, with an integer Template:Mvar. By the residue formula,
<math display="block">\frac{1}{2 \pi i} \int_{\Gamma_N} f(z) \pi \cot(\pi z) \, dz = \operatorname{Res}\limits_{z = 0} + \sum_{n = -N \atop n\ne 0}^N n^{-2}.</math>
The left-hand side goes to zero as Template:Math since <math>|\cot(\pi z)|</math> is uniformly bounded on the contour, thanks to using <math>x = \pm \left(\frac 12 + N\right)</math> on the left and right side of the contour, and so the integrand has order <math>O(N^{-2})</math> over the entire contour. On the other hand,[2]
<math display="block">\frac{z}{2} \cot\left(\frac{z}{2}\right) = 1 - B_2 \frac{z^2}{2!} + \cdots </math> where the Bernoulli numberTemplate:Tmath.
(In fact, Template:Math.) Thus, the residue Template:Math is Template:Math. We conclude:
<math display="block">\sum_{n = 1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}</math>
which is a proof of the Basel problem.
The same argument works for all <math>f(x) = x^{-2n}</math> where <math>n</math> is a positive integer, giving us<math display="block"> \zeta(2n) = \frac{(-1)^{n+1}B_{2n}(2\pi)^{2n}}{2(2n)!}.</math> The trick does not work when Template:Tmath, since in this case, the residue at zero vanishes, and we obtain the useless identity Template:Tmath.
Evaluating Eisenstein series
The same trick can be used to establish the sum of the Eisenstein series:<math display="block">\pi \cot(\pi z) = \lim_{N \to \infty} \sum_{n=-N}^N (z - n)^{-1}.</math>