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

COMPLEX ANALYSIS: for Mathematics and Engineering, 
3rd Edition,  1997,  ISBN: 0-7637-0270-6
Jones & Bartlett Publishers, Inc.
40 Tall Pine Drive, Sudbury, MA 01776
Tele.  (800) 832-0034, FAX:  (508)  443-8000
E-mail:  mkt@jbpub.com,     http://www.jbpub.com/
This free software is compliments of the authors.
mathews@fullerton.edu,  howell@westmont.edu

CHAPTER 8   RESIDUE THEORY
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 Integrals
GoTo Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11.
GoTo Contents

CHAPTER 8   RESIDUE THEORY

Clear[A, f, f0, F, g, G, i, p, R, Res, Res1, Res2, Res3, Res4, Res5, 
      Res6, solset, sub, S, θ, val, x, z, z1, z2, z3, z4, z5, z6, Z];

Section 8.1  The Residue Theorem

In this section we extend the results of the Cauchy integral formulae in 
Section 6.5 to integrals that have a finite number of isolated singularities 
which lie inside the contour C .

Definition,  Page 244.  Let  f(z)  have a nonremovable isolated singularity at the point  (Subscript[z, 0]).  
Then  f(z)  has the Laurent series representation  f(z) = (∑_(-∞)^∞)(((Subscript[a, n])(z-(Subscript[z, 0])))^n).  
The coefficient  (Subscript[a, -1])  of  (1/(z-(Subscript[z, 0]))) is called the residue of  f(z)  at  (Subscript[z, 0])  and 
we use the notation  Res[f, (Subscript[z, 0])] = a-1.

Theorem 8.1,  Page 245.  (Cauchy's Residue Theorem)  Let  D  be a simply connected domain, and let  C  be a simple closed positively oriented contour that lies in  D.  If  f(z)  is analytic inside  C  and on  C,  except at the points   (Subscript[z, 1]), (Subscript[z, 2]), ⋯, (Subscript[z, n])  that lie inside  C, then  (∫_C^( )) f(z) dz=2π i (∑_(k = 1)^n)Res[f,  (Subscript[z, k])].

Example 8.1,  Page 244.  Find the residue at z = 0 for the function  f(z) = (e^((2/z))).

\(Clear[f, Res, S, z]; 
f[z_]\  = \ E\^\(2\/z\); 

    S[z_]\  = \ Series[f[z], {z, ∞, 5}]; 

    Print["f[z] = ", f[z]]; 
Print["S[z] = ", S[z]]; \)

The coefficient of  (1/z)  is  2  so the residue is  Res[f, 0] = 2.

\(Res\  = \ \(S[z]\)[[3, 2]]; 

    Print[\*""Res[f,0] = Res[\!\(E\^\(2\/z\)\),0] = "", 
      Res]; \)

Example 8.2,  Page 244.  Find the residue at  z = 0  for the function  
g(z) = (3/(2 z + (z^2) - (z^3))).

\(Clear[g, Res, S, z]; 
g[z_]\  = \ 3\/\(2  z\  + \ z\^2\  - \ z\^3\); 

    S[z_]\  = \ Series[g[z], {z, 0, 4}]; 
Print["g[z] = ", g[z]]; 

    Print["S[z] = ", S[z]]; \)

The coefficient of  (1/z)  is  (3/2)  so the residue is  Res[g,0]  =  (3/2).

We compare this with Mathematica's  Residue procedure for computing residues.

\(Res\  = Residue[g[z], {z, 0}]; 

    Print[\*""Res[g,0] = Res[\!\(3\/\(2  z\\  + \\ z\^2\\  - \\ z\^3\)\),0] = "", Res]; \)

Example 8.3,  Page 245.  Use residues to integrate    (∫_( C)^(.))  (e^((2/z))) dz
around the circle  C: |z| =  1.

From Example 8.1  Res[f,0]  =  2.

\(Clear[Res, val]; 
Res\  = \ 2; 

    Print[\*""Res[f,0] = Res[\!\(E\^\(2\/z\)\),0] = "", 
      Res]; \)

Thus the value of the integral is:

val  =  2  π I Res;
Print["\!\(\(∫\_\(\\ \*
StyleBox[\(C\),
FontSize->12]\)\%.\)\)(E^((2/z)))\[DifferentialD]z = 2πI Res[f,0] = ",val];

GoTo Chapter 8

Section 8.2  Calculation of Residues

Theorem 8.2,  Page247.  (Residues at Poles)
(a)  	If  f(z)  has a simple pole at  (Subscript[z, 0]),  
	then  Res[f, (Subscript[z, 0])] = (lim_(z -> (Subscript[z, 0]))) (z - (Subscript[z, 0]))f(z)

(b)  	If  f(z)  has a pole of order 2 at  (Subscript[z, 0]),  
	then  Res[f, (Subscript[z, 0])] = (lim_(z -> (Subscript[z, 0]))) (∂_z) ((((z-(Subscript[z, 0])))^2)f(z))

(c)  	If  f(z)  has a pole of order 3 at  (Subscript[z, 0]),  
	then  Res[f, (Subscript[z, 0])] = (1/(2!))(lim_(z -> (Subscript[z, 0]))) (∂_(z, z)) ((((z-(Subscript[z, 0])))^3)f(z))

Example 8.4,  Page 248.  Find the residue of  f(z) = ((π cot(π z))/((z^2)))  at  (Subscript[z, 0]) = 0.

\(Clear[f, Res, S, z]; 
f[z_]\  = \ \(π\ Cot[π\ z]\)\/z\^2; 

    Print["f[z] = ", f[z]]; \)

The function  f(z)  has a pole of order  3  at  (Subscript[z, 0]) = 0.  
Now, the residue  at  (Subscript[z, 0]) = 0  is determined:

\(Print[\*""      (z^3)f[z] = "", z\^3\ f[z]]; 

    Print[\*"" (∂_z) ((z^3)f[z]) = "", 
      ∂\_z\ \((\(z\^3\) f[z])\)]; 

    Print[\*""(∂_(z, z)) ((z^3)f[z]) = "", 
      ∂\_\(z, z\)\ \((z\^3\ f[z])\)]; 

    Print[\*""(1/(2!))\!\(\(lim\\ \)\+\(z -> 0\)\)[(∂_(z, z))((z^3)f[z])] ="", 
      1\/\(2!\)\ 
        Limit[∂\_\(z, z\)\ \((z\^3\ f[z])\), z -> 0]]; \)

We compare this with Mathematica's  Residue procedure for computing residues.

