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

Let  P  and  Q  be polynomials of degree  m  and  n,  respectively, where  n ≥ m + 1.  If  Q (x) ≠ 0  for all real  x, then  

	\(P . 
        V . \(∫\_\(-∞\)\%∞\(\( P \((x)\) 
                  cos \((α\ x)\)\)\/\(Q \((x)\)\)\) dx\)\)  and  \(P . 
        V . \(∫\_\(-∞\)\%∞\(\( P \((x)\) 
                  sin \((α\ x)\)\)\/\(Q \((x)\)\)\) dx\)\)

are convergent improper integrals.  Integrals of this type are sometimes encountered in the study of Fourier transforms and Fourier integrals.  We now show how these improper integrals can be evaluated.

	It is of particular importance to observe that we will be using the identities cos (α x) = 
        Re[(e^(i α x))]  and  sin (α x) = 
        Im[(e^(i α x))]  where  α  is a positive real number.  The crucial step in the proof of Theorem 8.4 will not hold if  cos (α z)  and  sin (α z)  are used instead of  (e^(i α z)).  Lemma 8.1  will give the details.

Theorem 8.4 (Contour Integration for Improper Trig. Integrals),  Page 328.  Let  P  and  Q  be polynomials, of degree  m  and  n,  where  n ≥ m + 1  and  Q (x) ≠ 0  for all real  x .  Let  0 < α  and  \(f \((z)\) = \(e\^\(i\ α\ z\)\ P \((z)\)\)\/\(Q \((z)\)\)\),  and (Subscript[z, 1]), (Subscript[z, 2]),   ... , (Subscript[z, k])  be the poles of  f(z)  that lie in the upper half plane and  Re (Res[f, (Subscript[z, j])])  and  Im (Res[f, (Subscript[z, j])])  are the real and imaginary parts of  Res[f, (Subscript[z, j])],  respectively.  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, z\_j])\)\)\),  
	
	and  
	
	P . 
          V . (∫_(-∞)^∞)(( 
                    P (x))/(Q (x))) 
              sin (α x) dx  =  
        2  π  (∑_(j = 1)^k) Re (Res[f, (Subscript[z, j])]).

Proof of Theorem 8.4, see text Page 328.

The proof of the theorem is similar to the proof of Theorem 8.3. Before we turn to the proof, let us first illustrate how we use this theorem.

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

Example 8.17,  Page 329.  Use the residue calculus to evaluate the integral  "\!\(\[Integral]\_\(-\[Infinity]\)\%\[Infinity]\)\!\(\(x  \
Sin[x]\)\/\(x\^2 + 4\)\)\[DifferentialD]x = \
\!\(\[Pi]\/\[ExponentialE]\^2\)".

Solution 8.17.

Enter the functions  F[x] = ((x Sin[x])/((x^2)  +  4))  and  \(f[
          z] = \(z\ e\^\(i\ z\)\)\/\(z\^2\  + \ 4\)\)  and locate the singularities of  f[z].

Remove[x, z, Z]; 
Clear[f, F, g, Res1, Res2, solset, 
        val]; 
F[x_] = ((x Sin[x])/((x^2)  +  4)); 
f[
          z_]  =  ((z (E^(I z)))/((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];\)\ \)

Which poles lie in the upper half plane?

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])]}]}}]; 
\(\(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}]}];\)\ \)
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];\)\ \)

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

Res2  =  
        Residue[f[z], {z, (Subscript[Z, 2])}]; 
val  = 2  π  Re[Res2]; 
Print["Res[f,", (Subscript[Z, 2]), "] = ", 
        Res2]; 
Print[""]; 
Print["Re[Res[f,", (Subscript[Z, 2]), "]] = ", 
        Re[Res2]]; 
dots = 
        Graphics[{Red, PointSize[0.03], 
            Point[{Re[(Subscript[Z, 2])], Im[(Subscript[Z, 2])]}]}]; 
\(\(centers = 
        Graphics[{Text[\*""\!\(z\_2\)"", {Re[Z\_2], 
                Im[Z\_2]}, {\(-1.2\), 0}]}];\)\ \)
