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

Amazingly, we can evaluate certain definite real integrals with the aid of the residue theorem. We do this by interpreting the definite integral as the parametric form of an integral of an analytic function along a simple closed contour.

Suppose we wish to evaluate an integral of the form  

			(∫_0^(2  π)) 
        F (cos θ, sin θ) dθ,    

where  F(u,v)  is a function of the two real variables  u  and  v.  

Consider the unit circle (Subscript[C, 0]) (0) = {z : |z| = 1} with parametrization

			\(\(C\_0\%+\) \((0)\) : \ z = 
        cos \((θ)\) + i\ sin \((θ)\)\),  for 0 ≤ θ ≤ 2  π;   

which gives us the following symbolic differentials.

			\(dz = \((\(-sin\) \((θ)\) + i\ cos \((θ)\))\) dθ\),  
		and  
			\(dθ\  = dz\/\(i\ z\)\).  

Combining   z = cos θ + i sin θ with (1/z) = cos θ - i sin θ, we can obtain

		cos θ = ((z + (1/z))/2),   sin θ = ((z - (1/z))/(2  i)).

Using the substitutions for cos θ, sin θ, and dθ in 3xpression (8-3) transforms the definite integral into a contour integral

		\(∫\_0\%\(2  π\)\ 
          F \((cos\ θ, 
              sin\ θ)\) dθ\  = \ ∮\_\(\(\ \)\(\(C\_0\%+\) \((0)\)\)\)\ 
          f \((z)\)\ \(\(dz\)\(\ \)\)\),

where the new integrand is  \(f \((z)\) = \(F \((\(1\/2\) \((z + 1\/z)\), \(1\/\(2  i\)\) \((z - 1\/z)\))\)\)\/\(i\ z\)\).

	Suppose that  f  is analytic inside and on the unit circle (Subscript[C, 0]) (0), except at the points  (Subscript[z, 1]), (Subscript[z, 2]),   ... , (Subscript[z, n])  that lie interior to  (Subscript[C, 0]) (0). Then the residue theorem gives

		(∫_0^(2  π)) 
          F (cos θ, 
              sin θ) dθ   =  
        2  π i (∑_(k = 1)^n) Res[f, (Subscript[z, k])].

Some of these problems can be 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.10,  Page 318.    Use substitution and an equivalent contour integral to evaluate  (∫_0^(2  π))(( 1)/(1  +  
                3 Cos[θ]^2)) dθ.

Solution 8.10.

Enter the function  F[θ] = (( 1)/(1  +  3 Cos[θ]^2)) and use substitution to obtain the complex function f[z].

Remove[Z]; 
Clear[f, G, F, Res1, Res2, Res3, Res4, solset, θ, val, 
        z]; 
F[θ_]  = (( 1)/(1  +  3 Cos[θ]^2)); 
f[z_]  =  sub[F[θ], θ]; 
Print["F[θ] = ", F[θ]]; 
Print["f[z] = ", f[z]];

Locate the singularities of  \(f[
          z] = \(\(-\ 4\)\ i\ z\)\/\(3\ z\^4\  + \ 10\ z\^2\  + \ 3\)\).

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

Find out which singularities lie inside the unit circle  C : |z| = 1.

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}]}];\)\ \)
contour  =  Graphics[{Magenta, Circle[{0, 0}, 1]}]; 
Show[dots, centers, contour, 
        PlotRange -> {{-2.1, 2.1}, {-2.1, 2.1}}, 
        Ticks -> {Range[-2, 2, 1], 
            Range[-2, 2, 1]}, 
AspectRatio -> 1, 
        Axes -> True, 
        AxesLabel -> {"x", "y"}]; 
\(\(Print[\*""\!\(z\_1\) = "", Z\_1, ",  Is |", 
        Z\_1, "| < 1 ?  ", N[Abs[Z\_1]] < 1];\)\ \)
\(\(Print[\*""\!\(z\_2\) = "", Z\_2, ",   Is |", 
        Z\_2, "| < 1 ?   ", N[Abs[Z\_2]] < 1];\)\ \)
