# Evaluation of a contour integral

I wonder whether Mathemtica can evaluate the contour integral of $$\frac{2az+b}{az^2+bz+c}$$ over the unit circle $$|z| = 1.$$ I do not have access to Mathemtica .Could we try something like :


(* Define the parameterization *)
z[t_] := Exp[I*t]

(* Evaluate the integral as a function of a, b, and c *)
integral[a_, b_, c_] := Integrate[(f[a, b, c, z[t]] * I * z[t]), {t, 0, 2*Pi}]$$$$


This is fairly routine:

f[z_] := (2 a z + b)/(a z ^2 + b z + c)
γ[t_] := Exp[I t]
Integrate[f[γ[t]] γ'[t], {t, 0, 2 π}]


Which gives you:

ConditionalExpression[I*Piecewise[{{2*Pi, Xor[Abs[(b - Sqrt[b^2 - 4*a*c])/a] < 2, Abs[(b + Sqrt[b^2 - 4*a*c])/a] < 2]},
{4*Pi, Abs[(b + Sqrt[b^2 - 4*a*c])/a] < 2 && Abs[(b - Sqrt[b^2 - 4*a*c])/a] < 2}}, 0],
Abs[(b + Sqrt[b^2 - 4*a*c])/a] != 2 && Abs[(b - Sqrt[b^2 - 4*a*c])/a] != 2]


The reason for all the complexity here is because the roots may lie inside our outside or on the contour depending on $$a,b,c$$, and you may even have one outside, one inside. If the roots lie outside the contour, the result is of course zero because $$f$$ is analytic everywhere within the contour. If one is outside then you get $$2\pi i$$, and if both are inside, then you get $$4\pi i$$ in this case. If any of them are on the contour then the result is undefined.

If the roots lie inside, you can just use the residue theorem:

roots = Solve[Denominator[f[z]] == 0, z];
2 Pi I * Total[Residue[f[z], {z, z /. #}] & /@ roots]
(*Result: 4 I Pi *)

• Unfortunately, the answer is not complete. If one of the roots (or both roots) produced by Solve[a z^2 + b z + c == 0, z] belongs to the unit circumference (Abs[(b + Sqrt[b^2 - 4*a*c])/a]]== 2 or Abs[(b - Sqrt[b^2 - 4*a*c])/a] == 2), then the integral does not exist, but there exists its principal value. Apr 26, 2023 at 16:37
• @user64494 The answer is complete insofar as the original question is worded - as the integral is undefined which I mentioned. Your addition is a helpful further consideration however. Apr 26, 2023 at 17:45
• flinty (@ does not work.): I think you are not right. The question is "whether Mathem[a]tica can evaluate the contour integral of$\frac{2az+b}{az^2+bz+c}$ over the unit circle $|z|=1$". Apr 26, 2023 at 18:44

This is an improvement of the @flinty's answer. If one of the roots produced by Solve[a z^2 + b z + c == 0, z] belongs to the unit circumference (Abs[(b + Sqrt[b^2 - 4*a*c])/a]]== 2 or Abs[(b - Sqrt[b^2 - 4*a*c])/a] == 2), then the integral does not exist, but there exists its principal value.

f[z_] := (2 a z + b)/(a z^2 + b z + c);\[Gamma][t_] := Exp[I t];
Integrate[f[\[Gamma][t] *\[Gamma]'[t]], {t, 0, 2 \[Pi]},
Assumptions ->  Abs[(b + Sqrt[b^2 - 4*a*c])/a] == 2 ||
Abs[(b - Sqrt[b^2 - 4*a*c])/a] == 2, PrincipalValue -> True]


ConditionalExpression[ (2*I)*a*Piecewise[{{(-2*Pi)/Sqrt[-b^2 + 4*a*c], Abs[((-I)*b + Sqrt[-b^2 + 4*a*c])/a] >= 2 && Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a] < 2}, {(2*Pi)/Sqrt[-b^2 + 4*a*c], Abs[((-I)*b + Sqrt[-b^2 + 4*a*c])/a] < 2 && Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a] >= 2}}, 0] + b*Piecewise[{{(2*Pi)/c, Abs[((-I)*b + Sqrt[-b^2 + 4*a*c])/a] >= 2 && Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a] >= 2}, {(2*(b^2 - 2*a*c + I*b*Sqrt[-b^2 + 4*a*c])*Pi)/ (c*(b^2 - 4*a*c + I*b*Sqrt[-b^2 + 4*a*c])), Abs[((-I)*b + Sqrt[-b^2 + 4*a*c])/a] < 2 && Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a] >= 2}, {(2*(-b^2 + 2*a*c + I*b*Sqrt[-b^2 + 4*a*c])*Pi)/ (c*(-b^2 + 4*a*c + I*b*Sqrt[-b^2 + 4*a*c])), Abs[((-I)*b + Sqrt[-b^2 + 4*a*c])/a] >= 2 && Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a] < 2}}, 0], (Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a]/2 < 1 || Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a]/2 > 1) && (Abs[((-I)*b + Sqrt[-b^2 + 4*a*c])/a]/2 < 1 || Abs[((-I)*b + Sqrt[-b^2 + 4*a*c])/a]/2 > 1)]

In order to consider the general case, the PrincipalValue->True option should be added (As the Russians say "You can't spoil porridge with butter".).

Integrate[f[\[Gamma][t] *\[Gamma]'[t]], {t, 0, 2 \[Pi]}, PrincipalValue -> True]


ConditionalExpression[(2*b*Pi)/c + (2*I)*a*Piecewise[ {{0, !(Xor[Sqrt[Abs[(I*b - Sqrt[-b^2 + 4*a*c])/a]]/Sqrt[2] < 1, Sqrt[Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a]]/Sqrt[2] < 1])}, {((2*I)*(I*b + Sqrt[-b^2 + 4*a*c])*Pi)/(I*b^2 - (4*I)*a*c + b*Sqrt[-b^2 + 4*a*c]), Sqrt[Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a]]/ Sqrt[2] < 1}}, (2*(b + I*Sqrt[-b^2 + 4*a*c])*Pi)/ ((-I)*b^2 + (4*I)*a*c + b*Sqrt[-b^2 + 4*a*c])], (Sqrt[Abs[(I*b - Sqrt[-b^2 + 4*a*c])/a]]/Sqrt[2] < 1 || Sqrt[Abs[(I*b - Sqrt[-b^2 + 4*a*c])/a]]/Sqrt[2] > 1) && (Sqrt[Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a]]/Sqrt[2] < 1 || Sqrt[Abs[(I*b + Sqrt[-b^2 + 4*a*c])/a]]/Sqrt[2] > 1)]

correct form (thanks @flinty) of the integral

Integrate[(2 a z + b)/(a z^2 + b z + c)I Exp[I t] /. z -> Exp[I t], {t, 0, 2*Pi}]



evaluates 0

Obviously this result (Mathematica v12.2) without any conditions isn't correct!

• In 13.2 on Widows 10 Integrate[(2 a z + b)/(a z^2 + b z + c) I Exp[I t] /. z -> Exp[I t], {t, 0, 2*Pi}] results in ConditionalExpression[ I*Piecewise[{{2*Pi, Xor[Abs[(b - Sqrt[b^2 - 4*a*c])/a] < 2, Abs[(b + Sqrt[b^2 - 4*a*c])/a] < 2]}, {4*Pi, Abs[(b + Sqrt[b^2 - 4*a*c])/a] < 2 && Abs[(b - Sqrt[b^2 - 4*a*c])/a] < 2}}, 0], Abs[(b + Sqrt[b^2 - 4*a*c])/a] != 2 && Abs[(b - Sqrt[b^2 - 4*a*c])/a] != 2]` as @flinty wrote. Apr 27, 2023 at 3:24