contour  =  
        Graphics[{VioletRed, 
            Circle[{0, 0}, 3, {0, π}]}]; 
segment = 
        Graphics[{Thickness[0.02], Magenta, 
            Line[{{-3, 0}, {3, 0}}]}]; 
Show[dots, centers, contour, segment, 
        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\ , "] = ", 
        val];\)\ \)
\(\(Print[\*""The contour is the semicircle (Subscript[C, R]) and interval [-R,R],""];\)\ \)
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 = 2π Re[", Res2, "] = ", 
        val];\)\ \)

Remark.  The integral of  f[z] for this problem is  g[z],  but it cannot be used in any meaningful way to solve the problem at hand.

g[
          x_]  = ∫F[x] \[DifferentialD]x; 
Print["F[x] = ", F[x]]; 
Print["g[x] = ∫ ", F[x], " \[DifferentialD]x = ", 
        g[x]]; 
Print[""]; 
Print["      g[∞] = ", g[∞]]; 
Print["     g[-∞] = ", 
        g[-∞]]; 
Print[""]; 
Print["g[∞]-g[-∞] = ", 
        Simplify[g[∞] - g[-∞]]]; 
Print["g[∞]-g[-∞] = ", 
        N[g[∞] - 
            g[-∞]]];

This looks good, however it cannot be used to solve for the definite integral. This does not agree with the answer obtained with the residue calculus.

\(\(\(
\)\(\(Print[\*""(∫_(-∞)^∞)"", F[x], " \[DifferentialD]x = ", 
        val, " = ", N[val]];\)\(\ \)\(
\)
    \)\)\)

However, the definite integral will produce the following result.

val  = (∫_(-∞)^∞) 
              F[x] \[DifferentialD]x ; 
\(\(Print[\*""\!\(∫\_\(-∞\)\%∞\)"", 
        F[x], " \[DifferentialD]x = ", val, " = ", 
        N[val]];\)\ \)

Which is also the correct answer.

The PrincipalValue option can also be used.

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

Example 8.18,  Page 329.    Use the residue calculus to evaluate the integral  "\!\(\[Integral]\_\(-\[Infinity]\)\%\[Infinity]\)\!\(Cos[x]\/\(z\^4 + \
4\)\)\[DifferentialD]x".

Solution 8.18.

Enter the functions  F[x] = Cos[x]/((x^4) + 4)  and  f[z] = ((e^(i z))/((z^4)  +  4))  and locate the singularities of  f[z].

Remove[x, z, Z]; 
Clear[f, F, g, Res1, Res2, Res3, Res4, solset, 
        val]; 
F[x_] = Cos[x]/((x^4)  +  4); 
f[
          z_]  =  ((E^(I z))/((z^4)  +  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];\)\ \)
(Subscript[Z, 4])  =  
        ReplaceAll[z, 
          (Subscript[solset, [[4]]])];  
\(\(Print[\*""\!\(z\_4\) = "", 
        Z\_4];\)\ \)

Which poles lie in the upper half plane?

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])]}]}, {Red, 
              PointSize[0.03], Point[{Re[(Subscript[Z, 3])], Im[(Subscript[Z, 3])]}]}, {Red, 
              PointSize[0.03], 
              Point[{Re[(Subscript[Z, 4])], Im[(Subscript[Z, 4])]}]}}]; 
\(\(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}], 
            Text[\*""\!\(z\_4\)"", {Re[Z\_4], Im[Z\_4] - 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[\*""\!\(z\_4\) = "", Z\_4, ",   Is  Im(", 
        Z\_4, ") > 0 ?    ", 
        N[Im[Z\_4]] > 0];\)\ \)

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

Res2  =  Residue[f[z], {z, (Subscript[Z, 2])}]; 
Res4  =  Residue[f[z], {z, (Subscript[Z, 4])}]; 
val  =  
        Together[- 2 π ( 
              Im[Res2]  +  Im[Res4] )]; 
Print["Res[f,", (Subscript[Z, 2]), "] = ", Res2]; 
Print["Res[f,", (Subscript[Z, 4]), "] = ", 
        Res4]; 