\(\(Print[\*""\!\(z\_3\) = "", Z\_3, ", Is |", 
        Z\_3, "| < 1 ?  ", N[Abs[Z\_3]] < 1];\)\ \)
\(\(Print[\*""\!\(z\_4\) = "", Z\_4, ",  Is |", 
        Z\_4, "| < 1 ?   ", 
        N[Abs[Z\_4]] < 1];\)\ \)

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

Res1  =  Residue[f[z], {z, (Subscript[Z, 1])}]; 
Res2  =  Residue[f[z], {z, (Subscript[Z, 2])}]; 
val  = 
        2 π I (Res1  +  
              Res2); 
Print["Res[f,", (Subscript[Z, 1]), "] = ", Res1]; 
Print["Res[f,", (Subscript[Z, 2]), "] = ", 
        Res2]; 
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}]}];\)\ \)
contour  =  Graphics[{Magenta, Circle[{0, 0}, 1]}]; 
Show[dots, centers, contour, 
        PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}, 
        Ticks -> {Range[-1, 1, 1], 
            Range[-1, 1, 1]}, 
AspectRatio -> 1, 
        Axes -> True, 
        AxesLabel -> {"x", "y"}]; 
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = 2πI((", 
        Res1\ , ") + (", \ 
        Res2\ , "))"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = 2πI(", 
        Res1\  + \ Res2\ , ")"];\)\ \)
Print[""]; 
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = ", 
        val];\)\ \)
Print["The contour is the circle  C:|z| = 1,"]; 
Print["taken with the positive orientation."]; 
Print[""]; 
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = ", 
        val];\)\ \)

Example 8.11,  Page 319.    Use Mathematica to evaluate  (∫_0^(2  π))(( 1)/(1  +  
                3 Cos[θ]^2)) dθ.

Solution 8.11.

Enter the function  F[θ] = (( 1)/(1  +  3 Cos[θ]^2)) and use substitution to obtain the complex function f[z].

Remove[Z]; 
Clear[f, G, F, Res1, Res2, Res3, Res4, solset, θ, val, 
        z]; 
F[θ_]  = (( 1)/(1  +  3 Cos[θ]^2)); 
f[z_]  =  sub[F[θ], θ]; 
Print["F[θ] = ", F[θ]]; 
Print["f[z] = ", f[z]];

Mathematica  is capable of finding some of these difficult integrals.  The function  F[θ] = (( 1)/(1  +  3 Cos[θ]^2))  can be integrated.

G[θ_]  =  ∫F[θ] \[DifferentialD]θ; 
val  =  (∫_0^(2  π))F[θ] \[DifferentialD]θ; 
Print["G[θ] = ∫ ", 
        F[θ], " \[DifferentialD]θ = ", 
        G[θ]]; 
Print[""]; 
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = ", 
        val];\)\ \)
Print[""]; 
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = ", 
        ComplexExpand[val]];\)\ \)

However, direct substitution using  G[θ]  and the endpoints of the interval seems to be erroneous.

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),  cot (π),  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.

gr1 = 
        Plot[G[θ], {θ, 0, π}, PlotStyle -> Magenta, 
          DisplayFunction -> Identity]; 
gr2 = 
        Plot[G[θ], {θ, π, 2  π}, 
          PlotStyle -> Magenta, 
          DisplayFunction -> Identity]; 
\(\(Show[gr1, gr2, 
        PlotRange -> {{0, 2  π}, {\(-1\), 
              1}}, 
Ticks -> {Range[0, 
              2  π, π\/2], 
            Range[\(-π\)\/4, π\/4, π\/2]}, 
AxesLabel -> {"θ", "s"}, 
        DisplayFunction -> $DisplayFunction];\)\ \)
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.

lim1 = 
        Limit[G[θ], θ -> π,    Direction -> 
            1]; 
lim2 = 
        Limit[G[θ], θ -> 
            0,     Direction -> -1]; 
lim3 = 
        Limit[G[θ], θ -> 2  π, 
          Direction -> 1]; 
lim4 = 
        Limit[G[θ], θ -> π,    Direction -> -1]; 
val  =  (lim1  - lim2)  +  (lim3  -  
              lim4); 
