Example

Here is a simple example. Suppose we want to find the integral of from 0 to . We begin by choosing an analytic branch of the logarithm, defined everywhere in except for the line consisting of negative purely imaginary numbers (that is, where is specified to take values in . Now, choose real numbers where and . Then, let be the positively oriented contour consisting of the clockwise upper semicircular arc from to , the directed line segment from to , the anticlockwise semicircular arc from to , and the directed line segment from to (this looks like a rainbow in the complex plane).

The reason we chose this contour is that it necessarily avoids the inevitable singularity of the logarithm at 0, and it includes inside of it, the pole of the function . By Cauchy's residue theorem, we have = times the residue of the pole at . This is easily calculated, and it is equal to . Thus, the integral evaluates to .

The idea is to now take and . Some easy calculations (left to the reader) show that the integrals along the semicircular arcs vanish, leaving us with only the integrals along the real axes. For we get back the integral we are trying to calculate , and on we get (since arg here is equal to ): Thus, plugging everything back in, , so .