Print[""]; 
Print["Im[Res[f,", (Subscript[Z, 2]), "]] = ", Im[Res2]]; 
Print["Im[Res[f,", (Subscript[Z, 4]), "]] = ", 
        Im[Res4]]; 
dots = 
        Graphics[{{Red, PointSize[0.03], Point[{Re[(Subscript[Z, 2])], Im[(Subscript[Z, 2])]}]}, {Red, 
              PointSize[0.03], 
              Point[{Re[(Subscript[Z, 4])], Im[(Subscript[Z, 4])]}]}}]; 
\(\(centers = 
        Graphics[{Text[\*""\!\(z\_2\)"", {Re[Z\_2], 
                Im[Z\_2]}, {\(-1.2\), 0}], 
            Text[\*""\!\(z\_4\)"", {Re[Z\_4], Im[Z\_4]}, {\(-1.2\), 
                0}]}];\)\ \)
contour  =  
        Graphics[{VioletRed, 
            Circle[{0, 0}, 3, {0, π}]}]; 
segment = 
        Graphics[{Thickness[0.02], Magenta, 
            Line[{{-3, 0}, {3, 0}}]}]; 
Show[dots, centers, contour, segment, 
        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π(Im[", 
        Res2\ , "] + Im[", \ 
        Res4\ , "])"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = - 2π(", 
        Im[Res2]\ , " + (", \ 
        Im[Res4]\ , "))"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = - 2π(", 
        Im[Res2]\ \  + \ \ Im[
            Res4]\ , ")"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = ", 
        val];\)\ \)
\(\(Print[\*""The contour is the semicircle (Subscript[C, R]) and interval [-R,R],""];\)\ \)
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 "];\)\ \)
Print["= - 2π(Im[", Res2 , "] + Im[",  
        Res4 , "])"]; 
Print["= ", val, " = ", 
        N[val]];

Remark.  The integral of  F[x] for this problem 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["F[x] = ", F[x]]; 
Print["g[x] = ∫ ", F[x], " \[DifferentialD]x = ", 
        g[x]]; 
Print[""]; 
Print["      g[∞] = ", g[∞]]; 
Print["     g[-∞] = ", 
        g[-∞]]; 
Print[""]; 
Print["g[∞]-g[-∞] = ", 
        Simplify[g[∞] - g[-∞]]]; 
Print["g[∞]-g[-∞] = ", 
        N[g[∞] - 
            g[-∞]]];

This looks good, however it cannot be used to solve for the definite integral. This does not agree with the answer obtained with the residue calculus.

\(\(\(
\)\(\(Print[\*""(∫_(-∞)^∞)"", F[x], " \[DifferentialD]x = ", 
        val, " = ", N[val]];\)\(\ \)\(
\)
    \)\)\)

However, the definite integral will produce the following result.

val  = (∫_(-∞)^∞) 
              F[x] \[DifferentialD]x ; 
\(\(Print[\*""\!\(∫\_\(-∞\)\%∞\)"", 
        F[x], " \[DifferentialD]x = ", val, " = ", 
        N[val]];\)\ \)

Which is also the correct answer.

The PrincipalValue option can also be used.

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

We are almost ready to give the proof of Theorem 8.4. We first need one preliminary  result known as Jordan's lemma.

Lemma 8.1, (Jordan's Lemma), Page 330.  Let  P  and  Q  be polynomials with real coefficients of degree  m  and  n,  where  n ≥ m + 1.  If  (Subscript[C, R])  is the upper semicircle \(z = 
        R\ e\^iθ\ \ for\ \ 0\  ≤ \ θ\  ≤ \ 2  π\),  then

	\(\(\(\(lim\)\(\ \)\)\+\(R\  -> \ ∞\)\) \(∫\_\(C\_R\)\ \(e\^\(i\ z\)\ P \((z)\)\)\/\(Q \((z)\)\)\ dz\)\  = \ 0\).

Proof of Lemma 8.1, see text Page 330.

Section 8.5  Exercises for Improper Integrals Involving Trigonometric Functions
See textbook page 331.

Section 8.6	Indented Contour Integrals

Section 8.7	Integrands with Branch Points

Section 8.8	The Argument Principle and Rouche's Theorem

GO TO  THE  Table of Contents