The residue theorem

This applet is a variant of Applet 6, Complex Integration.  The function is now specified by locating its poles and residues.  Also, the integral has been divided by 2 pi in order to make the residue theorem clearer.

Note that every time a contour goes anti-clockwise around a pole, the integral increases by 2 pi i times the residue at that pole.  Similarly if a contour winds once clockwise around a pole, the integral decreases by 2 pi i times the residue at that pole.  Try making a function with several poles at different places, and testing contours that go around several poles, or go around different poles a different number of times.

NB: There will be an inaccuracy of about +- 5% in the final integral, basically because all integrals are being computed numerically (in fact, I'm using the so-called Midpoint Rule).  The inaccuracy gets especially bad if the contour gets too close to a pole.