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 2   COMPLEX FUNCTIONS

\(
\(Needs["Graphics`ComplexMap`"];\)\ \)
Needs["Graphics`ImplicitPlot`"]; 
Needs["Graphics`Colors`"]; 
Needs["Algebra`InequalitySolve`"]; 
a = u = v = w = x = y = z = Z = 
                      0; 
Clear[a, ac, al, b, bc, bhc, bl, bverti, circlea, circleb, eq1, eq2, 
        eq3, eq4, eq5, eqn, eqns, f,  F, hc, hl, horiz, Iden, ineq, ineq1, 
        ineq2, ineq3, ineq4, ineq5, ineq6, ineq7, ineq8, ineq9, θ, r, 
        u, u0, u1, u2,  U, U0, v, vc, vl, verti, V, w, wplane, W, x,  X, y, 
        Y, z, Z, zplane];

Section 2.1  Functions of a Complex Variable

A complex valued function of the complex variable z is a rule that assigns to each complex number z in a set D one and only one complex number w. We write w=f(z) and call w the image of z  under f. The set D is called the domain of f, and the set of all images {w = f (z) : z ∈ D} is called the range of f. As we saw in Section 1.6, the term domain is also used to indicate a connected open set. When speaking about the domain of a function, however, mathematicians mean only the set of points on which the function is defined. This is a distinction worth noting.
	
	Just as z can be expressed by its real and imaginary parts, z=x+iy, we write f(z) =w=u+iv, where u and v are the real and imaginary parts of w, respectively. This gives us the representation  

			w = f (z) = f (x, y) = f (x + i y) = 
              u + i v.

	Since u and v depend on x and y, they can be considered to be real valued functions of the real variables x and y;  that is

			  u = u (x, y)  and  v = v (x, y).  

	Combining these ideas, we often write a complex valued function f in the form

			f (z) = f (x + i y) = 
          u (x, y) + i v (x, y).

A function  f  of the complex variable  z  is a rule that assigns to each value  z  in a set  D  one and only one complex value  w.  We write  w = f (z)  and call w  the image of  z  under  f.  The set  d  is called the domain of definition of  f,  and the set of all images  R = {w = f (z) : z ∈ D}  is called the range of  f.  Just as  z  can be expressed by its real and imaginary parts,  z = x + iy,  we write  w = u + iv,  where  u  and  v  are the real and imaginary parts of  w, respectively.  This gives us the representation  f (x + i y) = u + iv.  Since  u  and  v  depend on  x  and  y,  they can be considered to be real functions of the real variables  x  and  y;  that is,  u = u (x, y)  and  v = v (x, y).  Combining these ideas it is customary to write a complex function  f  in the rectangular coordinate form  f (z) = f (x + i y) = 
          u (x, y) + i v (x, y).  

	Conversely, if  u = u (x, y)  and  v = v (x, y)  are two given real-valued functions of the real variables  x  and  y, then f (z) = u (x, y) + i v (x, y)  can be used to define the complex function  f.  

	In a similar fashion, we define the polar coordinate form of a complex function to be  \(f \((z)\) = \(f \((r\ e\^\(i\ θ\))\) = u \((r, θ)\) + i\ v \((r, θ)\)\)\).  

	There are two methods for defining a complex function in Mathematica. Before we start, make x, y, u and v real variables.

Clear[u, v, x, y, 
        z]; 
Clear[f, F, X, Y, U, V, Z]; 
TagSet[x, Im[x], 0]; 
TagSet[y, Im[y], 0]; 
TagSet[u, Im[u[x, y]], 0]; 
TagSet[v, Im[v[x, y]], 0]; 
TagSet[x, Re[x], x]; 
TagSet[y, Re[y], y]; 
TagSet[u, Re[u[x, y]], u[x, y]]; 
TagSet[v, Re[v[x, y]], v[x, y]];

Method 1.  Make  f[x,y]  a function of two real variables (x,y).

\(
\(f[x_, y_] := u[x, y] + I\ v[x, y];\)\ \)
Print["f[x,y] = ", f[x, y]]; 
Print["f[2,1] = ", f[2, 1]]; 
Print[""]; 
Print["Re[f[x,y]] = ", ComplexExpand[Re[f[x, y]]]]; 
Print["Im[f[x,y]] = ", 
        ComplexExpand[Im[f[x, y]]]]; 
