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 10  APPLICATIONS of HARMONIC FUNCTIONS

a = A = b = B = c = k = R = T = u = U = v = V = w = W = x = X = y = Y = z = Z = 
                                        0; 
Clear[a, a0, a1, a2, a3, A, b, B, 
        CR, Δx, Δy, eq1, eq2, eqns, f, f1, F, F1, 
        F2, F3, F4, g, G, lines, n, P, Ψ, ϕ, Φ, 
        r, r0, solset, θ, t, T, T1, T2, Q, u, u0, U, U1, v, v0, V, V1, 
        w, w0, W, W1, x, x1, x2, x3, y, z, z1, z2, z3, 
        z4]; 
Needs["Graphics`ComplexMap`"]; 
Needs["Graphics`ParametricPlot3D`"]
Needs["Graphics`Colors`"];

Section 10.1	Preliminaries

Section 10.2  Invariance of Laplace's Equation and the Dirichlet Problem

Let  D  be a domain whose boundary is made up of piecewise smooth contours joined end to end.  The Dirichlet problem is to find a function  ϕ  that is harmonic in  D  such that  ϕ  takes on prescribed values at points on the boundary.  Let us first study the problem in the upper half plane.

Theorem 10.1 (Invariance of Laplace's Equation), Page 389. Let Φ (u, v) be harmonic in a domain G in the w plane. Then Φ (u, v) satisfies Laplace's equation  

			(Subscript[Φ, xx]) (u, v) + (Subscript[Φ, vv]) (u, v) = 
        0,   

at each point  w = u + i v  in  G.   If  w = f (z) = u (x, y) + i v (x, y)  is a conformal mapping from a domain  D  in the z plane onto  G, then the composition  

			ϕ (x, y) = Φ (u (x, y), 
            v (x, y)),  

is harmonic in  D, and  ϕ (x, y)  satisfies Laplace's equation  

			(Subscript[ϕ, xx]) (u, y) + (Subscript[ϕ, yy]) (x, y) = 0,  

at each point  z = x + i y  in  D.

Proof of Theorem 10.1, see text Page 389.

Example 10.4,  Page 390.  Show that  ϕ (x, y) = 
        arctan (((2  x)/((x^2)  +  (y^2)  -  1)))  is harmonic in the disk  |z|<1.

Solution 10.4.

Enter the function   ϕ (x, y) = 
        arctan (((2  x)/((x^2)  +  (y^2)  -  1))).

Remove[x, y]; 
Clear[ϕ]; 
ϕ[x_, y_]  =  
        ArcTan[((2  x)/((x^2)  +  (y^2)  -  1))]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]];

Verify that Laplace's equation holds.

ϕxx  =  
        Together[(∂_(x, x))ϕ[x, y]]; 
ϕyy  =  
        Together[(∂_(y, y))ϕ[x, 
              y]]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]]; 
Print[""]; 
\(\(Print[\*""\!\(ϕ\_xx\)(x,y) = "", \ ϕxx];\)\ \)
\(\(Print[\*""\!\(ϕ\_yy\)(x,y) = "", \ ϕyy];\)\ \)
Print[""]; 
\(\(Print[\*""(Subscript[ϕ, xx])(x,y) + (Subscript[ϕ, yy])(x,y) = "", ϕxx\  + \ ϕyy];\)\ \)

Therefore,  ϕ[x, y]  =  ArcTan[((2  x)/((x^2)  +  (y^2)  -  1))]  is a harmonic function.

Show that  ϕ (x, y)  is the imaginary part of a certain analytic function.

Clear[f, g, u, U, U1, v, V, V1, x, y, z, w, W, 
        W1]; 
TagSet[x, Im[x], 0]; 
TagSet[y, Im[y], 0]; 
g[
          z_]  =  ((I  +  z)/(I  -  z)); 
\(\(U\  = \ 
        Together[
          ComplexExpand[
            Re[g[x + I\ y]], 
\ \ TargetFunctions -> {Re, 
                Im}]];\)\ \)
\(\(V\  = \ 
        Together[
          ComplexExpand[
            Im[g[x + I\ y]], 
\ \ TargetFunctions -> {Re, 
                Im}]]\ ;\)\ \)
W1  =  Log[U  +  I V]; 
W2  =  
        ComplexExpand[W1, TargetFunctions -> {Re, Im}]; 
W3  =  Expand[MapAll[Together, W2]]; 
U1  =  
        MapAll[Together, 
          ComplexExpand[Re[W1], 
            TargetFunctions -> {Re, Im}]]; 
V1  =  
        ComplexExpand[Im[W1], 
          TargetFunctions -> {Re, Im}]; 
Q  =  
        ArcTan[Simplify[
            ((Subscript[V1, [[2]]])/(Subscript[V1, [[1]]]))]]; 
Print["   g[z] = ", g[z]]; 
Print["g[x+\[ImaginaryI]y] = ", 
        g[x + I y]]; 
\(\(Print["g[x+Iy] = ", 
        ComplexExpand[
          g[x + I\ y], 
\ \ TargetFunctions -> {Re, 
              Im}]];\)\ \)
Print["g[x+\[ImaginaryI]y] = ", 
        U  +  I V]; 
Print["  "]; 
Print["Log[g[x+\[ImaginaryI]y]] = ", W1]; 
Print["Log[g[x+\[ImaginaryI]y]] = ", W3]; 
Print["  "]; 
Print["Re[Log[g[x+\[ImaginaryI]y]]] = ", U1]; 
Print["Im[Log[g[x+\[ImaginaryI]y]]] = ", 
        V1]; 
Print["Im[Log[g[x+\[ImaginaryI]y]]] = ", Q]; 
Print["Im[Log[", g[x + Iy], "]] = ", 
        Q]; 
Print[""]; 
Print["Im[Log[", g[z], "]] = ", 
        Q];

Since  \(ϕ[x, y]\  = \ \(ArcTan[\(2  x\)\/\(x\^2\  + \ y\^2\  - \ 1\)] = 
          Im[Log[\(i\  + \ z\)\/\(i\  - \ z\)]]\)\)  is the imaginary part of an analytic function, hence it is a harmonic function.

We can use Mathematica to make a contour plot of the function.  But for computational purposes we use the identity  ArcTan[((2  x)/((x^2)  +  (y^2)  -  1))] = -π + 
          ArcTan[-1 + (x^2) + (y^2), 2  x] which is valid in the right half-plane.  In the left half plane we would need to use  ArcTan[((2  x)/((x^2)  +  (y^2)  -  1))] = π + 
          ArcTan[-1 + (x^2) + (y^2), 2  x].  The singularity along x=0 makes it difficult to plot the function on a domain containing the y-axis.

cont = 
        Table[((-π k)/10), {k, 0, 
            5}]; 
ϕ[x_, y_] = -π + 
          ArcTan[-1 + (x^2) + (y^2), 2  x]; 
Φ[x_, y_] =  π + 
          ArcTan[-1 + (x^2) + (y^2), 2  x]; 
gr1 = 
        ContourPlot[ϕ[x, y], {x, 0.002, 1}, {y, -1, 
            1}, 
Contours -> cont, 
          PlotPoints -> 35, 
          AspectRatio -> 1, 
ColorFunction -> 
            Hue, DisplayFunction -> 
            Identity]; 
gr2 = 
        ContourPlot[-Φ[x, 
              y], {x, -1, -0.002}, {y, -1, 
            1}, 
Contours -> cont, 
          PlotPoints -> 35, 
          AspectRatio -> 1, 
ColorFunction -> 
            Hue, DisplayFunction -> 
            Identity]; 
Show[gr1, gr2, 
        DisplayFunction -> $DisplayFunction]; 
Print["Contour plot for"]; 
\(\(Print[\*""ϕ[x,y] = ArcTan[\!\(\(2  x\)\/\(x\^2\\  + \\ y\^2\\  - \\ 1\)\)]""];\)\ \)

Then use Mathematica to make a 3D plot of the solution.

\(
\(g1 = 
        Plot3D[ϕ[x, y], {x, 0.001, 1}, {y, \(-1\), 1}, 
          PlotPoints -> {21, 
              21}, 
AxesLabel -> {"x", "y", "ϕ[x,y]  "}, ColorFunction -> Hue, 
          DisplayFunction -> Identity];\)\ \)
\(\(g2 = 
        Plot3D[\(-Φ[x, y]\), {x, \(-1\), \(-0.001\)}, {y, \(-1\), 
            1}, PlotPoints -> {21, 
              21}, 
AxesLabel -> {"x", "y", "ϕ[x,y]  "}, ColorFunction -> Hue, 
          DisplayFunction -> Identity];\)\ \)
Show[g1, g2, 
        PlotRange -> {{-1, 1}, {-1, 1}, {((-π)/2), 0}}, 
        DisplayFunction -> $DisplayFunction]; 
\(\(Print[\*""ϕ[x,y] = ArcTan[\!\(\(2  x\)\/\(x\^2\\  + \\ y\^2\\  - \\ 1\)\)]""];\)\ \)

Let D be a domain whose boundary is made up of piecewise smooth contours joined end to end. Dirichlet problem is to find a function Φ that is harmonic in D such that Φ takes on prescribed values at points on the boundary. Let us first study this problem in the upper half-plane.

Example 10.5,  Page 391.  Show that the function  

		Φ (u, v) = (1/π) ArcTan[(v/(u  -  (Subscript[u, 0])))] = 
          (1/π) Arg[w  -  (Subscript[u, 0])]  

is harmonic in the upper half plane  Im[w] > 0  and has boundary values  

		Φ (u, 0) = 
        0   for   u > 
          (Subscript[u, 0]), 
Φ (u, 0) = 
        1   for   u < (Subscript[u, 0]).

Solution 10.5.

Remove[u, U, v, V, 
        w]; 
Clear[g, G, P, Ψ, Φ, Q, u0, 
        w0]; 
g[w_, u0_]   =  (1/π) Log[w  -  u0]; 
G[w_, u0_]  =  ComplexExpand[g[w, u0]]; 
P[w_, u0_]  =  ComplexExpand[Re[g[w, u0]]]; 
Q[w_, u0_]  =  ComplexExpand[Im[g[w, u0]]]; 
Ψ[u_, v_, u0_]  =  
        ReplaceAll[P[w, u0], w -> u + I v]; 
Φ[u_, v_, u0_]  =  
        ReplaceAll[Q[w, u0], w -> u + I v]; 
\(\(Print[\*""  g[w,\!\(u\_0\)] = "", g[w, u0]];\)\ \)
\(\(Print[\*""  g[w,\!\(u\_0\)] = "", G[w, u0]];\)\ \)
\(\(Print[\*""Ψ[u,v,\!\(u\_0\)] = "", 
        P[w, u0], " = ", Ψ[u, v, u0]];\)\ \)
\(\(Print[\*""Φ[u,v,\!\(u\_0\)] = "", 
        P[w, u0], " = ", Φ[u, v, 
          u0]];\)\ \)

For illustration, set  (Subscript[u, 0]) = 1.

u0 = 1; 
u = 2;  
\(\(Print["u = ", u, \*""    \!\(u\_0\) = "", 
        u0];\)\ \)
\(\(Print[u, \*"" > \!\(u\_0\) is "", 
        u > u0, ",  Φ[", 
        u, \*"",0,\!\(u\_0\)] = "", Φ[u, 0, 
          u0]];\)\ \)
u = 0;  
Print[""]; 
\(\(Print["u = ", u, \*""    \!\(u\_0\) = "", 
        u0];\)\ \)
\(\(Print[u, \*"" < \!\(u\_0\) is "", 
        u < u0, ",  Φ[", 
        u, \*"",0,\!\(u\_0\)] = "", Φ[u, 0, 
          u0]];\)\ \)

First use Mathematica to make a contour plot of the solution.

cont = 
        Table[k, {k, 0, 1, (1/8)}]; 
ContourPlot[
        Evaluate[Φ[u, v, 1]], {u, -1, 3}, {v, 0.00001, 
          2}, 
Contours -> cont, 
        PlotPoints -> 35, 
        AspectRatio -> (1/2), 
ColorFunction -> 
          Hue]; 
Print["Contour plot for"]; 
Print["Φ[u,v] = ", Φ[u, v, 
          1]]; 
Print[""]; 
Print[Φ[u, v, 1] == c]; 
Print["where  c = ", cont];

Then use Mathematica to make a 3D plot of the solution.

Clear[u, v]; 
Plot3D[Φ[u, v, 1], {u, 0, 2}, {v, 0, 1}, 
        PlotPoints -> {21, 
            11}, 
AxesLabel -> {"u", "v", "\
Φ[u,v]  "}, ColorFunction -> Hue]; 
Print["      Φ[u,v] = ", Φ[u, v, 
          1]]; 
Print["      Φ[u,0] = 0  when  u > 1"]; 
Print["      Φ[u,0] = 1  when  u < 1"];

The function  Φ (u, 
            v) = (1/π) ArcTan[
              (v/(u  -  1))] = (1/π) Arg[w  -  1] = 
            (1/π) Arg[u + i v  -  1]  is harmonic in the upper half plane  Im[w] > 0  and has the desired boundary values.

Remark 10.1 Let t be a real number. We shall use the convention Arctan (±∞) = (π/2) so that the function Arctan (t) denotes the branch of the inverse tangent that lies in the range 0 < Arctan (t) < π. Doing so permits us to write the solution in equation (10-4) as Φ (u, v) = (1/π) Arctan  (v/(u  -  (Subscript[u, 0]))).

Theorem 10.2 (N-Value Dirichlet Problem for the Upper Half Plane),  Page 392. Let (Subscript[u, 1]) <  (Subscript[u, 2]) < ⋯ <  (Subscript[u, N - 1]) denote N - 1 real constants. The function  

		\(Φ \((u, v)\) = 
        a\_\(N - 1\) + \(1\/π\) \(∑\+\(k = 1\)\%\(N - 1\)\((a\_\(k - 1\) - a\_k)\)\ Arg\ \((w - u\_k)\)\)\)
\(Φ \((u, v)\) = 
        a\_\(N - 1\) + \(1\/π\) \(∑\+\(k = 1\)\%\(N - 1\)\((a\_\(k - 1\) - a\_k)\)\ Arctan \((v\/\(u\  - \ u\_k\))\)\)\)  

is harmonic in the upper half plane  Im (w) > 0  and takes on the boundary values

		Φ (u, 0) = (Subscript[a, 0])      for   u < (Subscript[u, 1]),  
		Φ (u, 0) = 
        (Subscript[a, k])      for   (Subscript[u, k]) < u <  (Subscript[u, k + 1]) for k = 1, 2, ⋯, N - 2,  
		Φ (u, 0) = 
        (Subscript[a, N - 1])   for   u > (Subscript[u, N - 1]).

Proof of Theorem 10.2, see text Page 392.

Example 10.6,  Page 393.  Find a function  ϕ (x, y)  that is harmonic in the upper half-plane  Im[z] > 0,  which takes on the boundary values  

ϕ (x, 0) = 
        4   when      x < -1, 
ϕ (x, 
            0) = 1   when   - 1 < x < 
          0, 
ϕ (x, 0) = 
        3   when      0 < x < 
          1, 
ϕ (x, 0) = 
        2   when      1 < x.

Solution 10.6.

Enter the boundary values and construct the  Dirichlet sum.

Remove[a, x, y, z]; 
Clear[ϕ]; 
(Subscript[x, 1])  =  -1; 
(Subscript[x, 2])  =   0; 
(Subscript[x, 3])  =   1; 
(Subscript[a, 0])  =   4; 
(Subscript[a, 1])  =   1; 
(Subscript[a, 2])  =   3; 
(Subscript[a, 3])  =   2; 
z  =  x  +  I y; 
ϕ[x_, y_] = 
        (Subscript[a, 3]) + (((Subscript[a, 0]) - (Subscript[a, 1]))/π) 
            Arg[z - (Subscript[x, 1])] + (((Subscript[a, 1]) - (Subscript[a, 2]))/π) 
            Arg[z - (Subscript[x, 2])] + (((Subscript[a, 2]) - (Subscript[a, 3]))/π) 
            Arg[z - (Subscript[x, 3])]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]];

First use Mathematica to make a contour plot of the solution.

cont = 
        Table[k, {k, 1, 4, (1/4)}]; 
ContourPlot[ϕ[x, y], {x, -2, 2}, {y, 0.00001, 
          2}, 
Contours -> cont, 
        PlotPoints -> 35, 
        AspectRatio -> (1/2), 
ColorFunction -> 
          Hue]; 
Print["Contour plot for"]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]]; 
Print[""]; 
Print[ϕ[x, y] == c]; 
Print["where  c = ", cont];

Then use Mathematica to make a 3D plot of the solution.

\(
\(Plot3D[ϕ[x, y], {x, \(-2\), 2}, {y, 0.00001, 
          1}, 
PlotPoints -> {41, 11}, 
        AxesLabel -> {"x", "y", "ϕ[x,y] "}, 
ColorFunction -> Hue];\)\ \)
Print["ϕ[x,y] = ", ϕ[x, 
          y]];

The function  \(ϕ[x, y] = 
        2 + Arg[\(-1\) + x + i\ y]\/π - \(2\ Arg[x + i\ y]\)\/π + \(3\ Arg[1 + x + i\ y]\)\/π\)  is harmonic in the upper half-plane  Im[z] > 0,  and takes on the desired boundary values.

Example 10.7,  Page 393.  Find a function ϕ (x, y) that is harmonic in the upper half-plane  Im[z] > 0,  which takes on the boundary values  

ϕ (x, 0) = 
        1   when    | 
          x | <1, 
ϕ (x, 0) = 
        0   when    | x | >1.

Solution 10.7.

Enter the boundary values and construct the  Dirichlet sum.

Remove[a, v, x, y, 
        z]; 
Clear[ϕ]; 
(Subscript[x, 1])  =  -1; 
(Subscript[x, 2])  =   1; 
(Subscript[a, 0])  =   0; 
(Subscript[a, 1])  =   1; 
(Subscript[a, 2])  =   0; 
z  =  x  +  I y; 
ϕ[x_, y_] = 
        (Subscript[a, 2]) + (1/π) ((Subscript[a, 0]) - (Subscript[a, 1])) 
            Arg[z - (Subscript[x, 1])] + (1/π) ((Subscript[a, 1]) - (Subscript[a, 2])) 
            Arg[z - (Subscript[x, 2])]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]];

First use Mathematica to make a contour plot of the solution.

cont = Table[k, {k, 0, 1, (1/10)}]; 
ContourPlot[ϕ[x, y], {x, -2, 2}, {y, 0.000001, 2}, 
        Contours -> cont, PlotPoints -> 35, 
        AspectRatio -> (1/2), 
ColorFunction -> 
          Hue]; 
Print["Contour plot for"]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]]; 
Print[""]; 
Print[ϕ[x, y] == c]; 
Print["where  c = ", cont];

Then use Mathematica to make a 3D plot of the solution.

\(
\(Plot3D[ϕ[x, y], {x, \(-2\), 2}, {y, 0.00001, 
          1.5}, 
PlotPoints -> {41, 16}, 
        AxesLabel -> {"x", "y", "ϕ[x,y]  "}, 
ColorFunction -> Hue];\)\ \)
Print["ϕ[x,y] = ", ϕ[x, 
          y]];

The function  ϕ[x, y] = 
        Arg[-1 + x + i y]/π - 
          Arg[1 + x + i y]/π is harmonic in the upper half-plane  Im[z] > 0,  and takes on the desired boundary values.

Example 10.8,  Page 395.  Find a function  ϕ (x, y)  that is harmonic in the unit disk  |z|<1,  which takes on the boundary values 

\(ϕ \((x, 
            y)\) = \(0\ \ \ when\ \ \ z = e\^\(i\ θ\)\ \ \ and\ \ 0 < θ < π\), 
ϕ \((x, y)\) = \(1\ \ \ when\ \ \ z = e\^\(i\ θ\)\ \ \ and\ \ π < θ < 2 \( \(π\)\(.\)\)\)\)

Solution 10.8.

Construct the solution via a known conformal mapping.  This example is similar to Example 10.21, Page 343.

Remove[u, U, V, w, W, x, y, 
        z]; 
Clear[f, ϕ, Q]; 
f[
          z_]  =  ((I (1  -  z))/(1  +  z)); 
W  =  
        ComplexExpand[f[x +  I y],  
          TargetFunctions -> {Re, Im}]; 
U  =  
        ComplexExpand[Re[W],  
          TargetFunctions -> {Re, Im}]; 
V  =  
        ComplexExpand[Im[W],  
          TargetFunctions -> {Re, Im}]; 
V  =  Together[V]; 
Q  =  (1/π) ArcTan[(V/U)]; 
ϕ[x_, y_]  =  (1/π) ArcTan[Cancel[(V/U)]]; 
Print["     f[z] = ", f[z]]; 
Print["  f[x+\[ImaginaryI]y] = ", 
        U  +  I V]; 
Print[" "]; 
Print["Log[f[z]] = ", Log[f[z]]]; 
Print["Log[f[z]] = ", 
        Log[U  +  I V]]; 
Print[" "]; 
Print["   ϕ[x,y] = ", Arg[f[z]]]; 
Print["   ϕ[x,y] = ", 
        Arg[U  +  I V]]; 
Print[" "]; 
Print["   ϕ[x,y] = ", Q]; 
Print["   ϕ[x,y] = ", ϕ[x, 
          y]];

The above solution is theoretical, it can be used for computations.  If the trigonometric identity  arctan ((1/t)) = (π/2) -  arctan (t)  is used we get a version that plots the boundary values better.  Then use Mathematica to make a contour plot of the solution.

ϕ[x_, y_] = 
        (1/2) - (1/π) ArcTan[1 - (x^2) - (y^2), 2  y]; 
cont = Table[k, {k, 0, 1, (1/5)}]; 
ContourPlot[ϕ[x, y], {x, -1, 1}, {y, -1, 
          1}, 
Contours -> cont, 
        PlotPoints -> 75, 
AspectRatio -> 1, 
        ColorFunction -> Hue]; 
Print["Contour plot for"]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]]; 
Print[""]; 
Print[ϕ[x, y] == c]; 
Print["where  c = ", cont];

Next, use Mathematica to make a 3D plot of the solution.

Clear[Φ, r, θ]; 
Φ[r_, θ_]  =  
        Simplify[
          ReplaceAll[ϕ[x, y], {x -> r Cos[θ], 
              y -> r Sin[θ]}]]; 
\(\(CylindricalPlot3D[Φ[r, θ], {r, 0, 0.9999, 
          0.09999}, {θ, 0, 
          2  π, π\/32}, 
ViewPoint -> {1, 1, 
            1}, AxesLabel -> {"x", "y", "  ϕ[x,y]"}];\)\ \)
Print["ϕ[x,y] = ", ϕ[x, y]]; 
Print["Φ[r,θ] = ", Φ[
          r, θ]];

The function  ϕ[x, y] = (1/π) 
          ArcTan[((1 - (x^2) - (y^2))/(2 y))]  is harmonic in the unit disk  |z|<1,  and takes on the desired boundary values.

Example 10.9,  Page 396.  Find a function  ϕ (x, y)  that is harmonic in the upper half disk  H : y > 0, |z|<1,  which takes on the boundary values

\(ϕ \((x, 
            y)\) = \(0\ \ \ when\ \ \ z = e\^\(i\ θ\)\ \ \ and\ \ 0 < θ < π\), 
ϕ \((x, 0)\) = 1\ \ \ for\ \ \  - 1 < x < 1. \)

Solution 10.9.

Construct the solution via a known conformal mapping.

Remove[U, V, w, W, x, y, 
        z]; 
Clear[F, ϕ]; 
F[
          z_]  =  ((I (1  -  z))/(1  +  z)); 
W  =  
        ComplexExpand[F[x +  I y],  
          TargetFunctions -> {Re, Im}]; 
U  =  Together[ComplexExpand[Re[W]]]; 
V  =  Together[ComplexExpand[Im[W]]]; 
ϕ[x_, y_]  =  (2/π) ArcTan[(V/U)]; 
Print["w = ", F[z], " = ", 
        U + I V]; 
Print[" "]; 
\(\(Print[\*""\!\(2\/π\)Log[w] = "", \(2\/π\) 
          Log[U + I\ V]];\)\ \)
Print[" "]; 
Print["   ϕ[x,y] = ", ϕ[x, 
          y]];

The above solution is theoretical, it can be used for computations.  If the trigonometric identity  arctan ((1/t)) = (π/2) -  arctan (t) is used we get a version that plots the boundary values better.  Then use Mathematica to make a contour plot of the solution.

ϕ[x_, y_] = 
        1 - (2/π) ArcTan[1 - (x^2) - (y^2), 2  y]; 
cont = Table[k, {k, 0, 1, (1/5)}]; 
ContourPlot[ϕ[x, y], {x, -1.1, 1.1}, {y, -0.05, 
          1.05}, 
Contours -> cont, 
        PlotPoints -> 75, 
AspectRatio -> (1/2), 
        ColorFunction -> Hue]; 
Print["Contour plot for"]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]]; 
Print[""]; 
Print[ϕ[x, y] == c]; 
Print["where  c = ", cont];

Next, use Mathematica to make a 3D plot of the solution.

Clear[Φ, r, θ]; 
Φ[r_, θ_]  =  
        Simplify[
          ReplaceAll[ϕ[x, y], {x -> r Cos[θ], 
              y -> r Sin[θ]}]]; 
\(\(CylindricalPlot3D[Φ[r, θ], {r, 0, 0.9999, 
          0.09999}, {θ, 
          0, π, π\/32}, 
ViewPoint -> {1, 1, 
            1}, AxesLabel -> {"x", "y", "ϕ[x,y]  "}];\)\ \)
Print["ϕ[x,y] = ", ϕ[x, y]]; 
Print["Φ[r,θ] = ", Φ[
          r, θ]];

The function  ϕ[x, y] = (2/π) ArcTan[((1 - (x^2) - (y^2))/(2 y))]  that is harmonic in the upper half disk  H : y > 0, |z|<1,  and takes on the desired boundary values.

Example 10.10,  Page 397.  Find a function  ϕ (x, y)  that is harmonic in the quarter disk  G : x > 0, y > 0, |z|<1,  which takes on the boundary values

\(ϕ \((x, 
            y)\) = \(0\ \ \ when\ \ \ z = e\^\(i\ θ\)\ \ \ and\ \ 0 < θ < π\/2\), 
ϕ \((x, 0)\) = 
        1\ \ \ for\ \ \ 0 < x < 1, 
ϕ \((0, y)\) = 
        1\ \ \ for\ \ \ 0 < y < 1. \)

Solution 10.10.

Construct the solution via a known conformal mapping.

Remove[U, V, w, W, x, y, 
        z]; 
Clear[F, ϕ]; 
F[
          z_]  =  ((I (1  -  (z^2)))/(1  +  (z^2))); 
W  =  
        ComplexExpand[F[x +  I y],  
          TargetFunctions -> {Re, Im}]; 
U  =  Together[ComplexExpand[Re[W]]]; 
V  =  Together[ComplexExpand[Im[W]]]; 
ϕ[x_, y_]  =  (2/π) ArcTan[(V/U)]; 
Print["w = ", F[z], " = ", 
        U + I V];  
Print[" "]; 
\(\(Print[\*""\!\(2\/π\)Log[w] = "", \(2\/π\) 
          Log[U + I\ V]];\)\ \)
Print[" "]; 
Print["   ϕ[x,y] = ", ϕ[x, 
          y]];

First use Mathematica to make a contour plot of the solution.

ϕ[x_, y_] = 
        (2/π) ArcTan[((1 - (x^4) - 2 (x^2) (y^2) - (y^4))/(4 x y))]; 
cont = Table[k, {k, 0, 1, (1/5)}]; 
ContourPlot[ϕ[x, y], {x, 0.0001, 1}, {y, 0.0001, 
          1}, 
Contours -> cont, 
        PlotPoints -> 55, 
AspectRatio -> 1, 
        ColorFunction -> Hue]; 
Print["Contour plot for"]; 
Print["ϕ[x,y] = ", ϕ[x, 
          y]]; 
Print[""]; 
Print[ϕ[x, y] == c]; 
Print["where  c = ", cont];

Then use Mathematica to make a 3D plot of the solution.

Clear[Φ, r, θ]; 
Φ[r_, θ_]  =  
        Simplify[
          ReplaceAll[ϕ[x, y], {x -> r Cos[θ], 
              y -> r Sin[θ]}]]; 
CylindricalPlot3D[Φ[r, θ], {r, 0.001, 
          1}, {θ, 0.001, 1.56}, ViewPoint -> {2, -1, 1}, 
        AxesLabel -> {"x", "y", "  ϕ[x,y]"}]; 
Print["ϕ[x,y] = ", ϕ[x, y]]; 
Print["Φ[r,θ] = ", Φ[
          r, θ]];

The function  \(ϕ[x, y] = 
        2\/π\ ArcTan[\(1 - x\^4 - 2\ x\^2\ y\^2 - y\^4\)\/\(4\ x\ y\)]\)  that is harmonic in the quarter disk  G : x > 0, y > 0, |z|<1,  and takes on the desired boundary values.

Section 10.2  Exercises for Invariance of Laplace's Equation and the Dirichlet Problem
See textbook page 399.

Section 10.3	Poisson's Integral Formula for the Upper Half Plane

Section 10.4	Two Dimensional Mathematical Models

Section 10.5	Steady State Temperatures

Section 10.6	Two-Dimensional Electrostatics

Section 10.7	Two-Dimensional Fluid Flow

Section 10.8	The Joukowski Airfoil

Section 10.9	The Schwarz-Christoffel Transformation

Section 10.10	Image of a Fluid Flow

Section 10.11	Sources and Sinks

GO TO  THE  Table of Contents