import math
import numpy as np
def func(x):
return np.sin(x)
def integration (f, n, r, a, dtheta ):
summation = 0
theta = 0
while theta <= 2*np.pi:
f_arg = a + r*np.exp(1j*theta)
second = np.exp(-1j*theta*n)
summation += f(f_arg) * second * dtheta
theta += dtheta
return math.factorial(n)*summation / (2*np.pi*r**n)
print(integration(func, 2, 1, 0, 2*np.pi/10000))
aW1wb3J0IG1hdGgKaW1wb3J0IG51bXB5IGFzIG5wCgpkZWYgZnVuYyh4KToKICAgIHJldHVybiBucC5zaW4oeCkKCmRlZiBpbnRlZ3JhdGlvbiAoZiwgbiwgciwgYSwgZHRoZXRhICk6CgogICAgc3VtbWF0aW9uID0gMAogICAgdGhldGEgPSAwCiAgICB3aGlsZSB0aGV0YSA8PSAyKm5wLnBpOgoKICAgICAgICBmX2FyZyA9IGEgKyByKm5wLmV4cCgxaip0aGV0YSkKICAgICAgICBzZWNvbmQgPSBucC5leHAoLTFqKnRoZXRhKm4pCgogICAgICAgIHN1bW1hdGlvbiArPSBmKGZfYXJnKSAqIHNlY29uZCAqIGR0aGV0YQogICAgICAgIHRoZXRhICs9IGR0aGV0YQoKICAgIHJldHVybiBtYXRoLmZhY3RvcmlhbChuKSpzdW1tYXRpb24gLyAoMipucC5waSpyKipuKQoKcHJpbnQoaW50ZWdyYXRpb24oZnVuYywgMiwgMSwgMCwgMipucC5waS8xMDAwMCkp