Print[""]; 
Print["Re[f[2,1]] = ", ComplexExpand[Re[f[2, 1]]]]; 
Print["Im[f[2,1]] = ", 
        ComplexExpand[Im[f[2, 1]]]];

Method 2.  Make  F[z]  a function of  z = x  +  i y.

\(
\(F[Z_] := 
        Module[{x = Re[Z], y = Im[Z]}, 
Return[
            u[x, y]\  + \ I\ v[x, y]]\ ];\)\ \)
Print["F[x + \[ImaginaryI] y] = ", 
        F[x + I y]]; 
Print[""]; 
Print["F[x + \[ImaginaryI] y] = ", 
MapAll[
          ComplexExpand, 
          F[x + I y]]]; 
Print[""]; 
Print["  F[2 + \[ImaginaryI]] = ", 
        F[2 + I]]; 
Print[""]; 
Print["Re[F[2 + \[ImaginaryI]]] = ", 
        ComplexExpand[
          Re[F[2 + I]]]]; 
Print["Im[F[2 + \[ImaginaryI]]] = ", 
        ComplexExpand[
          Im[F[2 + I]]]];

Remark.  It was necessary to use the power of  MapAll  to find the real and imaginary parts of   F[x  +  i y].

Print["Re[F[x + \[ImaginaryI] y]] = ", 
        Re[F[x + I y]]]; 
Print["Re[F[x + \[ImaginaryI] y]] = ", 
        MapAll[ComplexExpand,  
          Re[F[x + I y]]]]; 
Print[""]; 
Print["Im[F[x + \[ImaginaryI] y]] = ", 
        Im[F[x + I y]]]; 
Print["Im[F[x + \[ImaginaryI] y]] = ", 
        MapAll[ComplexExpand,  
          Im[F[x + I y]]]];

Example 2.1,  Page 49.  Write  f (z) = (z^4)  in the  f (z) = u (x, y) + i v (x, y)  form.

Solution 2.1.

Use Method 1 to construct  f[x,y].

Clear[x, y, z, Z]; 
Clear[f, F]; 
TagSet[x, Im[x], 0]; 
TagSet[y, Im[y], 0]; 
TagSet[x, Re[x], x]; 
TagSet[y, Re[y], y]; 
f[x_, y_] = (((x + I y))^4); 
Print["f[x,y] = ", f[x, y]]; 
f[x_, y_] = 
        ComplexExpand[(((x + I y))^4)]; 
Print["f[x,y] = ", f[x, y]]; 
Print[""]; 
Print["f[0,1] = ", f[0, 1]]; 
Print["f[1,1] = ", f[1, 1]]; 
\(\(Print[\*""f[1,\!\(1\/2\)] = "", 
        f[1, 1\/2]];\)\ \)

Use Method 2 to construct  F[z].

\(
\(F[z_] := 
        Module[{x = Re[z], y = Im[z], Z}, 
Z = 
            x + I\ y; \ 
Return[
            ComplexExpand[Z\^4]]\ ];\)\ \)
Z = x  +  I y; 
Print["F[", Z, "] = ", (z^4)]; 
Print["F[", Z, "] = ", F[Z]]; 
Print[""]; 
Z = I; 
Print["F[", Z, "] = ", F[Z]]; 
Z = 1  +  I; 
Print["F[", Z, "] = ", F[Z]]; 
Z = 1  +  (I/2); 
Print["F[", Z, "] = ", F[Z]];

Aside.  We can let Mathematica plot the image of a region under the mapping w = f[z].

Clear[d, f, g, Iden, z]; 
Iden[z_]  =  z; 
f[z_]  =  (z^4); 
CartesianMap[
        Iden,  {0, 1, 0.1}, {0, 1, 
          0.1}, 
PlotRange -> {{-0.1, 
              1}, {-0.1, 1}}, 
AspectRatio -> 1, 
        Ticks -> {Range[0, 1, (1/2)], Range[0, 1, (1/2)]}, 
        AxesLabel -> {"x", "y"}, 
        PlotStyle -> {Magenta, Pink}]; 
