Skip to content
DeepForgeby svx
All problems
HardCalculusca-183

Residue Theorem Integral

Problem

Evaluate the contour integral of 1 / ((z - a)*(z - b)) counterclockwise around the circle |z| = R with real poles a != b.

By the residue theorem the integral is 2*pi*i times the sum of residues at the poles inside the circle, where each simple pole contributes 1/(pole - other). Return the result as [real, imag].

Hint

When both poles are inside, the two residues cancel because 1/(a-b) + 1/(b-a) = 0.

Test cases

case 1
in: [1,3,2]
expected: [0,-3.141592653589793]
case 2
in: [1,3,4]
expected: [0,0]
case 3
in: [3,1,2]
expected: [0,-3.141592653589793]
case 4
in: [2,5,1]
expected: [0,0]
case 5
in: [0,4,3]
expected: [0,-1.5707963267948966]
Starter codePython
def residue_integral(a, b, r):
    # Return [real, imag]
    # Your code here
    pass

5 test cases · run your code against them in the editor