\(Res\  = \ Residue[f[z], {z, 0}]; 

    Print[\*""Res[f,0] = Res[\!\(\(π\\ Cot[π\\ z]\)\/z\^2\),0] = "", Res]; \)

Which is the coefficient of  (1/z)  in the series expansion for  f[z].

\(S[z_]\  = \ Series[f[z], {z, 0, 7}]; 

    Res\  = \ \(S[z]\)[[3, 3]]; 

    Print["S[z] = ", S[z]]; 

    Print[\*""Res[f,0] = Res[\!\(\(π\\ Cot[π\\ z]\)\/z\^2\),0] = "", Res]; \)

Example 8.5,  Page  248.  Use residues to integrate   (∫_C^(.)) (1/((z^4) + (z^3) - 2(z^2)))dz 
around the circle C:  |z| = 3.

\(Clear[f, Res1, Res2, Res3, Res4, z, z1, z2, z3, z4]; 

    f[z_]\  = \(\ 1\)\/\(z\^4\  + \ z\^3\  - \ 2  z\^2\); 

    Print["f[z] = ", f[z]]; \)

Find the singularities of  f(z)  =  (1/((z^4) + (z^3) - 2(z^2))).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ReplaceAll[z, solset[[2]]]; 
    \ Print[\*""\!\(z\_2\) = "", z2]; 

    z3\  = \ ReplaceAll[z, solset[[3]]]; 
    \ Print[\*""\!\(z\_3\) = "", z3]; 

    z4\  = \ ReplaceAll[z, solset[[4]]]; 
    \ Print[\*""\!\(z\_4\) = "", z4]; \)

Find out which singularities lie within a circle  |z| < 3.

\(Print[\*""\!\(z\_1\) = "", z1, ", Is |", z1, "| < 3 ?  ", 
      N[Abs[z1]] < 3]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is |", z2, "| < 3 ?  ", 
      N[Abs[z2]] < 3]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is |", z3, "| < 3 ?  ", 
      N[Abs[z3]] < 3]; 

    Print[\*""\!\(z\_4\) = "", z4, ", Is |", z4, "| < 3 ?  ", 
      N[Abs[z4]] < 3]; \)

Compute the residues at  (Subscript[z, 1]), (Subscript[z, 2]) and  (Subscript[z, 4]).

\(Res1\  = \ Residue[f[z], {z, z1}]; 
Res2\  = \ Residue[f[z], {z, z2}]; 
    
Res4\  = \ Residue[f[z], {z, z4}]; 

    Print["Res[f,", z1, "] = ", Res1]; 

    Print["Res[f,", z2, "] = ", Res2]; 

    Print["Res[f,", z4, "] = ", Res4]; \)

The integral is computed by the residue calculus:

val  = 2 π I (Res1  +  Res2  +  Res4);
Print["\!\(\(∫\_\(\\ \*
StyleBox[\(C\),
FontSize->12]\)\%.\)\)\!\(\(\\ 1\)\/\(z\^4\\  + \\ z\^3\\  - \\ 2  z\^2\)\)\[DifferentialD]z = 2πI(((-1)/12) - (1/4) + (1/3))"];
Print["\!\(\(∫\_\(\\ \*
StyleBox[\(C\),
FontSize->12]\)\%.\)\)\!\(\(\\ 1\)\/\(z\^4\\  + \\ z\^3\\  - \\ 2  z\^2\)\)\[DifferentialD]z = ",val];

Example 8.6,  Page 249.  Use residues to integrate   (∫_C^(.)) (1/((z^4) +  4))dz
around the circle  C: |z-1| = 2.

\(Clear[f, Res1, Res2, Res3, Res4, z, z1, z2, z3, z4]; 

    f[z_]\  = \ 1\/\(z\^4\  + \ 4\); 
Print["f[z] = ", f[z]]; \)

Find the singularities of   f(z)  = (1/((z^4) +  4)).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ReplaceAll[z, solset[[2]]]; 
    \ Print[\*""\!\(z\_2\) = "", z2]; 

    z3\  = \ ReplaceAll[z, solset[[3]]]; 
    \ Print[\*""\!\(z\_3\) = "", z3]; 

    z4\  = \ ReplaceAll[z, solset[[4]]]; 
    \ Print[\*""\!\(z\_4\) = "", z4]; \)

Find out which singularities lie within a circle  |z-1| < 2.

\(Print[\*""\!\(z\_1\) = "", z1, ", Is |", z1, 
      " - 1| < 2 ?  ", N[Abs[z1 - 1]] < 2]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is |", z2, 
      " - 1| < 2 ?  ", N[Abs[z2 - 1]] < 2]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is |", z3, 
      " - 1| < 2 ?  ", N[Abs[z3 - 1]] < 2]; 

    Print[\*""\!\(z\_4\) = "", z4, ", Is |", z4, 
      " - 1| < 2 ?  ", N[Abs[z4 - 1]] < 2]; \)

Compute the residue at  (Subscript[z, 3]) and  (Subscript[z, 4]).

\(Res3\  = \ Residue[f[z], {z, z3}]; 
Res4\  = \ Residue[f[z], {z, z4}]; 
    
Print["Res[f,", z3, "] = ", Res3]; 

    Print["Res[f,", z4, "] = ", Res4]; \)

The integral is computed by the residue calculus:

val  = 2 π I (Res3  +  Res4);
Print["\!\(\(∫\_\(\\ \*
StyleBox[\(C\),
FontSize->12]\)\%.\)\)\!\(1\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]z = 2πI(((-1)/16) + (I/16) - (1/16) - (I/16))"];
Print["\!\(\(∫\_\(\\ \*
StyleBox[\(C\),
FontSize->12]\)\%.\)\)\!\(1\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]z = ",val];

Example 8.7,  Page 250.  Find the partial fraction expansion f(z) = ((3 z  +  2)/(z(z - 1)(z - 2))).

\(Clear[f, F, i, p, R, solset, z, Z]; 

    f[z_]\  = \ \(3  z\  + \ 2\)\/\(z \((z - 1)\) \((z - 2)\)\); 

    Print["f[z] = ", f[z]]; \)

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; 

    Z\  = \ Table[0, {Length[solset]}]; 
R\  = \ Table[0, {Length[solset]}]; 
    
F[z_]\  = \ 0; 

    For[i = 1, i ≤ Length[solset], \(i++\), 
\ \ \ 
      Z[[i]] = 
        ReplaceAll[z, solset[[i]]]; 

      \ \ \ If[1 == i, p\  = \ 1]; 
\ \ \ 
      If[1 < i; 
        Z[[i - 1]] == 
          Z[[i]], p = p + 1, p = 1]; 

      \ \ \ Print["z", i, " = ", 
        Z[[i]]]; 
\ \ \ 
      R[[i]]\  = \ 
        Residue[\(\((z - Z[[i]])\)\^\(p
                   - 1\)\) f[z], {z, 
            Z[[i]]}]; 
\ \ \ 
      Print["Res[", 
        \((z - Z[[i]])\)\^\(p - 1\), 
        " f,", Z[[i]], "] = ", 
        R[[i]]]; 
\ \ \ Print[" "]; 
      
\ \ \ F[z_]\  = \ 
        F[z]\  + \ 
          R[[i
              ]]\/\((
                z - Z[[i]])\)\^p; ]; 

    Print["f[z] = ", f[z]]; 
Print["f[z] = ", F[z]]; \)

Compare this with Mathematica's Apart  procedure for the partial fraction expansion.

\(Print["f[z] = ", f[z]]; 
Print["f[z] = ", Apart[f[z]]]; \)

Example 8.8,  Page 250.  Find the partial fraction expansion of  f(z) = (((z^2) + 3 z + 2)/((z^2) (z  -  1))).

\(Clear[f, F, i, p, R, solset, z, Z]; 

    f[z_]\  = \ \(z\^2\  + \ 3  z\  + \ 2\)\/\(\(z\^2\) \((z - 1)\)\); 

    Print["f[z] = ", f[z]]; \)

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; 

    Z\  = \ Table[0, {Length[solset]}]; 
R\  = \ Table[0, {Length[solset]}]; 
    
F[z_]\  = \ 0; 

    For[i = 1, i ≤ Length[solset], \(i++\), 
\ \ \ 
      Z[[i]] = 
        ReplaceAll[z, solset[[i]]]; 

      \ \ \ If[1 == i, p\  = \ 1]; 
\ \ \ 
      If[1 < i; 
        Z[[i - 1]] == 
          Z[[i]], p = p + 1, p = 1]; 

      \ \ \ Print["z", i, " = ", 
        Z[[i]]]; 
\ \ \ 
      R[[i]]\  = \ 
        Residue[\(\((z - Z[[i]])\)\^\(p
                   - 1\)\) f[z], {z, 
            Z[[i]]}]; 
\ \ \ 
      Print["Res[", 
        \((z - Z[[i]])\)\^\(p - 1\), 
        " f,", Z[[i]], "] = ", 
        R[[i]]]; 
\ \ \ Print[" "]; 
      
\ \ \ F[z_]\  = \ 
        F[z]\  + \ 
          R[[i
              ]]\/\((
                z - Z[[i]])\)\^p; ]; 

    Print["f[z] = ", f[z]]; 
Print["f[z] = ", F[z]]; \)

Compare this with Mathematica's Apart  procedure for the partial fraction expansion.

\(Print["f[z] = ", f[z]]; 
Print["f[z] = ", Apart[f[z]]]; \)

An Extra Example,  Page 251.  Find the partial fraction expansion  of  f(z) = (1/((z^4) - 1)).

\(Clear[f, F, i, p, R, solset, z, Z]; 
f[z_]\  = \ 1\/\(z\^4 - 1\); 

    Print["f[z] = ", f[z]]; \)

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; 

    Z\  = \ Table[0, {Length[solset]}]; 
R\  = \ Table[0, {Length[solset]}]; 
    
F[z_]\  = \ 0; 

    For[i = 1, i ≤ Length[solset], \(i++\), 
\ \ \ 
      Z[[i]] = 
        ReplaceAll[z, solset[[i]]]; 

      \ \ \ If[1 == i, p\  = \ 1]; 
\ \ \ 
      If[1 < i; 
        Z[[i - 1]] == 
          Z[[i]], p = p + 1, p = 1]; 

      \ \ \ Print["z", i, " = ", 
        Z[[i]]]; 
\ \ \ 
      R[[i]]\  = \ 
        Residue[\(\((z - Z[[i]])\)\^\(p
                   - 1\)\) f[z], {z, 
            Z[[i]]}]; 
\ \ \ 
      Print["Res[", 
        \((z - Z[[i]])\)\^\(p - 1\), 
        " f,", Z[[i]], "] = ", 
        R[[i]]]; 
\ \ \ Print[" "]; 
      
\ \ \ F[z_]\  = \ 
        F[z]\  + \ 
          R[[i
              ]]\/\((
                z - Z[[i]])\)\^p; ]; 

    Print["f[z] = ", f[z]]; 
Print["f[z] = ", F[z]]; \)

Which is an improvement on Mathematica's Apart  procedure.

\(Print["f[z] = ", f[z]]; 
Print["f[z] = ", Apart[f[z]]]; \)

GoTo Chapter 8

Section 8.3  Trigonometric Integrals

The method in this section is used to evaluate integrals of the form   
(∫_0^(2 π))F(cos(θ), sin(θ))dθ    by using the contour  C: |z| = 1,  
and the change of variable  cos(θ) = ((z+(1/z))/2),   sin(θ) = ((z-(1/z))/(2 i))  and   dθ = (dz/(i Z)),
and the complex function   f(z) = ((F(((z+(1/z))/2), ((z-(1/z))/(2 i))))/(i z)).

These problems were also solved using Mathematica's table of integrals.

We need to use the following substitution procedure.

\(Clear[f0, F, sub, θ, z]; 

    sub[F_, θ_]\  := 

      Module[{}, 
\ \ Clear[f0]; 
\ \ f0\  = \ F; 
\ \ 
        f0\  = \ ReplaceAll[
            f0, {Cos[θ] -> \(z + 1\/z\)\/2, 
              Sin[θ] -> \(z - 1\/z\)\/\(2  I\)}]; 

        \ \ f0\  = \ 
          ReplaceAll[
            f0, {Cos[2  θ] -> \(z\^2 + 1\/z\^2\)\/2, 
              Sin[2  θ] -> 
                \(z\^2 - 1\/z\^2\)\/\(2  I\)}]; 
\ \ 
        f0\  = \ ReplaceAll[
            f0, {Cos[3  θ] -> \(z\^3 + 1\/z\^3\)\/2, 
              Sin[3  θ] -> 
                \(z\^3 - 1\/z\^3\)\/\(2  I\)}]; 
\ \ 
        f0\  = \ f0\/\(I\ z\); 
\ \ f0\  = \ Together[f0]; 
\ \ 
        f0\  = \ Cancel[f0]; 
\ \ Return[f0]; \ ]; \)

Example 8.9,  Page 253.    Use substitution and an equivalent contour integral to evaluate   (∫_0^(2 π))(1/(1 + 3 (cos^2)(θ)))dθ.

\(Clear[f, G, F, Res1, Res2, Res3, Res4, solset, θ, val, z, z1, 
      z2, z3, z4]; 

    F[θ_]\  = \(\ 1\)\/\(1\  + \ 3\ Cos[θ]\^2\); 

    f[z_]\  = \ sub[F[θ], θ]; 

    Print["F[θ] = ", F[θ]]; 
Print["f[z] = ", f[z]]; 
    \)

Find the singularities of  f(z)  =  ((- 4 i z)/(3 (z^4) + 10(z^2) + 3)).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ReplaceAll[z, solset[[2]]]; 
    \ Print[\*""\!\(z\_2\) = "", z2]; 

    z3\  = \ ReplaceAll[z, solset[[3]]]; 
    \ Print[\*""\!\(z\_3\) = "", z3]; 

    z4\  = \ ReplaceAll[z, solset[[4]]]; 
    \ Print[\*""\!\(z\_4\) = "", z4]; \)

Find out which singularities lie within a circle  |z| < 1.

\(Print[\*""\!\(z\_1\) = "", z1, ", Is |", z1, "| < 1 ?  ", 
      N[Abs[z1]] < 1]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is |", z2, "| < 1 ?  ", 
      N[Abs[z2]] < 1]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is |", z3, "| < 1 ?  ", 
      N[Abs[z3]] < 1]; 

    Print[\*""\!\(z\_4\) = "", z4, ", Is |", z4, "| < 1 ?  ", 
      N[Abs[z4]] < 1]; \)

Compute the residues at  (Subscript[z, 1])  and  (Subscript[z, 2]).

\(Res1\  = \ Residue[f[z], {z, z1}]; 
Res2\  = \ Residue[f[z], {z, z2}]; 
    
Print["Res[f,", z1, "] = ", Res1]; 

    Print["Res[f,", z2, "] = ", Res2]; \)

The integral is computed by the residue calculus:

\(\(\ val\  = \ 2\ π\ I\ \((Res1\  + \ Res2)\); 

    Print[\*""(∫_0^(2  π))\!\(\(\\ 1\)\/\(1\\  + \\ 3\\ Cos[θ]\^2\)\)\[DifferentialD]θ = 2πI(((-I)/4) + (I/4)) = "", val]; \)\)

Mathematica  is capable of finding some of these difficult integrals.  
The function  F(θ) = (1/(1 + 3 (cos^2)(θ))) can be integrated directly to obtain:

\(G[θ_]\  = \ 
      ∫\(\(\ 1\)\/\(1\  + \ 3\ Cos[θ]\^2\)\) 
          \[DifferentialD]θ; 

    val\  = \ ∫\_0
          \%\(2  π\)\(\(\ 1\)\/\(1\  + \ 3\ Cos[θ]\^2\)\) 
          \[DifferentialD]θ; 

    Print[\*""G[θ] = ∫\!\(\(\\ 1\)\/\(1\\  + \\ 3\\ Cos[θ]\^2\)\)\[DifferentialD]θ = "", G[θ]]; 

    Print[\*""     (∫_0^(2  π))\!\(\(\\ 1\)\/\(1\\  + \\ 3\\ Cos[θ]\^2\)\)\[DifferentialD]θ = "", val]; \)

However, direct substitution using  G(θ)  and the endpoints of the interval seems 
to be erroneous.  This is due to the fact that  cot(0)  and  cot(2π)  are undefined.

\(Print["      G[0] = ", G[0]]; 

    Print["     G[2π] = ", G[2  π]]; 

    Print["G[2π]-G[0] = ", G[2  π] - G[0]]; \)

This is due to the fact that cot(0) and cot(2π) are undefined.  A graph of  G(θ)  reveals that it has a discontinuity at θ = π in the middle of the interval [0, 2π].  This is a violation of the Fundamental Theorem of Calculus, which asserts that the integral of a continuous function must be continuous.

\(Plot[G[θ], {θ, 0, 2  π}, 
      PlotRange -> {{0, 2  π}, {\(-1\), 1}}, 
      Ticks -> {Range[0, 2  π, π\/2], Range[\(-1\), 1, 0.5]}, 
      PlotStyle -> RGBColor[1, 0, 0], 
      AxesLabel -> {"θ", "s"}]; 

    Print["s = ", G[θ]]; \)

The indefinite integrand G(θ) can be used piecewise over  (0, π)  and  (π, 2π) 
where it is continuous, by using the left and right hand limits at the endpoints.

\(val\  = \ 
      Limit[G[θ], θ -> π, Direction -> 1]\  - \ 
        Limit[G[θ], θ -> 0, Direction -> \(-1\)]\  + 
        \ Limit[G[θ], θ -> 2  π, Direction -> 1]\ 
         - \ Limit[G[θ], θ -> π, 
          Direction -> \(-1\)]; 

    Print[\*""(∫_0^(2  π))\!\(\(\\ 1\)\/\(1\\  + \\ 3\\ Cos[θ]\^2\)\)\[DifferentialD]θ = "", val]; \)

The above answer is correct too.
Limits were required because G(θ) is not continuous at  θ = 0,  θ = π   and   θ = 2π.

Example 8.10,  Page 255.    Show that   (∫_0^(2 π))((cos(2θ))/(5 - 4cos(θ)))dθ=(π/6).
Solution.  The solution is given in the textbook.

GoTo Chapter 8

Section 8.4  Improper Integrals of Rational Functions

Theorem 8.3,  Page 257.  Let  f(z) = ((P(x))/(Q(x)))  where  P(x)  and  Q(x)  are polynomials, of degree  m  and  n ,  respectively.  If  Q(x) ≠ 0  for all real  x  and  m + 2 ≤ n,  and  (Subscript[z, 1]),(Subscript[z, 2]),⋯,(Subscript[z, k])  are the poles of  ((P(x))/(Q(x)))  that lie in the upper half plane.  Then    P.V. (∫_(-∞)^∞)((P(x))/(Q(x)))dx=2π i (∑_(j = 1)^k)Res[(P/Q), (Subscript[z, j])].

These problems were also solved using Mathematica's table of integrals.

Example 8.11,  Page 257.  Evaluate   (lim_(R -> ∞))   (∫_(-R)^R)  xdx.
This is the Cauchy Principal Value of the integral (C.P.V.).

\(Clear[f, F, lim1, lim2, R, x]; 
f[x_]\  = \ x; 

    F[x_]\  = ∫x \[DifferentialD]x; 

    lim1\  = \ 
      ∫\_\(-∞\)\%∞ x \[DifferentialD]x; 

    lim2\  = \ Limit[\ F[R]\  - \ F[\(-R\)], \ R -> ∞]; 

    Print["f[x] = ", f[x]]; 

    Print["F[x] = ∫ x \[DifferentialD]x = ", F[x]]; 

    Print[\*""  (lim_(R -> ∞)) (∫_(-R)^R) x \[DifferentialD]x = "", lim1]; 

    Print[\*""  (lim_(R -> ∞)) (∫_(-R)^R) x \[DifferentialD]x = "", lim2]; 

    Print[\*""C.P.V. (∫_(-∞)^∞) x \[DifferentialD]x = "", lim2]; \)

Example 8.12,  Page 257.  Evaluate    (∫_(-∞)^∞)(1/((x^2)  +  1))dx.

\(Clear[f, g, Res1, Res2, solset, val, x, z, z1, z2]; 

    f[z_]\  = \ 1\/\(z\^2\  + \ 1\); 
Print["f[x] = ", f[x]]; \)

Find the singularities of  f(z) = (1/((z^2) + 1)).

solset  =  Sort[Solve[Denominator[f[z]] == 0, z]]\(z1\  = \ 
      ReplaceAll[z, solset[[1]]]; \ 
    Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ReplaceAll[z, solset[[2]]]; 
    \ Print[\*""\!\(z\_2\) = "", z2]; \)

Which poles lie in the upper half plane ?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") > 0 ?  ", N[Im[z1]] > 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") > 0 ?  ", N[Im[z2]] > 0]; \)

Find the residue at (Subscript[z, 2]).

\(Res2\  = \ Residue[f[z], {z, z2}]; 

    Print["Res[f,", z2, "] = ", Res2]; \)

The integral is computed by the residue calculus:

\(val\  = \ 2  π\ I\ Res2; 

    Print[\*""(∫_(-∞)^∞)\!\(1\/\(x\^2\\  + \\ 1\)\)\[DifferentialD]x = "", val]; \)

Or, we can evaluate the integral with anti-derivatives:

\(g[x_]\  = ∫\(1\/\(x\^2\  + \ 1\)\) \[DifferentialD]x; 

    val\  = ∫\_\(-
            ∞\)\%∞\( 1\/\(x\^2\  + \ 1\)\) 
          \[DifferentialD]x; 
Print["f[x] = ", f[x]]; 

    Print[\*""g[x] = ∫\!\(1\/\(x\^2\\ \(+\(\\ 1\)\)\)\)\[DifferentialD]x = "", g[x]]; 

    Print["g[∞] = ", g[∞], 
      ",    g[-∞] = ", \ g[\(-∞\)]]; 

    Print[\*""(∫_(-∞)^∞)\!\(1\/\(x\^2\\ \(+\(\\ 1\)\)\)\)\[DifferentialD]x = g[∞]-g[-∞] = "", g[∞]\  - \ g[\(-∞\)]]; 

    Print[\*""(∫_(-∞)^∞)\!\(1\/\(x\^2\\ \(+\(\\ 1\)\)\)\)\[DifferentialD]x = "", val]; \)

The above answers are correct too.

Example 8.13,  Page 259.  Use the residue calculus to evaluate the integral
    (∫_(-∞)^∞)(1/(((x^2)  +  1) ((x^2)  +  4)))dx  =  (π/6).

\(Clear[f, g, Res1, Res2, Res3, Res4, solset, val, x, z, z1, z2, z3, z4]; 
    
f[z_]\  = \ 1\/\(\((z\^2\  + \ 1)\) \((z\^2\  + \ 4)\)\); 

    Print["f[x] = ", f[x]]; \)

Find the singularities of  f(z)  =  (1/(((z^2) + 1)((z^2) + 4))).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ReplaceAll[z, solset[[2]]]; 
    \ Print[\*""\!\(z\_2\) = "", z2]; 

    z3\  = \ ReplaceAll[z, solset[[3]]]; 
    \ Print[\*""\!\(z\_3\) = "", z3]; 

    z4\  = \ ReplaceAll[z, solset[[4]]]; 
    \ Print[\*""\!\(z\_4\) = "", z4]; \)

Which poles lie in the upper half plane?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") > 0 ?  ", N[Im[z1]] > 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") > 0 ?  ", N[Im[z2]] > 0]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is  Im(", z3, 
      ") > 0 ?  ", N[Im[z3]] > 0]; 

    Print[\*""\!\(z\_4\) = "", z4, ", Is  Im(", z4, 
      ") > 0 ?  ", N[Im[z4]] > 0]; \)

Find the residues at  (Subscript[z, 2])  and  (Subscript[z, 4]).

\(Res2\  = \ Residue[f[z], {z, z2}]; 
Res4\  = \ Residue[f[z], {z, z4}]; 
    
Print["Res[f,", z2, "] = ", Res2]; 

    Print["Res[f,", z4, "] = ", Res4]; \)

The integral is computed by the residue calculus:

\(val\  = \ 2\ π\ I\ \((Res2\  + \ Res4)\); 

    Print[\*""(∫_(-∞)^∞)\!\(1\/\(\((x\^2\\  + \\ 1)\) \((x\^2\\  + \\ 4)\)\)\)\[DifferentialD]x = 2πI(((-I)/6) + (I/12)) = "", 
      val]; \)

Or, we can evaluate the integral with anti-derivatives:

\(g[x_]\  = \ ∫f[x] \[DifferentialD]x; 

    Print["g[x] = ∫f[x]\[DifferentialD]x = ", g[x]]; \)

Limits must be used to compute values of g[\(\(0\^+\)\)] and g[\(\(0\^-\)\)].

\(val\  = \ 
      Limit[g[x], x -> ∞] - 
        Limit[g[x], x -> 0, Direction -> \(-1\)]\  + 

        Limit[g[x], x -> 0, Direction -> 1]\  - 
        Limit[g[x], x -> \(-∞\)]; 

    Print[\*""(∫_(-∞)^∞)\!\(1\/\(\((x\^2\\  + \\ 1)\) \((x\^2\\  + \\ 4)\)\)\)\[DifferentialD]x = "", 
      val]; \)

The above answer is correct too.

Example 8.14,  Page 260.  Use the residue calculus to evaluate the integral
    (∫_(-∞)^∞)(1/((((x^2) + 4))^3))dx  =  ((3 π)/256).

\(Clear[f, g, Res1, Res2, Res3, Res4, Res5, Res6, solset, val, x, z, z1, 
      z2, z3, z4, z5, z6]; 
f[z_]\  = \ 1\/\((z\^2\  + \ 4)\)\^3; 

    Print["f[x] = ", f[x]]; \)

Find the singularities of  f(z)  =  (1/((((z^2) + 4))^3)).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ReplaceAll[z, solset[[2]]]; 
    \ Print[\*""\!\(z\_2\) = "", z2]; 

    z3\  = \ ReplaceAll[z, solset[[3]]]; 
    \ Print[\*""\!\(z\_3\) = "", z3]; 

    z4\  = \ ReplaceAll[z, solset[[4]]]; 
    \ Print[\*""\!\(z\_4\) = "", z4]; 

    z5\  = \ ReplaceAll[z, solset[[5]]]; 
    \ Print[\*""\!\(z\_5\) = "", z5]; 

    z6\  = \ ReplaceAll[z, solset[[5]]]; 
    \ Print[\*""\!\(z\_6\) = "", z6]; \)

Which poles lie in the upper half plane?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") > 0 ?  ", N[Im[z1]] > 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") > 0 ?  ", N[Im[z2]] > 0]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is  Im(", z3, 
      ") > 0 ?  ", N[Im[z3]] > 0]; 

    Print[\*""\!\(z\_4\) = "", z4, ", Is  Im(", z4, 
      ") > 0 ?  ", N[Im[z4]] > 0]; 

    Print[\*""\!\(z\_5\) = "", z5, ", Is  Im(", z5, 
      ") > 0 ?  ", N[Im[z5]] > 0]; 

    Print[\*""\!\(z\_6\) = "", z6, ", Is  Im(", z6, 
      ") > 0 ?  ", N[Im[z6]] > 0]; \)

Compute the residue at  (Subscript[z, 4]).

\(Res4\  = \ Residue[f[z], {z, z4}]; 

    Print["Res[f,", z4, "] = ", Res4]; \)

The integral is computed by the residue calculus:

\(val\  = \ 2\ π\ I\ Res4; 

    Print[\*""(∫_(-∞)^∞)\!\(1\/\((z\^2\\  + \\ 4)\)\^3\)\[DifferentialD]x = "", val]; \)

Or, we can evaluate the integral with anti-derivatives:

\(g[x_]\  = ∫f[x] \[DifferentialD]x; 

    Print["g[x] = ∫f[x]\[DifferentialD]x = ", g[x]]; \)

Limits must be used to compute values of g[\(\(0\^+\)\)] and g[\(\(0\^-\)\)].

\(val\  = \ 
      Limit[g[x], x -> ∞]\  - 

        Limit[g[x], x -> 0, Direction -> \(-1\)]\  + 

        Limit[g[x], x -> 0, Direction -> 1]\  - \ 

        Limit[g[x], x -> \(-∞\)]; 

    Print[\*""(∫_(-∞)^∞)\!\(1\/\((z\^2\\  + \\ 4)\)\^3\)\[DifferentialD]x = "", val]; \)

The above answer is correct too.

GoTo Chapter 8

Section 8.5  Improper Integrals involving Trigonometric Functions

Theorem 8.4,  Page 261.  Let  P  and  Q  be polynomials, of degree  m  and  n,  where  m+1 ≤ n  
and  Q(x) ≠ 0  for all real  x .  If  0 < α  and  f(z) = ((exp(i α z) P(z))/(Q(z))), then  
P.V. (∫_(-∞)^∞)((P(x)cos(α x))/(Q(x)))dx=-2π (∑_(j = 1)^k)Im(Res[(P/Q), (Subscript[z, j])]),   and  
P.V. (∫_(-∞)^∞)((P(x)sin(α x))/(Q(x)))dx=-2π (∑_(j = 1)^k)Re(Res[(P/Q), (Subscript[z, j])]),
where  (Subscript[z, 1]),(Subscript[z, 2]),⋯,(Subscript[z, k])  are the poles of  f(z)  that lie in the upper half plane and where  Re(Res[(P/Q), (Subscript[z, j])])  and  Im(Res[(P/Q), (Subscript[z, j])])  are the real and imaginary parts of   Res[(P/Q), (Subscript[z, j])], respectively.

These problems were also solved using Mathematica's table of integrals.

Example 8.15,  Page 261.  Use the residue calculus to evaluate the integral
    (∫_(-∞)^∞)((x sin(x))/((x^2)  +  4))dx  =  (π/((e^2))).

\(Clear[f, g, Res1, Res2, solset, val, x, z, z1, z2]; 

    f[z_]\  = \ 
      \(z\ E\^\(I\ z\)\)\/\(z\^2\  + \ 4\); 

    Print["f[x] = ", f[x]]; \)

Find the singularities of  f(z)  =  ((z (e^(i z)))/((z^2)  +  4)).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ReplaceAll[z, solset[[2]]]; 
    \ Print[\*""\!\(z\_2\) = "", z2]; \)

Which poles lie in the upper half plane?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") > 0 ?  ", N[Im[z1]] > 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") > 0 ?  ", N[Im[z2]] > 0]; \)

Compute the residue at  z2.

\(Res2\  = \ Residue[f[z], {z, z2}]; 

    Print["Res[f,", z2, "] = ", Res2]; \)

The integral is computed by the residue calculus:

\(val\  = \ 2\ π\ Re[Res2]; 

    Print[\*""(∫_(-∞)^∞)\!\(\(x\\ Sin[x]\)\/\(x\^2\\  + \\ 4\)\)\[DifferentialD]x = "", val]; \)

Remark.  The integral for this problem is g(x), but it cannot be used 
in any meaningful way to solve the problem at hand.

\(g[x_]\  = 
      ∫\(\(x\ Sin[x]\)\/\(x\^2\  + \ 4\)\) \[DifferentialD]x; 

    Print["g[x] = ∫f[x]\[DifferentialD]x = ", g[x]]; \)

\(Print["      g[∞] = ", g[∞]]; 

    Print["     g[-∞] = ", g[\(-∞\)]]; 

    Print["g[∞]-g[-∞] = ", 
      g[∞] - g[\(-∞\)]]; 

    Print["g[∞]-g[-∞] = ", 
      N[g[∞] - g[\(-∞\)]]]; \)

They look good, however they can not be used to solve for the definite integral.
This does not agree with the answer obtained with the residue calculus.

\(\(Print[
      \*""(∫_(-∞)^∞)\!\(\(x\\ Sin[x]\)\/\(x\^2\\  + \\ 4\)\)\[DifferentialD]x = "", 
      N[2\ π\ Re[Res2]]]; \)\)

However, the definite integral will produce:

\(val\  = 
      ∫\_\(-
            ∞\)\%∞\(\( x\ Sin[x]\)\/\(x\^2\  + \ 4\)\) 
          \[DifferentialD]x\ ; 

    Print[\*""(∫_(-∞)^∞)\!\(\(x\\ Sin[x]\)\/\(x\^2\\  + \\ 4\)\)\[DifferentialD]x = "", val]; 

    Print[\*""(∫_(-∞)^∞)\!\(\(x\\ Sin[x]\)\/\(x\^2\\  + \\ 4\)\)\[DifferentialD]x = "", N[val]]; 

    Print[\*""(∫_(-∞)^∞)\!\(\(x\\ Sin[x]\)\/\(x\^2\\  + \\ 4\)\)\[DifferentialD]x = "", 
      FullSimplify[val]]; \)

Which is also the correct answer.

Example 8.16,  Page 262.  
Use the residue calculus to evaluate the integral    (∫_(-∞)^∞)((cos(x))/((x^2)  +  4))dx.

\(Clear[f, g, Res1, Res2, Res3, Res4, solset, val, x, z, z1, z2, z3, z4]; 
    
f[z_]\  = \ E\^\(I\ z\)\/\(z\^4\  + \ 4\); 

    Print["f[x] = ", f[x]]; \)

Find the singularities of  f(z)  =  (((e^(i z)))/((z^4)  +  4)).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ReplaceAll[z, solset[[2]]]; 
    \ Print[\*""\!\(z\_2\) = "", z2]; 

    z3\  = \ ReplaceAll[z, solset[[3]]]; 
    \ Print[\*""\!\(z\_3\) = "", z3]; 

    z4\  = \ ReplaceAll[z, solset[[4]]]; 
    \ Print[\*""\!\(z\_4\) = "", z4]; \)

Which poles lie in the upper half plane?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") > 0 ?  ", N[Im[z1]] > 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") > 0 ?  ", N[Im[z2]] > 0]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is  Im(", z3, 
      ") > 0 ?  ", N[Im[z3]] > 0]; 

    Print[\*""\!\(z\_4\) = "", z4, ", Is  Im(", z4, 
      ") > 0 ?  ", N[Im[z4]] > 0]; \)

Compute the residues at  (Subscript[z, 2])  and  (Subscript[z, 4]).

\(Res2\  = \ Residue[f[z], {z, z2}]; 
Res4\  = \ Residue[f[z], {z, z4}]; 
    
Print["Res[f,", z2, "] = ", Res2]; 

    Print["Res[f,", z4, "] = ", Res4]; \)

The integral is computed by the residue calculus:

\(val\  = \ Together[\(-\ 2\)\ π\ \((\ Im[Res2]\  + \ Im[Res4]\ )\)]; 
    
Print[\*""(∫_(-∞)^∞)\!\(Cos[x]\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]x = "", val]; 

    Print[\*""(∫_(-∞)^∞)\!\(Cos[x]\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]x = "", N[val]]; \)

Remark.  The integral for this problem is g(x), but it cannot be used 
in any meaningful way to solve the problem at hand.

\(g[x_]\  = ∫\(Cos[x]\/\(x\^4\  + \ 4\)\) \[DifferentialD]x; 

    Print[\*""g[x] = ∫\!\(Cos[x]\/\(x\^4\\ \(+\(\\ 4\)\)\)\)\[DifferentialD]x = ""]; 
Print[g[x]]; 

    Print["      g[∞] = ", FullSimplify[g[∞]]]; 

    Print["     g[-∞] = ", FullSimplify[g[\(-∞\)]]]; 
    
Print["g[∞]-g[-∞] = ", 
      FullSimplify[g[∞] - g[\(-∞\)]]]; 

    Print["g[∞]-g[-∞] = ", 
      N[g[∞] - g[\(-∞\)]]]; \)

Which does not agree with the answer obtained via residues.

\(val\  = \ Together[\(-\ 2\)\ π\ \((\ Im[Res2]\  + \ Im[Res4]\ )\)]; 
    
Print[\*""(∫_(-∞)^∞)\!\(Cos[x]\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]x = "", val]\)\(Print[
      \*""(∫_(-∞)^∞)\!\(Cos[x]\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]x = "", N[val]]\)

However, the definite integral will produce:

\(val\  = 
      ∫\_\(-∞\)\%∞\( Cos[x]\/\(x\^4 + 4\)\) 
          \[DifferentialD]x; 

    Print[\*""(∫_(-∞)^∞)\!\(Cos[x]\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]x = "", val]; 

    Print[\*""(∫_(-∞)^∞)\!\(Cos[x]\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]x = "", FullSimplify[val]]; 

    Print[\*""(∫_(-∞)^∞)\!\(Cos[x]\/\(z\^4\\  + \\ 4\)\)\[DifferentialD]x = "", N[val]]; \)

Which is also the correct answer.

GoTo Chapter 8

Section 8.6  Indented Integrals

Theorem 8.5,  Page 265.  Let  f(z) = ((P(x))/(Q(x)))  where  P(x)  and  Q(x)  are polynomials with real coefficients of degree  m  and  n ,  respectively, where  m + 2 ≤ n.  If  Q(x)  has simple zeros at the points  (Subscript[t, 1]),(Subscript[t, 2]),⋯,(Subscript[t, l])  on the x axis, and  (Subscript[z, 1]),(Subscript[z, 2]),⋯,(Subscript[z, k])  are the poles of  f(z)  that lie in the upper half plane,
then   P.V. (∫_(-∞)^∞)((P(x))/(Q(x)))dx=2π i (∑_(j = 1)^k)Res[f,  (Subscript[z, j])]+ π i (∑_(j = 1)^l)Res[f, (Subscript[t, j])].

These problems were also solved using Mathematica's table of integrals.

Example 8.17,  Page 265.  Show that  P.V. (∫_(-1)^8)(1/((x^(1/3))))dx=(9/2).
Solution.  The solution is given in the textbook.

Example 8.18,  Page 266.  Show that  P.V. (∫_(-∞)^∞)(x/((x^3)  -  8 ))dx=((π (Sqrt[3]))/6).

\(Clear[f, g, Res1, Res2, solset, val, x, z, z1, z2]; 

    f[z_]\  = \ z\/\(z\^3\  - \ 8\); 
Print["f[x] = ", f[x]]; \)

Find the singularities of  f(z)  =  (z/((z^3)  -  8)).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ 
Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ComplexExpand[
        ReplaceAll[z, solset[[2]]]]; \ 

    Print[\*""\!\(z\_2\) = "", z2]; 

    z3\  = \ ComplexExpand[
        ReplaceAll[z, solset[[3]]]]; \ 

    Print[\*""\!\(z\_3\) = "", z3]; \)

Which poles lie in the upper half plane?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") > 0 ?  ", N[Im[z1]] > 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") > 0 ?  ", N[Im[z2]] > 0]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is  Im(", z3, 
      ") > 0 ?  ", N[Im[z3]] > 0]; \)

Which poles lie on the real axis?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") = 0 ?  ", N[Im[z1]] == 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") = 0 ?  ", N[Im[z2]] == 0]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is  Im(", z3, 
      ") = 0 ?  ", N[Im[z3]] == 0]; \)

Compute the residues at  (Subscript[z, 1])  and  (Subscript[z, 3]).

\(Res1\  = \ Residue[f[z], {z, z1}]; 
Res3\  = \ Residue[f[z], {z, z3}]; 
    
Print["Res[f,", z1, "] = ", Res1]; 

    Print["Res[f,", z3, "] = ", Res3]; \)

The integral is computed by the residue calculus:

\(val\  = \ 2\ π\ I\ Res3 + π\ I\ Res1; 

    Print[\*""(∫_(-∞)^∞)\!\(x\/\(x\^3 - \\ 8\\ \)\)\[DifferentialD]x = "", val, " = ", 
      ComplexExpand[val]]; \)

Remark.  The integral for this problem is g(x), but it cannot be used in any meaningful way to solve the problem at hand.

\(g[x_]\  = ∫\(x\/\(x\^3\  - \ 8\)\) \[DifferentialD]x; 

    Print["g[x] = ∫f[x]\[DifferentialD]x = ", g[x]]; 

    L1\  = \ Limit[g[x], x -> ∞]; 

    L2\  = \ Limit[g[x], x -> \(-∞\)]; 

    Print["      g[∞] = ", L1]; 

    Print["     g[-∞] = ", L2]; 

    Print["g[∞]-g[-∞] = ", L1 - L2]; 

    Print["g[∞]-g[-∞] = ", ComplexExpand[L1 - L2]]; 
    \)

However, the Cauchy principle value of the definite integral will produce:

\(val\  = \ 
      Integrate[x\/\(x\^3\  - \ 8\), {x, \(-∞\), ∞}, 
        PrincipalValue -> True]; 

    Print[\*""(∫_(-∞)^∞)\!\(x\/\(x\^3 - \\ 8\\ \)\)\[DifferentialD]x = "", val]; \)

Which is also the correct answer.

Example 8.19,  Page 267.  Show that  P.V. (∫_(-∞)^∞)((sin(x))/((x  -  1)((x^2) + 4) ))dx=((π (Sqrt[3]))/6).

\(Clear[f, g, Res1, Res2, solset, val, x, z, z1, z2]; 

    f[z_]\  = \ 
      E\^\(I\ z\)\/\(\((z - 1)\) 
          \((z\^2\  + \ 4)\)\); 
Print["f[z] = ", f[z]]; 

    F[x_]\  = \ Sin[x]\/\(\((x - 1)\) \((x\^2\  + \ 4)\)\); 

    Print["F[x] = ", F[x]]; \)

Find the singularities of  f (z)=(((e^(i z)))/((x - 1) ((x^2)  +  4))).

\(solset\  = \ Sort[Solve[Denominator[f[z]] == 0, z]]; \ Print[solset]; 

    z1\  = \ ReplaceAll[z, solset[[1]]]; 
    \ 
Print[\*""\!\(z\_1\) = "", z1]; 

    z2\  = \ ComplexExpand[
        ReplaceAll[z, solset[[2]]]]; \ 

    Print[\*""\!\(z\_2\) = "", z2]; 

    z3\  = \ ComplexExpand[
        ReplaceAll[z, solset[[3]]]]; \ 

    Print[\*""\!\(z\_3\) = "", z3]; \)

Which poles lie in the upper half plane?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") > 0 ?  ", N[Im[z1]] > 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") > 0 ?  ", N[Im[z2]] > 0]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is  Im(", z3, 
      ") > 0 ?  ", N[Im[z3]] > 0]; \)

Which poles lie on the real axis?

\(Print[\*""\!\(z\_1\) = "", z1, ", Is  Im(", z1, 
      ") = 0 ?  ", N[Im[z1]] == 0]; 

    Print[\*""\!\(z\_2\) = "", z2, ", Is  Im(", z2, 
      ") = 0 ?  ", N[Im[z2]] == 0]; 

    Print[\*""\!\(z\_3\) = "", z3, ", Is  Im(", z3, 
      ") = 0 ?  ", N[Im[z3]] == 0]; \)

Compute the residues at  (Subscript[z, 2])  and  (Subscript[z, 3]).

\(Res2\  = \ Residue[f[z], {z, z2}]; 
Res3\  = \ Residue[f[z], {z, z3}]; 
    
Print["Res[f,", z2, "] = ", Res2]; 

    Print["Res[f,", z3, "] = ", Res3]; \)

The integral is computed by the residue calculus:

\(val\  = \ 2\ π\ Re[Res2] + π\ Re[\ Res3]; 

    Print[\*""(∫_(-∞)^∞)\!\(x\/\(x\^3 - \\ 8\\ \)\)\[DifferentialD]x = "", val, " = ", 
      ComplexExpand[val]]; \)

Remark.  The integral for this problem is g(x), but it cannot be used in any meaningful way to solve the problem at hand.

\(g[x_]\  = 
      ∫\(Sin[x]\/\(\((x - 1)\) \((x\^2\  + \ 4)\)\)\) 
          \[DifferentialD]x; 

    Print["g[x] = ∫f[x]\[DifferentialD]x = ", g[x]]; \)

However, the Cauchy principle value of the definite integral will produce:

\(\(val\  = \ 
      Integrate[
        Sin[x]\/\(\((x - 1)\) \((x\^2\  + \ 4)\)\), {x, \(-∞\), 
          ∞}, PrincipalValue -> True]; 

    Print[\*""(∫_(-∞)^∞)\!\(Sin[x]\/\(\((x - 1)\) \((x\^2\\  + \\ 4)\)\)\)\[DifferentialD]x = "", val]; 

    Print[\*""(∫_(-∞)^∞)\!\(Sin[x]\/\(\((x - 1)\) \((x\^2\\  + \\ 4)\)\)\)\[DifferentialD]x = "", 
      Expand[FullSimplify[val]]]; 
\)\)

Which is also the correct answer.

GoTo Chapter 8