Print["A unit square in the z-plane."]; 
CartesianMap[
        f,  {0, 1, 0.1}, {0, 1, 
          0.1}, 
PlotRange -> {{-4, 1}, {-2, 
              2}}, 
AspectRatio -> (4/5), 
        Ticks -> {Range[-4, 0, 1], Range[-2, 2, 1]}, 
        AxesLabel -> {"u", "v"}, 
        PlotStyle -> {Magenta, Pink}];  
Print["The image region,"]; 
Print["under the mapping  w = ", 
        f[z]];

d[z_] = 
        z + ((1 + I)/2); 
g[z_] = f[z + ((1 + I)/2)]; 
PolarMap[
        d ,  {0, (1/2), (1/20)}, {0, 
          2  π, (π/12)}, 
PlotRange -> {{0, 
              1}, {0, 1}}, 
        AspectRatio -> 
          1, 
Ticks -> {Range[0, 1, (1/2)], 
            Range[0, 1, (1/2)]}, AxesLabel -> {"x", "y"}, 
        PlotStyle -> {DarkGreen, Green}]; 
\(\(Print[\*""The disk |z-((1 + I)/2)| < (1/2) in the z-plane.""];\)\ \)
\(\(PolarMap[
        g\ , {\ 0, 1\/2, 1\/20}, {0, 
          2  π, π\/12}, 
PlotRange -> {{\(-2.2\), 1.0}, {\(-1.6\), 1.6}}, 
        AspectRatio -> 
          1, 
Ticks -> {Range[\(-2\), 1, 1], 
            Range[\(-1\), 1, 1]}, AxesLabel -> {"u", "v"}, 
        PlotStyle -> {DarkGreen, Green}];\)\ \)
Print["The image under the mapping  w = ", 
        f[z]];

Example 2.2,  Page 50.  Write \(f \((z)\) = \(\(z\)\(\ \)\)\&_\ Re[z] + z\^2 + Im[z]\) in the   f (z) = u (x, y) + i v (x, y)  form.

Solution 2.2.

Use Method 1 to construct  f[x,y].

Clear[x, y, z, Z]; 
Clear[f, F]; 
TagSet[x, Im[x], 0]; 
TagSet[y, Im[y], 0]; 
TagSet[x, Re[x], x]; 
TagSet[y, Re[y], y]; 
Z = x + I y; 
f[x_, y_] = 
ComplexExpand[
          Conjugate[Z] Re[Z] + (Z^2) + Im[Z]]; 
Print["f[x,y] = ", 
        Conjugate[Z] Re[Z] + (Z^2) + Im[Z]]; 
Print["f[x,y] = ", f[x, y]]; 
Print[""]; 
Print["f[3,2] = ", f[3, 2]];

Use Method 2 to construct  F[z].

\(
\(F[Z_] := 
        Module[{x = Re[Z], y = Im[Z], z}, 
z = 
            x + I\ y; \ 
Return[
            ComplexExpand[Conjugate[z] Re[z] + z\^2 + Im[z]]]];\)\ \)
Z = x  +  I y; 
Print["f[x,y] = ", 
        Conjugate[Z] Re[Z] + (Z^2) + Im[Z]]; 
Print["F[", Z, "] = ", F[Z]]; 
Print[""]; 
Z = 3  +  2 I; 
Print["F[", Z, "] = ", F[Z]];

Aside.  We can let Mathematica plot the image of a region under the mapping w = f[z].

\(
\(Clear[f, z];\)\ \)
Iden[z_] = z; 
f[z_] = 
        Conjugate[z] Re[z] + (z^2) + Im[z]; 
CartesianMap[
        Iden,  {0, 1, 0.1}, {0, 1, 
          0.1}, 
PlotRange -> {{-0.1, 
              1}, {-0.1, 1}}, 
AspectRatio -> 1, 
        Ticks -> {Range[0, 1, (1/2)], Range[0, 1, (1/2)]}, 
        AxesLabel -> {"x", "y"}, 
        PlotStyle -> {Blue, Cyan}]; 
