I guess this is a standard example for the use of residues! The function
f[z_] := Exp[z]*Cos[Pi*z]/(z^2 + z)
has two poles:
poles = Solve[z^2 + z == 0, z]
(* Out: {{z\[Rule]-1},{z\[Rule]0}} *)
The one at z=-1
is on the contour:
ComplexPlot3D[f[z], {z, -1.1 - 1 I, 1 + 1 I}, RegionFunction -> (Abs[#] <= 1 &), BoxRatios -> {Automatic, Automatic, 1}]
The respective residues are:
Residue[f[z], {z, #}] & /@ {0, -1}
(* Out: {1,1/\[ExponentialE]} *)
So - according to residue theorem - we find for the line integral along Abs[z]==1
(the residue on the pole counts half!):
2 Pi I (1 + 1/(2 E))
But Mathematica can actually handle those integrals directly; because of the pole on the contour the option PrincipalValue -> True
is needed:
Integrate[f[Exp[I \[Phi]]] I Exp[I \[Phi]], {\[Phi], 0, 2 Pi}, PrincipalValue -> True]
(* Out: \[ImaginaryI] (2+1/\[ExponentialE]) \[Pi] *)