# How would you calculate a contour integral? [duplicate]

How would you be able to calculate a contour integral of 1/(((z-1)^2)*(z-i)) over the contour |z-1| = 1? Not sure how to type that in :/

With

f[z_] := 1/((z - 1)^2*(z - I))


the contour integral around a circle centered at z == 1 can be parameterized by arc length around the circle.

Integrate[(f[z] /. z -> 1 + Cos[t] + I Sin[t]) D[1 + Cos[t] + I Sin[t], t],
{t, 0, 2 Pi}]
(* π *)


which, of course, is equal to the residue at z == 1, multiplied by 2 π I. (The pole at z == I is outside the contour and so does not contribute to the integral.)

Alternatively, the integral can be performed over a region.

reg = ParametricRegion[{1 + Cos[t], Sin[t]}, {{t, 0, 2 Pi}}];
Integrate[(f[z] /. z -> x + I y) (-y + I (x - 1)), {x, y} ∈ reg]


which gives the same result. (-y + I (x - 1)) is the equivalent of D[1 + Cos[t] + I Sin[t], t].

f[z_] := 1/((z - 1)^2*(z - I))

So for a=1, you get Pi