\(\(Print[\*"" \!\(lim\+\(θ -> \(π\^-\)\)\) ("", 
        G[θ], ") = ", lim1];\)\ \)
\(\(Print[\*"" \!\(lim\+\(θ -> \(π\^+\)\)\) ("", 
        G[θ], ") = ", lim2];\)\ \)
\(\(Print[\*""\!\(lim\+\(θ -> 2 \( π\^-\)\)\) ("", 
        G[θ], ") = ", lim3];\)\ \)
\(\(Print[\*""\!\(lim\+\(θ -> 2 \( π\^+\)\)\) ("", 
        G[θ], ") = ", lim4];\)\ \)
Print[""]; 
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = (", lim1\ , " - (", 
        lim2, ")) + (", lim3\ , " - (", 
        lim4, "))"];\)\ \)
Print[""]; 
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = ", \((lim1\  - 
            lim2)\), " + ", \((lim3\  - \ lim4)\), " = ", 
        val];\)\ \)

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

Example 8.12,  Page 320.    Use substitution and an equivalent contour integral to show that  \(∫\_0\%\(2  π\)\(\(\(\ \)\(cos \((2  θ)\)\)\)\/\(5\  - \ 
                  4\ cos \((θ)\)\)\) dθ\  = \ π\/6\).

Solution 8.12.

Enter the function  \(F[θ] = \(\(\ \)\(Cos[2  θ]\)\)\/\(5\  - \ 4\ Cos[θ]\)\) and use substitution to obtain the complex function f[z].

Remove[Z]; 
Clear[f, G, F, Res1, Res2, Res3, Res4, solset, θ, val, 
        z]; 
F[θ_]  = (( Cos[2  θ])/(5  -  4 Cos[θ])); 
f[z_]  =  sub[F[θ], θ]; 
Print["F[θ] = ", F[θ]]; 
Print["f[z] = ", f[z]];

Locate the singularities of  \(f[
          z] = \(i\ \((1\  + \ z\^4)\)\)\/\(2\ z\^2\ \((2\  - \ 5\ z\  + \ 2\ z\^2)\)\)\).

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

Find out which singularities lie inside the unit circle  C : |z| = 1.

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] - 0.05, 
                Im[Z\_1] + 0.2}, {1, 0}], 
            Text[\*""\!\(z\_2\)"", {Re[Z\_2], Im[Z\_2] + 0.2}, {\(-1\), 
                0}], Text[\*""\!\(z\_3\)"", {Re[Z\_3], 
                Im[Z\_3] + 0.2}, {\(-1\), 0}], 
            Text[\*""\!\(z\_4\)"", {Re[Z\_4], Im[Z\_4] + 0.2}, {\(-1\), 
                0}]}];\)\ \)
contour  =  Graphics[{Magenta, Circle[{0, 0}, 1]}]; 
Show[dots, centers, contour, 
        PlotRange -> {{-3.1, 3.1}, {-3.1, 3.1}}, 
        Ticks -> {Range[-3, 3, 1], 
            Range[-3, 3, 1]}, 
AspectRatio -> 1, 
        Axes -> True, 
        AxesLabel -> {"x", "y"}]; 
\(\(Print[\*""\!\(z\_1\) = "", Z\_1, ",   Is |", 
        Z\_1, "| < 1 ?   ", N[Abs[Z\_1]] < 1];\)\ \)
\(\(Print[\*""\!\(z\_2\) = "", Z\_2, ",   Is |", 
        Z\_2, "| < 1 ?   ", N[Abs[Z\_2]] < 1];\)\ \)
\(\(Print[\*""\!\(z\_3\) = "", Z\_3, ",  Is |", 
        Z\_3, "| < 1 ?  ", N[Abs[Z\_3]] < 1];\)\ \)
\(\(Print[\*""\!\(z\_4\) = "", Z\_4, ",   Is |", 
        Z\_4, "| < 1 ?   ", 
        N[Abs[Z\_4]] < 1];\)\ \)

Compute the residues at  (Subscript[z, 1]) = 1,  and  (Subscript[z, 3]) = (1/2), 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 (Res1  +  
              Res3); 
Print["Res[f,", (Subscript[Z, 1]), "] = ", Res1]; 
Print["Res[f,", (Subscript[Z, 3]), "] = ", 
        Res3]; 
dots = 
        Graphics[{{Red, 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.15}, {\(-1\), 0}], 
            Text[\*""\!\(z\_3\)"", {Re[Z\_3], 
                Im[Z\_3] - 0.15}, {\(-1\), 
                0}]}];\)\ \)
contour  =  Graphics[{Magenta, Circle[{0, 0}, 1]}]; 
Show[dots, centers, contour, 
        PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}, 
        Ticks -> {Range[-1, 1, 1], 
            Range[-1, 1, 1]}, 
AspectRatio -> 1, 
        Axes -> True, 
        AxesLabel -> {"x", "y"}]; 
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = 2πI((", 
        Res1\ , ") + (", \ 
        Res3\ , "))"];\)\ \)
\(\(Print[\*""\!\(∮\+C\) ("", 
        f[z], ") \[DifferentialD]z = 2πI(", 
        Res1\  + \ Res3\ , ") = ", val];\)\ \)
Print["The contour is the circle  C:|z| = 1,"]; 
Print["taken with the positive orientation."]; 
Print[""]; 
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = ", 
        val];\)\ \ \)

Mathematica  is capable of finding some of these difficult integrals.  The function  \(F[θ] = \(\(\ \)\(Cos[2  θ]\)\)\/\(5\  - \ 4\ Cos[θ]\)\)  can be integrated.

G[θ_]  =  ∫F[θ] \[DifferentialD]θ; 
val  =  (∫_0^(2  π))F[θ] \[DifferentialD]θ; 
Print["G[θ] = ∫ ", 
        F[θ], " \[DifferentialD]θ = ", 
        G[θ]]; 
Print[""]; 
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = ", 
        val];\)\ \)

However, direct substitution using G (θ) and the endpoints of the interval seems to be erroneous.  This is due to the fact that in the interior of the interval, tan ((π/2)) is undefined. Hence G (θ)is discontinuous.

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  tan ((π/2)) is 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.

gr1 = 
        Plot[G[θ], {θ, 0, π}, PlotStyle -> Magenta, 
          DisplayFunction -> Identity]; 
gr2 = 
        Plot[G[θ], {θ, π, 2  π}, 
          PlotStyle -> Magenta, 
          DisplayFunction -> Identity]; 
\(\(Show[gr1, gr2, 
        PlotRange -> {{0, 2  π}, {\(-4.5\), 
              0.5}}, 
Ticks -> {Range[0, 
              2  π, π\/2], 
            Range[\(\(-4\) π\)\/3, π\/3, π\/3]}, 
AxesLabel -> {"θ", "s"}, 
        DisplayFunction -> $DisplayFunction];\)\ \)
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.

lim1 = 
        Limit[G[θ], θ -> π,    Direction -> 
            1]; 
val2 = G[0]; 
val3 = G[2  π]; 
lim4 = 
        Limit[G[θ], θ -> π,    Direction -> -1]; 
val  =  (lim1  - val2)  +  (val3  -  
              lim4); 
\(\(Print[\*"" \!\(lim\+\(θ -> \(π\^-\)\)\) ("", 
        G[θ], ") = ", lim1];\)\ \)
Print["G[0] = ", val2]; 
Print["G[2π] = ", val3]; 
\(\(Print[\*"" \!\(lim\+\(θ -> \(π\^+\)\)\) ("", 
        G[θ], ") = ", lim4];\)\ \)
Print[""]; 
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = (", lim1\ , " - (", 
        val2, ")) + (", val3\ , " - (", 
        lim4, "))"];\)\ \)
\(\(Print["∫ "\+0\%\(2  π\), 
        F[θ], " \[DifferentialD]θ = ", \((lim1\  - 
            val2)\), " + ", \((val3\  - \ lim4)\), " = ", 
        val];\)\ \)

The above answer is correct too.  Limits were required because  G[θ]  is not continuous at  θ = π .

Section 8.3  Exercises for Trigonometric Integrals
See textbook page 321.

Section 8.4	Improper Integrals of Rational Functions

Section 8.5	Improper Integrals Involving Trigonometric Functions

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