Print["A unit square in the z-plane."]; 
CartesianMap[
        f, {0, 1, 0.1}, {0, 1, 
          0.1}, 
PlotRange -> {{0, 2.3}, {0, 
              1.15}}, 
AspectRatio -> (1/2), 
        Ticks -> {Range[0, 2, (1/2)], Range[0, 1, (1/2)]}, 
        AxesLabel -> {"u", "v"}, 
        PlotStyle -> {Blue, Cyan}]; 
Print["The image region under the"]; 
Print["mapping  w = ", f[z]]; 
Print["         w = ", 
        MapAll[ComplexExpand, 
          f[x + I y]]];

Examples 2.1 and 2.2  show how to find u(x,y) and v(x,y) when a rule for computing f is given. Conversely, if u(x,y) and v(x,y) are two real-valued functions of the real variables x and y, they determine a complex valued function f=u+iv, and we can use the formulas  

			\(x = \(z\  + \ \(\(z\)\(\ \)\)\&_\)\/2\) and \(y = \(z\  - \ \(\(z\)\(\ \)\)\&_\)\/\(2  i\)\)

to find a formula for f involving the variables z and \(\(\(z\)\(\ \)\)\&_\).

Example 2.3,  Page 50.  Express f (z)  =  4  (x^2)  +  4  (y^2)  with a formula involving  \(z\ \ \ and\ \ \ \(\(z\)\(\ \)\)\&_\).

Solution 2.3.

Enter the function.

Clear[w, x, y, z, 
        Z]; 
Clear[f]; 
TagSet[x, Im[x], 0]; 
TagSet[y, Im[y], 0]; 
TagSet[x, Re[x], x]; 
TagSet[y, Re[y], y]; 
w  =  4  (x^2)  +  4  (y^2); 
f[x_]  =  
        ReplaceAll[
          w , 
{x -> ((z  +  Conjugate[z])/2), 
            y -> ((z  -  Conjugate[z])/(2  I))}]; 
Print["    f[z] = ", w]; 
Print["    f[z] = ", f[z]]; 
Print["    f[z] = ", 
        Expand[f[z]]]; 
Print[""]; 
Z = x + I y; 
Print["f[", Z, "] = ", f[Z]]; 
Print["f[", Z, "] = ", 
        ComplexExpand[f[Z]]];

Since f[z] is real valued, a graph would not be very interesting.

Example 2.4  Page 51.  Express  f (z) = (z^2)  in both Cartesian and polar coordinate form.

Solution 2.4.

Enter the function.

Clear[z]; 
Clear[f, F, r, θ]; 
f[z_] = (z^2); 
F[r_, θ_]  =  
        ReplaceAll[
          f[z] , 
{(z^2) -> 
              (r^2) Cos[2  θ] + I (r^2) Sin[
                    2  θ], 
(z^5) -> 
              (r^5) Cos[5  θ] + I (r^5) Sin[
                    5  θ]}]; 
Print["      f[z] = ", f[z]]; 
\(\(Print[\*""f[1+I \!\(\@3\)] = "", 
        f[1 + I\ \@3]];\)\ \)
Print[""]; 
Print["      f[z] = ", 
        ComplexExpand[Re[f[x + I y]]], " + \[ImaginaryI](", 
        ComplexExpand[
          Im[f[x + I y]]], ")"]; 
\(\(Print[\*""f[1+I \!\(\@3\)] = "", 
        ComplexExpand[
          f[1 + I\ \@3]]];\)\ \)
Print[""]; 
\(\(Print[\*""  f[r (E^I)θ] = "", f[r\ E\^\(I\ θ\)]];\)\ \)
\(\(Print[\*"" f[2 (E^(Iπ/3))] = "", f[2\ E\^\(I\ π/3\)]];\)\ \)
\(\(Print[\*"" f[2 (E^(Iπ/3))] = "", ComplexExpand[
          f[2\ E\^\(I\ π/3\)]]];\)\ \)
Print[" "]; 
Print["  F[r,θ] = ", 
        F[r, θ]]; 
\(\(Print[\*"" F[2,\!\(π\/3\)] = "", 
        ComplexExpand[F[2, π\/3]]];\)\ \)

Remark 2.1. For a given function f, the functions u and v defined here are different from those defined by equation (2-1), because equation (2-1) involves Cartesian coordinates and equation (2-2) involves polar coordinates.

