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 whose total is equivalent to for integration purposes; this reduces the problem to finding the integral of along a Jordan curve with interior Template:Tmath. The requirement that be holomorphic on is equivalent to the statement that the exterior derivative on Template:Tmath. Thus if two planar regions and of enclose the same subset of Template:Tmath, the regions and lie entirely in Template:Tmath, hence
is well-defined and equal to zero. Consequently, the contour integral of along is equal to the sum of a set of integrals along paths Template:Tmath, each enclosing an arbitrarily small region around a single — the residues of (up to the conventional factor 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.
The left-hand side goes to zero as Template:Math since is uniformly bounded on the contour, thanks to using on the left and right side of the contour, and so the integrand has order over the entire contour. On the other hand,[2]
where the Bernoulli numberTemplate:Tmath.
The same argument works for all where is a positive integer, giving us 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: