COMPLEX ANALYSIS: Mathematica 4.1 Notebooks
(c) John H. Mathews, and
Russell W. Howell, 2002
Complimentary software to accompany our textbook:

COMPLEX ANALYSIS: for Mathematics and Engineering, 
4th Edition,  2001,  ISBN: 0-7637-1425-9
Jones & Bartlett Publishers, Inc.  
40 Tall Pine Drive, Sudbury, MA 01776  
Tele.  (800) 832-0034, FAX:  (508)  443-8000  
E-mail:  mkt@jbpub.com  
Internet:  http://www.jbpub.com/  
This free software is compliments of the authors.
John H. Mathews,   mathews@fullerton.edu 
Russell W. Howell,  howell@westmont.edu

CHAPTER 8   RESIDUE THEORY

a = t = x = y = z = Z = 
                  0; 
Clear[A, center, centers, dot, dots, f, f0, F, g, G, i, p, R, Res, 
        Res1, Res2, Res3, Res4, Res5, Res6, solset, sub, S, t, θ, val, 
        x, y, z, z1, z2, z3, z4, z5, z6, Z]; 
Needs["Graphics`Colors`"]; 
Needs["Graphics`FilledPlot`"];

Section 8.1	The Residue Theorem

Section 8.2	Calculation of Residues

Section 8.3	Trigonometric Integrals

Section 8.4	Improper Integrals of Rational Functions

Section 8.5	Improper Integrals Involving Trigonometric Functions

Section 8.6  Indented Contour Integrals

If  f  is continuous on the interval  b < x ≤ c, then the improper integral of  f  over  (b,c]  is defined by  

		\(∫\_b\%c\ f \((x)\) dx\  = \ 
        lim\+\(r\  -> \ \(b\^+\)\)\ ∫\_r\%c\ 
            f \((x)\) dx\)

provided that the limit exists.  Similarly, if  f  is continuous on the interval  a ≤ x < b, then the improper integral of  f  over  [a,b)  is defined by  

		\(∫\_a\%b\ f \((x)\) dx\  = \ 
        lim\+\(r\  -> \ \(b\^-\)\)\ ∫\_a\%r\ 
            f \((x)\) dx\)

provided that the limit exists. 

	Let  f  be continuous for all values of  x  in the interval  [a,c],  except at the value  x=b,  where  a < b < c.  The Cauchy principal value of  f  over  [a,c]  is defined by
	
		P . 
          V . (∫_a^c) 
            f (x) dx = \(lim\+\(r\  -> \ \(0\^+\)\)\ \([∫\_a\%\(b - r\)\ 
              f \((x)\) dx + ∫\_\(b + r\)\%c\ 
              f \((x)\) dx\ ]\)\)
	
provided that the limit exists.

For illustration purposes of comparison, the examples are also solved using Mathematica's table of integrals.

Example 8.19,  Page 333.  Show that  P . 
          V .  (∫_(-1)^8) 
                  (1/(x^(1/3))) dx = (9/2).

Solution 8.19.

We must guide Mathematica and write an appropriate form of the anti-derivative.

f[x_] = (1/(x^(1/3))); 
F[x_] = (3/2) ((((x^2)))^(1/3)); 
Print[" F[x] = ", F[x]]; 
Print[""]; 
Print["F'[x] = ", F'[x], " = ", 
        PowerExpand[F'[x]]]; 
Print[""]; 
Print[" f[x] = ", f[x]];

The integrand is discontinuous at x = 0 where it has a singularity.  Indeed, Mathematica has a branch cut for  w  =  (z^(1/3))  along the negative x-axis and maps these points onto the ray Arg[w] = (π/3).  Hence the function  f[x] = (1/(x^(1/3)))  does not have the graph as taught in elementary calculus.  We must use the following function  h[x].

h[x_ /;  x > 0] := 
        (1/(x^(1/3))); 
h[
          x_ /;  x < 
              0] := ((-1)/Abs)[x]^(1/3); 
g1 = 
        FilledPlot[h[x], {x, -1, 0}, Fills -> Cyan, 
          DisplayFunction -> Identity]; 
g2 = 
        FilledPlot[h[x], {x, 0, 1}, Fills -> Cyan, 
          DisplayFunction -> Identity]; 
g3 = 
        FilledPlot[h[x], {x, 1, 8}, Fills -> Red, 
          DisplayFunction -> Identity]; 
\(\(Show[g1, g2, g3, PlotRange -> {\(-5\), 5}, 
        AxesLabel -> {"x", "s"}, 
Ticks -> {Range[\(-1\), 8, 1], Range[\(-10\), 10, 2]}, 
        DisplayFunction -> $DisplayFunction];\)\ \)
Print["        s = ", f[x]];

Now we pursue the Cauchy principal value of the integral.

\(
\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], \*""\[DifferentialD]x = \!\(lim\+\(r -> 0\)\) (("", 
        F[\(-r\)] - \ F[\(-1\)], ") + (", 
        F[8] - \ F[r], "))"];\)\ \)
\(\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], \*""\[DifferentialD]x = \!\(lim\+\(r -> 0\)\) ("", 
        F[\(-r\)] - \ F[\(-1\)] + F[8] - \ 
          F[r], ")"];\)\ \)
\(\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], "\[DifferentialD]x = ", 
        Limit[F[\(-r\)] - \ F[\(-1\)] + F[8] - \ F[r], 
          r -> 0]];\)\ \)

Warning. The following computations will not produce the principal value of the real integral.  Indeed, Mathematica has a branch cut for  w = g[z] = ((3 (z^(2/3)))/2)  along the negative x-axis and maps these points onto the ray Arg[w] = ((2 π)/3),  in particular g[-1] = -(3/4) + ((3 i (Sqrt[3]))/4).

g[
          x_]  = ∫f[x] \[DifferentialD]x; 
val  = (∫_(-8)^1) f[x] \[DifferentialD]x; 
Print["f[x] = ", f[x]]; 
Print["g[x] = ∫", f[x], " \[DifferentialD]x = ", 
        g[x]]; 
Print[""]; 
Print["g[8] = ", g[8]]; 
Print["g[-1] = ",  g[-1], " = ", 
        ComplexExpand[g[-8]]]; 
Print[""]; 
Print["The following answers are suspect because"]; 
Print["the branch cuts occur on the negative x-axis."]; 
\(\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], " \[DifferentialD]x = g[8]-g[-1] = (", 
        g[8]\ , ") - (", \ 
        g[\(-1\)], ")"];\)\ \)
\(\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], " \[DifferentialD]x = ", 
        g[8]\  - \ g[\(-1\)]];\)\ \)
\(\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], " \[DifferentialD]x = ", 
        g[8]\  - ComplexExpand[g[\(-1\)]]];\)\ \)
\(\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], " \[DifferentialD]x = ", 
        val];\)\ \)

Correction. The following choice for the form for the indefinite integral will produce the desired computation.

f[x_] = (1/(x^(1/3))); 
F[x_] = (3/2) ((((x^2)))^(1/3)); 
Print["f[x] = ", f[x]]; 
Print["F[x] = ∫", f[x], " \[DifferentialD]x = ", 
        F[x]]; 
Print[""]; 
Print["F[8] = ", F[8], ",     F[-1] = ",  
        F[-1]]; 
\(\(Plot[F[x], {x, \(-1\), 8}, PlotRange -> {0, 6}, 
        AxesLabel -> {"x", "s"}, 
PlotStyle -> Magenta, 
        Ticks -> {Range[\(-1\), 8, 1], 
            Range[0, 6, 1]}];\)\ \)
Print["      s = F[x] = ", F[x]]; 
\(\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], " \[DifferentialD]x = F[8]-F[-1] = (", 
        F[8]\ , ") - (", \ F[\(-1\)], ")"];\)\ \)
\(\(Print[\*""\!\(∫\_\(-1\)\%8\)"", 
        f[x], " \[DifferentialD]x = ", 
        F[8]\  - \ F[\(-1\)]];\)\ \)

Which is also the correct answer.

Remark. The PrincipalValue option does not give and answer to this problem.

int = 
        Integrate[F[x], {x, -∞, ∞}, 
          PrincipalValue -> True]; 
\(\(Print[\*""\!\(∫\_\(-∞\)\%∞\)"", 
        F[x], " \[DifferentialD]x = ", 
        int];\)\ \)

Theorem 8.5,  Page 333.  Let f (z) = ((P (z))/(Q (z))) where P and Q are polynomials with real coefficients of degree m and n, respectively, where  n ≥ m + 2. If Q has simple zeros at the points (Subscript[t, 1]), (Subscript[t, 2]),   ... , (Subscript[t, r]) on the x-axis, then the Cauchy Principal Value (P.V.) of the integral is 

	\(\(\(P . 
          V . \(∫\_\(-∞\)\%∞\(\( 
                    P \((x)\)\)\/\(Q \((x)\)\)\) dx\)\)\(\ \)\(=\)\(\ \)\)\)2  π i (∑_(j = 1)^k) Res[(P/Q), 
              (Subscript[z, j])] + π i (∑_(j = 1)^r) Res[
              (P/Q), (Subscript[t, j])],  

where (Subscript[z, 1]), (Subscript[z, 2]),   ... , (Subscript[z, k]) are the poles of f that lie in the upper half-plane.

Proof of Theorem 8.5, see text Page 333.

Theorem 8.6,  Page 333.  Let P and Q be polynomials, of degree m and n, respectively, where n ≥ m + 1 and let Q have simple zeros at the points  (Subscript[t, 1]), (Subscript[t, 2]),   ... , (Subscript[t, r])  on the x-axis.  If α is a positive real number and if  \(f \((z)\) = \(e\^\(i\ α\ z\)\ P \((z)\)\)\/\(Q \((z)\)\)\), then we can compute the Cauchy Principal Value (P.V.) of the following integrals 

	\(\(\(P . 
          V . \(∫\_\(-∞\)\%∞\(\( 
                    P \((x)\)\)\/\(Q \((x)\)\)\) 
              cos \((α\ x)\) dx\)\)\(\ \)\(=\)\(\ \)\)\)-2 π (∑_(j = 1)^k) 
              Im (Res[f, (Subscript[z, j])]) - π (∑_(j = 1)^r) 
              Im (Res[f, (Subscript[t, j])]),  
	
	and  
	
	\(\(\(P . 
          V . \(∫\_\(-∞\)\%∞\(\( 
                    P \((x)\)\)\/\(Q \((x)\)\)\) 
              sin \((α\ x)\) dx\)\)\(\ \)\(=\)\(\ \)\)\)2  π  (∑_(j = 1)^k) 
              Re (Res[f, (Subscript[z, j])]) + π  (∑_(j = 1)^r) 
              Re (Res[f, (Subscript[t, j])]),    

where (Subscript[z, 1]), (Subscript[z, 2]),   ... , (Subscript[z, k]) are the poles of f that lie in the upper half plane.

Proof of Theorem 8.6, see text Page 333.

Remark. The formulas in these theorems give the Cauchy principal value of the integral, which pays special attention to the manner in which any limits are taken. They are similar to those in Section 8.4 and Section 8.5, except here we add one-half of the value of each residue at the points (Subscript[t, 1]), (Subscript[t, 2]),   ... , (Subscript[t, r]) on the x-axis.

Example 8.20,  Page 334.  Evaluate "P.V.\!\(\[Integral]\_\(-\[Infinity]\)\%\[Infinity]\)\!\(x\/\(x\^3 - \
8\)\)\[DifferentialD]x" by using complex analysis.

Solution 8.20.

Enter the function and  f[z] = (z/((z^3)  -  8))  and locate the singularities.

Remove[x, z, Z]; 
Clear[f, g, Res1, Res2, solset, val]; 
f[z_]  =  (z/((z^3)  -  8)); 
Print["f[z] = ", f[z]]; 
Print[""]; 
Print[Denominator[f[z]] == 0]; 
solset  =  
        Sort[Solve[Denominator[f[z]] == 0, 
            z]];  
Print[solset]; 
Print[""]; 
Print["The singularities are"]; 
(Subscript[Z, 1])  =  
        ReplaceAll[z, 
          (Subscript[solset, [[1]]])];  
\(\(Print[\*""\!\(z\_1\) = "", Z\_1];\)\ \)
(Subscript[Z, 2])  =  
        ComplexExpand[
          ReplaceAll[z, 
            (Subscript[solset, [[2]]])]];  
\(\(Print[\*""\!\(z\_2\) = "", Z\_2];\)\ \)
(Subscript[Z, 3])  =  
        ComplexExpand[
          ReplaceAll[z, 
            (Subscript[solset, [[3]]])]];  
\(\(Print[\*""\!\(z\_3\) = "", 
        Z\_3];\)\ \)

Which poles lie in the upper half plane ?  Which poles lie on the real axis ?

dots = 
        Graphics[{{Blue, PointSize[0.03], Point[{Re[(Subscript[Z, 1])], Im[(Subscript[Z, 1])]}]}, {Red, 
              PointSize[0.03], Point[{Re[(Subscript[Z, 2])], Im[(Subscript[Z, 2])]}]}, {Red, 
              PointSize[0.03], 
              Point[{Re[(Subscript[Z, 3])], Im[(Subscript[Z, 3])]}]}}]; 
\(\(centers = 
        Graphics[{Text[\*""\!\(z\_1\)"", {Re[Z\_1], 
                Im[Z\_1] + 0.1}, {\(-1\), 0}], 
            Text[\*""\!\(z\_2\)"", {Re[Z\_2], Im[Z\_2] - 0.1}, {\(-1\), 
                0}], Text[\*""\!\(z\_3\)"", {Re[Z\_3], 
                Im[Z\_3] - 0.1}, {\(-1\), 0}]}];\)\ \)
Show[dots, centers, 
        PlotRange -> {{-2.2, 2.2}, {-2.2, 2.2}}, 
        Ticks -> {Range[-2, 2, 1], 
            Range[-2, 2, 1]}, 
AspectRatio -> 1, 
        Axes -> True, 
        AxesLabel -> {"x", "y"}]; 
\(\(Print[\*""\!\(z\_1\) = "", Z\_1, ",         Is  Im(", 
        Z\_1, ") > 0 ?         ", N[Im[Z\_1]] > 0];\)\ \)
\(\(Print[\*""\!\(z\_2\) = "", Z\_2, ", Is  Im(", 
        Z\_2, ") > 0 ?  ", 
        N[Im[Z\_2]] > 0];\)\ \)
\(\(Print[\*""\!\(z\_3\) = "", Z\_3, ", Is  Im(", 
        Z\_3, ") > 0 ?  ", 
        N[Im[Z\_3]] > 0];\)\ \)
Print[""]; 
\(\(Print[\*""\!\(z\_1\) = "", Z\_1, ",         Is  Im(", 
        Z\_1, ") = 0 ?         ", N[Im[Z\_1]] == 0];\)\ \)
\(\(Print[\*""\!\(z\_2\) = "", Z\_2, ", Is  Im(", 
        Z\_2, ") = 0 ?  ", N[Im[Z\_2]] == 0];\)\ \)
\(\(Print[\*""\!\(z\_3\) = "", Z\_3, ", Is  Im(", 
        Z\_3, ") = 0 ?  ", 
        N[Im[Z\_3]] == 0];\)\ \)

Compute the residues at  (Subscript[z, 1]) = 2  and  (Subscript[z, 3]) = -1 + i (Sqrt[3]),  and use the residue calculus to compute the value of the integral.

Res1  =  Residue[f[z], {z, (Subscript[Z, 1])}]; 
Res3  =  Residue[f[z], {z, (Subscript[Z, 3])}]; 
val  =  
        2 π I  Res3 + π I  Res1; 
Print["Res[f,", (Subscript[Z, 1]), "] = ", Res1]; 
Print["Res[f,", (Subscript[Z, 3]), "] = ", 
        Res3]; 
Print["Res[f,", (Subscript[Z, 3]), "] = ", 
        ComplexExpand[Res3]]; 
dots = 
        Graphics[{{Blue, PointSize[0.03], Point[{Re[(Subscript[Z, 1])], Im[(Subscript[Z, 1])]}]}, {Red, 
              PointSize[0.03], 
              Point[{Re[(Subscript[Z, 3])], Im[(Subscript[Z, 3])]}]}}]; 
\(\(centers = 
        Graphics[{Text[\*""\!\(z\_1\)"", {Re[Z\_1], 
                Im[Z\_1] - 0.2}, {\(-1\), 0}], 
            Text[\*""\!\(z\_3\)"", {Re[Z\_3], Im[Z\_3]}, {\(-1.2\), 
                0}]}];\)\ \)
contour  =  
        Graphics[{{VioletRed, Circle[{0, 0}, 3, {0, π}]}, {VioletRed, 
              Circle[{Re[(Subscript[Z, 1])], Im[(Subscript[Z, 1])]}, 
                0.2, {0, π}]}}]; 
segment = 
        Graphics[{Thickness[0.02], Magenta, 
            Line[{{-3, 0}, {3, 0}}]}]; 
Show[centers, contour, segment, dots, 
        PlotRange -> {{-3.1, 3.1}, {-0.05, 3.05}}, 
        Ticks -> {Range[-1, 1, 1], Range[0, 2, 1]}, 
        AspectRatio -> (1/2), 
AspectRatio -> 1, 
        Axes -> True, 
        AxesLabel -> {"x", "y"}]; 
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = 2πI(", 
        ComplexExpand[Res3]\ , ") + πI(", \ 
        Res1\ , ")"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = πI(", 
        2\ ComplexExpand[Res3]\  + \ 
          Res1\ , ")"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = ", 
        ComplexExpand[val]];\)\ \)
\(\(Print[\*""The indented contour is the semicircle (Subscript[C, R]) portions of [-R,R],""];\)\ \)
Print["and a little indent semicircle around the pole on the \
x-axis,"]; 
Print["taken with the positive orientation."]; 
Print["Let R->∞ to obtain the Cauchy Principal Value \
of the integral."]; 
Print[""]; 
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", f[x], " \[DifferentialD]x = ", 
        ComplexExpand[val]];\)\ \)
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", f[x], " \[DifferentialD]x = ", 
        Chop[N[val]]];\)\ \)

Example 8.21,  Page 334.  Evaluate "P.V.\!\(\[Integral]\_\(-\[Infinity]\)\%\[Infinity]\)\!\(x\/\(x\^3 - \
8\)\)\[DifferentialD]x" by using a computer algebra system.

Solution 8.21.

Enter the function and  f[z] = (z/((z^3)  -  8))  and locate the singularities.

Remove[x, z, Z]; 
Clear[f, g, Res1, Res2, solset, val]; 
f[z_]  =  (z/((z^3)  -  8)); 
Print["f[z] = ", f[z]];

Warning.  The indefinite integral of f[x] is g[x], but it cannot be used in any meaningful way to solve the problem at hand.

g[
          x_]  = ∫f[
              x] \[DifferentialD]x; 
lim1 =  
        Limit[g[x], x -> ∞]; 
lim2 = Limit[g[x], x -> -∞]; 
Print["g[x] = ∫", f[x], "\[DifferentialD]x = ", 
        g[x]]; 
Print[""]; 
\(\(Print[\*"" g[∞] =  (lim_(x -> ∞)) ("", g[x], ")"];\)\ \)
Print[" g[∞] = ", lim1]; 
Print[""]; 
\(\(Print[\*""g[-∞] =  (lim_(x -> -∞)) ("", g[x], ")"];\)\ \)
Print["g[-∞] = ", lim2]; 
Print[""]; 
Print["    The following answer is suspect"]; 
Print["because of singularities on the real axis."]; 
Print[""]; 
Print["g[∞] - g[-∞] = ", 
        lim1 - lim2]; 
Print["g[∞] - g[-∞] = ", 
        ComplexExpand[lim1 - lim2]]; 
Print["g[∞] - g[-∞] = ", 
        N[lim1 - lim2]];

Warning. The following computation will not produce the correct answer.

val  = (∫_(-∞)^∞) 
              f[x] \[DifferentialD]x; 
Print["    The following answer is suspect"]; 
Print["because of singularities on the real axis."]; 
\(\(Print[\*""\!\(∫\_\(-∞\)\%∞\)"", 
        f[x], " \[DifferentialD]x = ", 
        val];\)\ \)
\(\(Print[\*""\!\(∫\_\(-∞\)\%∞\)"", 
        f[x], " \[DifferentialD]x = ", 
        N[val]];\)\ \)

Correction.  The indefinite integral of g[x] can be written in an algebraic form that will produce the correct answer for real functions.

g[
          x_]  = ∫f[
              x] \[DifferentialD]x; 
Print["g[x] = ∫", f[x], "\[DifferentialD]x = ", 
        g[x]]; 
g[x_] = 
        ArcTan[((1 + x)/(Sqrt[3]))]/(2 (Sqrt[3])) + 
          (1/12) Log[((((-2 + x))^2)/(4 + 2 x + (x^2)))]; 
lim1 =  
        Limit[g[x], x -> ∞]; 
lim2 = 
        Limit[g[x], 
          x -> -∞]; 
Print[""]; 
Print["The following version of g[x] will produce the correct \
result."]; 
Print[""]; 
Print["g[x] = ∫", f[x], "\[DifferentialD]x = ", 
        g[x]]; 
Print[""]; 
\(\(Print[\*"" g[∞] =  (lim_(x -> ∞)) ("", g[x], ")"];\)\ \)
Print[" g[∞] = ", lim1]; 
Print[""]; 
\(\(Print[\*""g[-∞] =  (lim_(x -> -∞)) ("", g[x], ")"];\)\ \)
Print["g[-∞] = ", lim2]; 
\(\(Plot[g[x], {x, \(-20\), 20}, PlotRange -> {\(-0.5\), 0.5}, 
        AxesLabel -> {"x", "s"}, 
PlotStyle -> Magenta, 
        Ticks -> {Range[\(-20\), 20, 10], 
            Range[\(-π\)\/\(4\ \@3\), π\/\(4\ \@3\), π\/\(4\ \@3\)]}];\)\ \)
Print["g[x] = ", g[x]]
Print[""]; 
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", f[x], " \[DifferentialD]x = (", lim1, ") - (", 
        lim2, ")"];\)\ \)
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", f[x], " \[DifferentialD]x = ", 
        lim1 - lim2];\)\ \)
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", f[x], " \[DifferentialD]x = ", 
        N[lim1 - lim2]];\)\ \)

Which is also the correct answer.

Aside. We can use Mathematica's built in "PrincipalValue" option to evaluate this definite integral .

val  =  
        Integrate[f[x], {x, -∞, ∞}, 
          PrincipalValue -> True]; 
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", f[x], " \[DifferentialD]x = ", val, " = ", 
        N[val]];\)\ \)

Which is also the correct answer.

Example 8.22,  Page 335.  Show that  "P.V.\!\(\[Integral]\_\(-\[Infinity]\)\%\[Infinity]\)\!\(Sin[x]\/\(\((\
x - 1)\) \((x\^2\\  + \\ 4)\)\)\)\[DifferentialD]x = \!\(\[Pi]\/5\)(Cos[1]-\!\
\(1\/\[ExponentialE]\^2\))".

Solution 8.22.

Enter the function and  \(f[
          z] = e\^\(i\ z\)\/\(\((z\  - \ 1)\) \((z\^2\  + \ 4)\)\)\)  and locate the singularities.

Remove[x, z, Z]; 
Clear[f, g, Res1, Res2, solset, val]; 
F[x_]  =  Sin[x]/((x - 1) ((x^2)  +  4)); 
f[
          z_]  =  ((E^(I z))/((z - 1) ((z^2)  +  4))); 
Print["F[x] = ", F[x]]; 
Print[""]; 
Print["f[z] = ", f[z]]; 
Print[""]; 
Print[Denominator[f[z]] == 0]; 
solset  =  
        Sort[Solve[Denominator[f[z]] == 0, 
            z]];  
Print[solset]; 
Print[""]; 
Print["The singularities are"]; 
(Subscript[Z, 1])  =  
        ReplaceAll[z, 
          (Subscript[solset, [[1]]])];  
\(\(Print[\*""\!\(z\_1\) = "", Z\_1];\)\ \)
(Subscript[Z, 2])  =  
        ReplaceAll[z, 
          (Subscript[solset, [[2]]])];  
\(\(Print[\*""\!\(z\_2\) = "", Z\_2];\)\ \)
(Subscript[Z, 3])  =  
        ReplaceAll[z, 
          (Subscript[solset, [[3]]])];  
\(\(Print[\*""\!\(z\_3\) = "", 
        Z\_3];\)\ \)

Which poles lie in the upper half plane ?  Which poles lie on the real axis ?

dots = 
        Graphics[{{Red, PointSize[0.03], Point[{Re[(Subscript[Z, 1])], Im[(Subscript[Z, 1])]}]}, {Red, 
              PointSize[0.03], Point[{Re[(Subscript[Z, 2])], Im[(Subscript[Z, 2])]}]}, {Blue, 
              PointSize[0.03], 
              Point[{Re[(Subscript[Z, 3])], Im[(Subscript[Z, 3])]}]}}]; 
\(\(centers = 
        Graphics[{Text[\*""\!\(z\_1\)"", {Re[Z\_1], 
                Im[Z\_1] - 0.1}, {\(-1\), 0}], 
            Text[\*""\!\(z\_2\)"", {Re[Z\_2], Im[Z\_2] - 0.1}, {\(-1\), 
                0}], Text[\*""\!\(z\_3\)"", {Re[Z\_3], 
                Im[Z\_3] + 0.1}, {\(-1\), 0}]}];\)\ \)
Show[dots, centers, 
        PlotRange -> {{-2.2, 2.2}, {-2.2, 2.2}}, 
        Ticks -> {Range[-2, 2, 1], 
            Range[-2, 2, 1]}, 
AspectRatio -> 1, 
        Axes -> True, 
        AxesLabel -> {"x", "y"}]; 
\(\(Print[\*""\!\(z\_1\) = "", Z\_1, ", Is  Im(", 
        Z\_1, ") > 0 ?  ", N[Im[Z\_1]] > 0];\)\ \)
\(\(Print[\*""\!\(z\_2\) = "", Z\_2, ",   Is  Im(", 
        Z\_2, ") > 0 ?  ", 
        N[Im[Z\_2]] > 0];\)\ \)
\(\(Print[\*""\!\(z\_3\) = "", Z\_3, ",    Is  Im(", 
        Z\_3, ") > 0 ?    ", 
        N[Im[Z\_3]] > 0];\)\ \)
Print[""]; 
\(\(Print[\*""\!\(z\_1\) = "", Z\_1, ", Is  Im(", 
        Z\_1, ") = 0 ?  ", N[Im[Z\_1]] == 0];\)\ \)
\(\(Print[\*""\!\(z\_2\) = "", Z\_2, ",  Is  Im(", 
        Z\_2, ") = 0 ?   ", N[Im[Z\_2]] == 0];\)\ \)
\(\(Print[\*""\!\(z\_3\) = "", Z\_3, ",    Is  Im(", 
        Z\_3, ") = 0 ?    ", 
        N[Im[Z\_3]] == 0];\)\ \)

Compute the residues at  (Subscript[z, 2]) = 2  i  and  (Subscript[z, 3]) = 1,  and use the residue calculus to compute the value of the integral.

Res2  =  Residue[f[z], {z, (Subscript[Z, 2])}]; 
Res3  =  Residue[f[z], {z, (Subscript[Z, 3])}]; 
val  =  
        2 π Re[Res2] + π Re[ 
              Res3]; 
Print["Res[f,", (Subscript[Z, 2]), "] = ", Res2]; 
Print["Res[f,", (Subscript[Z, 3]), "] = ", 
        Res3]; 
Print[""]; 
Print["Re[Res[f,", (Subscript[Z, 2]), "]] = ", Re[Res2]]; 
Print["Re[Res[f,", (Subscript[Z, 3]), "]] = ", 
        Re[Res3]]; 
dots = 
        Graphics[{{Red, PointSize[0.03], Point[{Re[(Subscript[Z, 2])], Im[(Subscript[Z, 2])]}]}, {Blue, 
              PointSize[0.03], 
              Point[{Re[(Subscript[Z, 3])], Im[(Subscript[Z, 3])]}]}}]; 
\(\(centers = 
        Graphics[{Text[\*""\!\(z\_2\)"", {Re[Z\_2], 
                Im[Z\_2]}, {\(-1.2\), 0}], 
            Text[\*""\!\(z\_3\)"", {Re[Z\_3] - 0.05, 
                Im[Z\_3] + 0.3}, {\(-1\), 
                0}]}];\)\ \)
contour  =  
        Graphics[{{VioletRed, Circle[{0, 0}, 3, {0, π}]}, {VioletRed, 
              Circle[{Re[(Subscript[Z, 3])], Im[(Subscript[Z, 3])]}, 
                0.2, {0, π}]}}]; 
segment = 
        Graphics[{Thickness[0.02], Magenta, 
            Line[{{-3, 0}, {3, 0}}]}]; 
Show[centers, contour, segment, dots, 
        PlotRange -> {{-3.1, 3.1}, {-0.05, 3.05}}, 
        Ticks -> {Range[-1, 1, 1], Range[0, 2, 1]}, 
        AspectRatio -> (1/2), 
AspectRatio -> 1, 
        Axes -> True, 
        AxesLabel -> {"x", "y"}]; 
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = 2π Re[", 
        Res2\ , "] + π Re[", \ 
        Res3\ , "]"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = 2π(", 
        Re[Res2\ ], ") + π(", 
        Re[\ Res3]\ , ")"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = ", 
        val];\)\ \)
\(\(Print[\*""The indented contour is the semicircle (Subscript[C, R]) portions of [-R,R],""];\)\ \)
Print["and a little indent semicircle around the pole on the \
x-axis,"]; 
Print["taken with the positive orientation."]; 
Print["Let R->∞ to obtain the Cauchy Principal Value \
of the integral."]; 
Print[""]; 
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", f[x], " \[DifferentialD]x = ", val];\)\ \)
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", f[x], " \[DifferentialD]x = ", 
        Chop[N[val]]];\)\ \)

Warning.  The indefinite integral of F[x] is g[x], but it cannot be used in any meaningful way to solve the problem at hand.

g[
          x_]  = ∫f[x] \[DifferentialD]x; 
Print["g[x] = ∫", f[x], "\[DifferentialD]x = ", 
        g[x]]; 
Print[""]; 
Print[" g[∞] = ", 
        g[∞] ]; 
Print[""]; 
Print["g[-∞] = ", g[-∞]]; 
Print[""]; 
Print["    The following answer is suspect"]; 
Print["because of singularities on the real axis."]; 
Print["g[∞]-g[-∞] = ", 
        g[∞]  -  g[-∞]]; 
Print["g[∞]-g[-∞] = ", 
        ComplexExpand[
          g[∞] - 
            g[-∞]]]; 
Print["g[∞]-g[-∞] = ", 
        N[g[∞] - 
            g[-∞]]];

Aside. We can use Mathematica's built in "PrincipalValue" option to evaluate the definite integral .

F0[x] = 
        Expand[Sin[x] Apart[
              (1/((-1 + x) (4 + (x^2))))]]; 
val1 = 
        Integrate[(Subscript[(F0[x]), [[1]]]), {x, -∞, ∞}, 
          PrincipalValue -> True]; 
val2 = 
        Integrate[(Subscript[(F0[x]), [[2]]]), {x, -∞, ∞}, 
          PrincipalValue -> True]; 
val3 = 
        Integrate[(Subscript[(F0[x]), [[3]]]), {x, -∞, ∞}, 
          PrincipalValue -> True]; 
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", F[x], " \[DifferentialD]x = ", 
        val1 + val2 + val3];\)\ \)
\(\(Print[\*""P.V.(∫_(-∞)^∞)"", F[x], " \[DifferentialD]x = ", 
        N[val1 + val2 + val3]];\)\ \)

Which is also the correct answer.

The proofs of Theorems 8.5 and 8.6 depend on the following result.

Lemma 8.2,  Page 336.  Let  f(z)  have a simple pole at the point  (Subscript[t, 0])  on the x-axis.  If the contour is \(\(C\_r\) : z = 
        t\_0 + r\ e\^iθ\ \ for\ \ 0\  ≤ \ θ\  ≤ \ π\),  then
		(Underscript[(lim ), r  ->  0]) (∫_((Subscript[C, r]))) 
            f (z) dz  =  i π Res[f, 
            (Subscript[t, 0])].

Proof of Lemma 8.2, see text Page 336.

Section 8.6 Exercises for  Indented Integrals
See textbook page 338.

Section 8.7	Integrands with Branch Points

Section 8.8	The Argument Principle and Rouche's Theorem

GO TO  THE  Table of Contents