Example 2.5,  Page 51.  Express  f (z) = (z^5) + 4 (z^2) - 6  in polar coordinate form.

Solution 2.5.

Enter the function.

Clear[z]; 
Clear[f, F, r, θ]; 
f[z_] = (z^5) + 4 (z^2) - 6; 
F[r_, θ_]  =  
        ReplaceAll[
          f[z] , 
{(z^2) -> 
              (r^2) Cos[2  θ] + I (r^2) Sin[
                    2  θ], 
(z^5) -> 
              (r^5) Cos[5  θ] + I (r^5) Sin[
                    5  θ]}]; 
Print["      f[z] = ", f[z]]; 
\(\(Print[\*""f[1+I \!\(\@3\)] = "", 
        f[1 + I\ \@3]];\)\ \)
\(\(Print[\*""f[1+I \!\(\@3\)] = "", 
        ComplexExpand[
          f[1 + I\ \@3]]];\)\ \)
Print[""]; 
\(\(Print[\*""  f[r (E^I)θ] = "", f[r\ E\^\(I\ θ\)]];\)\ \)
\(\(Print[\*"" f[2 (E^(Iπ/3))] = "", f[2\ E\^\(I\ π/3\)]];\)\ \)
\(\(Print[\*"" f[2 (E^(Iπ/3))] = "", ComplexExpand[
          f[2\ E\^\(I\ π/3\)]]];\)\ \)
Print[" "]; 
Print["  F[r,θ] = ", 
        F[r, θ]]; 
\(\(Print[\*"" F[2,\!\(π\/3\)] = "", 
        ComplexExpand[F[2, π\/3]]];\)\ \)

Aside.  We can let Mathematica plot the image of a region under the mapping w = f[z].

Clear[f, Iden, z]; 
Iden[z_]  =  z; 
f[z_]  =  (z^5) + 4 (z^2) - 6; 
CartesianMap[
        Iden,  {0, 1, 0.1}, {0, 1, 
          0.1}, 
PlotRange -> {{-0.1, 
              1}, {-0.1, 1}}, 
AspectRatio -> 1, 
        Ticks -> {Range[0, 1, (1/2)], Range[0, 1, (1/2)]}, 
        AxesLabel -> {"x", "y"}, 
        PlotStyle -> {Magenta, Pink}]; 
Print["A unit square in the z-plane."]; 
CartesianMap[
        f,  {0, 1, 0.1}, {0, 1, 
          0.1}, 
PlotRange -> {{-10, 0}, {0, 
              6}}, 
AspectRatio -> (6/10), 
        Ticks -> {Range[-10, 0, 1], Range[0, 6, 1]}, 
        AxesLabel -> {"u", "v"}, 
        PlotStyle -> {Magenta, Pink}];  
Print["The image region under the"]; 
Print["mapping  w = ", f[z]];

\(
\(PolarMap[
        Iden\ , \ {0, 1, 
          1\/20}, {0, π\/2, π\/24}, 
PlotRange -> {{0, 1}, {0, 1}}, 
        AspectRatio -> 
          1, 
Ticks -> {Range[0, 1, 1\/2], 
            Range[0, 1, 1\/2]}, AxesLabel -> {"x", "y"}, 
        PlotStyle -> {DarkGreen, Green}];\)\ \)
Print["A quarter disk in the z-plane."]; 
\(\(PolarMap[
        f\ , {0, 1, 
          1\/20}, {0, π\/2, π\/24}, 
PlotRange -> {{\(-10\), 0}, {0, 4}}, 
        AspectRatio -> 
          4\/10, 
Ticks -> {Range[\(-10\), 0, 1], 
            Range[0, 4, 1]}, AxesLabel -> {"u", "v"}, 
        PlotStyle -> {DarkGreen, Green}];\)\ \)
Print["The image region under the"]; 
Print["mapping  w = ", f[z]];

Section 2.1  Exercises for Functions of a Complex Variable
See textbook page 51.

Section 2.2	Transformations and Linear Mappings

Section 2.3	The Mappings w = z^n and w = z^1/n

Section 2.4	Limits and Continuity

Section 2.5	Branches of Functions

Section 2.6	The Reciprocal Transformation w  = 1/z

GO TO  THE  Table of Contents