1 Introduction

Classical function theory studies analytic functions and conformal maps defined on subdomains of the complex plane \(\mathbb {C}\,\). Most commonly, the domain of definition of the functions is the unit disk \(\mathbb {D}=\{z \in \mathbb {C} \,|\, |z|<1\}\). The powerful Riemann mapping theorem says that a given simply connected domain G with non-degenerate boundary can be mapped conformally onto the unit disk and it enables us to extend results originally proven for functions defined in the unit disk to the case when the domain of definition is a simply connected domain. Therefore for the convenient analysis of distances and other metric characteristics of sets it is natural to use conformally invariant distances and set functions. This works fine in the cases when the Riemann mapping function is known explicitly, such as in the cases described in [12]. Polygons form a large class of plane domains for which the Riemann mapping function can be given in terms of the Schwarz–Christoffel formula which is semi-explicit, although it involves unknown accessory parameters. A numerical implementation of conformal mapping methods based on the Schwarz–Christoffel formula is documented in [6] and the Schwarz–Christoffel Toolbox [5] is widely used to solve mapping problems in concrete applications. The so called crowding phenomenon, an inherent computational challenge in these mapping problems, is described in [6, pp. 20–21], [21, pp. 75–77]. This phenomenon can be observed already in numerical conformal mapping of rectangles onto a half-plane when the quotient \(m>1\) of the side lengths is large enough. The critical value of m depends on the computer floating point arithmetic and for double precision arithmetic the critical value lies in the range \( [10,20]\,\) [6, pp. 20–21], [21, pp. 75–77].

We apply here the boundary integral equation method as developed in [14, 16, 17, 19, 25] to compute numerically conformal invariants such as the hyperbolic metric, harmonic measure, reduced modulus, and the modulus of a quadrilateral [7, 8, 21, 23]. The cases considered here include, in particular, classes of domains to which the earlier methods do not seem to apply. Our methods are described in the respective sections of the paper, they are implemented in MATLAB, and the results are summarized by tabular data and graphics. We also give experimental error estimate in some simple cases. We include some code snippets within the text to indicate implementation details. All the computer codes of our computations are available in the internet link https://github.com/mmsnasser/ci-simply.

Section 2 reviews the boundary integral equation method for computing the conformal mapping from bounded and unbounded simply connected domains onto circular domains. This method will be applied in the remaining sections, sometimes together with auxiliary procedures. In Sect. 3 we use our method to compute the hyperbolic distance for several examples. Section 4 deals with the reduced modulus for bounded and unbounded simply connected domains. Section 5 deals with the harmonic measure for a simply connected polygonal domains. In Sect. 6, we present an iterative method for numerical computation of the conformal mapping from a quadrilateral onto a rectangle. We also present an analytic example to illustrate the effect of crowding phenomenon on the accuracy of such mapping.

2 Conformal Mappings of Simply Connected Domains

In this section, we review a numerical method for computing the conformal mapping from bounded and unbounded simply connected domains onto the unit disk and the exterior unit disk, respectively. The method is based on the boundary integral equation with the generalized Neumann kernel [16,17,18, 25].

2.1 The Generalized Neumann Kernel

Let G be a bounded or an unbounded simply connected domain bordered by a closed smooth Jordan curve \(\varGamma =\partial G\). The orientation of the boundary \(\varGamma \) is counterclockwise when G is bounded and clockwise when G is unbounded. We parametrize \(\varGamma \) by a \(2\pi \)-periodic complex function \(\eta (t)\), \(t\in [0,2\pi ]\). We assume that \(\eta (t)\) is twice continuously differentiable with \(\eta '(t)\ne 0\) (the presented method can be applied also if the curve \(\varGamma \) has a finite number of corner points but no cusps [19]). We denote by H the space of all Hölder continuous real functions on the boundary \(\varGamma \).

Let A be the complex function [17]

$$\begin{aligned} A(t)= \left\{ \begin{array}{l@{}l} \eta (t)-\alpha ,&{}\mathrm{if\;} G\mathrm{\; is\; bounded},\\ 1 ,&{}\mathrm{if\;} G \mathrm{\; is\; unbounded}.\\ \end{array} \right. \end{aligned}$$
(1)

The generalized Neumann kernel N(st) is defined for \((s,t)\in [0,2\pi ]\times [0,2\pi ]\) by

$$\begin{aligned} N(s,t) := \frac{1}{\pi }\mathrm{Im}\,\left( \frac{A(s)}{A(t)}\frac{\dot{\eta }(t)}{\eta (t)-\eta (s)}\right) . \end{aligned}$$
(2)

The kernel N(st) is continuous [25]. Hence, the integral operator \(\mathbf{N}\) defined on H by

$$\begin{aligned} \mathbf{N}\rho (s) := \int _J N(s,t) \rho (t) dt, \quad s\in [0,2\pi ], \end{aligned}$$

is compact. The integral equation with the generalized Neumann kernel involves also the following kernel

$$\begin{aligned} M(s,t) := \frac{1}{\pi }\mathrm{Re}\,\left( \frac{A(s)}{A(t)}\frac{\dot{\eta }(t)}{\eta (t)-\eta (s)}\right) , \quad (s,t)\in [0,2\pi ]\times [0,2\pi ]. \end{aligned}$$
(3)

which is singular and its singular part involves the cotangent function [25]. The integral operator \(\mathbf{M}\) defined on H by

$$\begin{aligned} \mathbf{M}\rho (s) := \int _J M(s,t) \rho (t) dt, \quad s\in [0,2\pi ], \end{aligned}$$

is singular, but it is bounded on H [25].

2.2 Bounded Simply Connected Domain

Let \(w=\varPhi (z)\) be the unique conformal map of the bounded simply connected domain G onto the unit disk \(|w|<1\) such that

$$\begin{aligned} \varPhi (\alpha )=0\quad \mathrm{and}\quad \varPhi '(\alpha )>0. \end{aligned}$$
(4)

Then, the mapping function \(\varPhi \) with normalization (4) can be written for \(z\in G\cup \varGamma \) as [18, § 3]

$$\begin{aligned} \varPhi (z)=c(z-\alpha )e^{(z-\alpha )f(z)} \end{aligned}$$
(5)

where the function f(z) is analytic in G with the boundary values \(A(t)f(\eta (t))=\gamma (t)+h+\mathrm {i}\rho (t)\), \(A(t)=\eta (t)-\alpha \), the function \(\gamma \) is defined by \(\gamma (t)=-\log |\eta (t)-\alpha |\), \(\rho \) is the unique solution of the integral equation

$$\begin{aligned} (\mathbf{I}-\mathbf{N})\rho =-\mathbf{M}\gamma , \end{aligned}$$
(6)

and \(c=e^{-h}\) where the constant h is given by

$$\begin{aligned} h=\frac{1}{2}[\mathbf{M}\rho -(\mathbf{I}-\mathbf{N})\gamma ]. \end{aligned}$$
(7)

Notice that \(\varPhi '(\alpha )=c=e^{-h}>0\).

Instead of the normalization (4), we can assume that the mapping function \(\varPhi \) satisfies the normalization

$$\begin{aligned} \varPhi (\alpha )=0\quad \mathrm{and}\quad \varPhi '(\alpha )=1. \end{aligned}$$
(8)

In this case, the function \(\varPhi \) maps the domain G onto the disk \(|w|<R\) with a positive constant R. The constant R is uniquely determined by G and the point \(\alpha \) and is called the conformal radius of G with respect to \(\alpha \) and is denoted by \(R(G,\alpha )\). For this case, in view of (5), we can write the mapping function \(\varPhi \) for \(z\in G\cup \varGamma \) as

$$\begin{aligned} \varPhi (z)=(z-\alpha )e^{(z-\alpha )f(z)} \end{aligned}$$
(9)

where the function f is as in (5), i.e., we divide the right-hand side of (5) by \(c=e^{-h}\). Hence, the boundary values of the mapping function \(\varPhi \) satisfy \(|\varPhi (\eta (t))|=1/c=e^h\) which implies

$$\begin{aligned} R(G,\alpha )=e^h, \end{aligned}$$
(10)

where the constant h is as in (7).

2.3 Unbounded Simply Connected Domain

For an unbounded simply connected domain \(G\subset \overline{{\mathbb C}}\) with \(\infty \in G\), there exists a unique conformal map \(w=\varPhi (z)\) from G onto the exterior of the unit disk \(|w|>1\) such that

$$\begin{aligned} \varPhi (\infty )=0\quad \mathrm{and}\quad \varPhi '(\infty )>0. \end{aligned}$$
(11)

Then, the mapping function \(\varPhi \) with normalization (4) can be written for \(z\in G\cup \varGamma \) as [18, § 3]

$$\begin{aligned} \varPhi (z)=c(z-\beta )e^{f(z)} \end{aligned}$$
(12)

where \(\beta \) is an auxiliary point in \(G^c=\overline{{\mathbb C}}\backslash \overline{G}\) and f(z) is an analytic function in G with \(f(\infty )=0\). The boundary values of the function f are given by \(A(t)f(\eta (t))=\gamma (t)+h+\mathrm {i}\rho (t)\) where \(A(t)=1\), the function \(\gamma \) is defined by \(\gamma (t)=-\log |\eta (t)-\beta |\), \(\rho \) is the unique solution of the integral equation (6), and \(c=e^{-h}\) where the constant h is given by (7). Notice that \(\varPhi '(\infty )=c=e^{-h}>0\).

Similar to the bounded case, the normalization (11) can be replaced by

$$\begin{aligned} \varPhi (\infty )=\infty \quad \mathrm{and}\quad \varPhi '(\infty )=1. \end{aligned}$$
(13)

For the new normalization (13), the mapping function \(\varPhi \) maps the unbounded domain G onto the exterior disk \(|w|>R\) with a positive constant R. The constant R is uniquely determined by G and is called the conformal radius of G with respect to \(\infty \) and is denoted by \(R(G,\infty )\). If \(\varPhi \) satisfies the normalization (13), then it can be written as

$$\begin{aligned} \varPhi (z)=(z-\beta )e^{f(z)}, \quad z\in G\cup \varGamma , \end{aligned}$$
(14)

and its boundary values satisfy \(|\varPhi (\eta (t))|=1/c=e^h\) where the function f is as in (5) and h is given by (7). Hence,

$$\begin{aligned} R(G,\infty )=e^h. \end{aligned}$$
(15)

2.4 Numerical Solution of the Boundary Integral Equation

The integral equation (6) is solved using the MATLAB function fbie in [17]. The function fbie is based on using the MATLAB function \(\texttt {zfmm2dpart}\) in the toolbox \(\texttt {FMMLIB2D}\) [9]. The computational cost for the overall method is \(O(n\log n)\) operations where n is the number of nodes in the interval \([0,2\pi ]\). Let et, etp, A, and gam be the discretization vectors of the functions \(\eta (t)\), \(\eta '(t)\), A(t), and \(\gamma (t)\), respectively. Then discretization vectors \(\texttt {rho}\) and \(\texttt {h}\) of the solution \(\rho (t)\) of the integral equation (6) and the constant h in (7), respectively, can be computed by

$$\begin{aligned} {[}{} \texttt {rho},\texttt {h}] = \texttt {fbie}(\texttt {et},\texttt {etp},\texttt {A},\texttt {gam}, \texttt {n},\texttt {iprec},\texttt {restart},\texttt {gmrestol},\texttt {maxit}). \end{aligned}$$

In the numerical experiments in this paper, the parameters in \(\texttt {fbie}\) are chosen as following: \(\texttt {iprec}=5\) (the tolerances of the FMM is \(0.5\times 10^{-15}\)), \(\texttt {gmrestol}=0.5\times 10^{-14}\) (the tolerances of the GMRES), \(\texttt {restart}=[\,]\) (the GMRES is used without restart), and \(\texttt {maxit}=100\) (the maximum number of iterations for GMRES).

Finally, the values of the auxiliary points \(\alpha \) in (5), (9) and \(\beta \) in (12), (14) have no effects on the values of the conformal mapping \(\varPhi \) as long as these points are sufficiently far away from the boundary \(\varGamma \).

3 Hyperbolic Distance

For \(x,y \in \mathbb {D}\) the hyperbolic distance \(\rho _{\mathbb {D}}(x,y)\) is defined by [4, 8, 11]

$$\begin{aligned} \sinh \frac{\rho _{\mathbb {D}}(x,y)}{2} = \frac{|x-y|}{\sqrt{(1-|x|^2)(1-|y|^2)}}\,. \end{aligned}$$

The main property of the hyperbolic distance is the invariance under Möbius transformations of \(\mathbb {D}\) onto \(\mathbb {D}\) defined by

$$\begin{aligned} z \mapsto \frac{z-a}{1- \overline{a}z}\, \end{aligned}$$

where \(a\in \mathbb {D}\) is fixed. In the metric space \((\mathbb {D}, \rho _{\mathbb {D}})\) one can build a non-euclidean geometry, where the parallel axiom does not hold. In this geometry, usually called the hyperbolic geometry of the Poincare disk, lines are circular arcs perpendicular to the boundary \(\partial \mathbb {D} \,.\) This geometry is fundamentally different from the Euclidean geometry, but many results of Euclidean geometry have counterparts in the hyperbolic geometry [4].

Let G be a Jordan domain in the plane. One can define the hyperbolic metric on G in terms of the conformal Riemann mapping function \(\varPhi : G \rightarrow \mathbb {D}= \varPhi (G)\) as follows:

$$\begin{aligned} \rho _G(x,y) = \rho _{\mathbb {D}}(\varPhi (x),\varPhi (y))\,. \end{aligned}$$

This definition yields a well-defined metric, independent of the conformal mapping \(\varPhi \,\) [4, 8, 11]. In hyperbolic geometry the boundary \(\partial G\) has the same role as the point of \(\{\infty \}\) in Euclidean geometry: both are like “horizon”, we cannot see beyond the horizon. It turns out that the hyperbolic geometry is more useful than the Euclidean geometry when studying the inner geometry of domains in geometric function theory.

3.1 Computing the Hyperbolic Distance for Simply Connected Domains

Let \(G\subset \overline{{\mathbb C}}\) be a bounded simply connected domain, let \(\alpha \in G\), and let \(w=\varPhi (z)\) be the unique conformal map of G onto the unit disk \(|w|<1\) with the normalization (4). Then for any two points \(z_1\) and \(z_2\) in G, we can define the hyperbolic metric \(\rho _G\) in the usual way,

$$\begin{aligned} \rho _G(z_1,z_2)=\rho _\mathbb {D}(\varPhi (z_1),\varPhi (z_2)) = 2\sinh ^{-1}\left( \frac{|\varPhi (z_1)-\varPhi (z_2)|}{\sqrt{\left( 1-|\varPhi (z_1)|^2\right) \left( 1-|\varPhi (z_2)|^2\right) }}\right) . \end{aligned}$$
(16)

A MATLAB function for computing the hyperbolic metric \(\rho _G(z_1,z_2)\) for any two points \(z_1\) and \(z_2\) in the bounded simply connected domain G is given below.

figure a

In the remaining part of this section, we use the MATLAB function hypdist to compute the hyperbolic metric \(\rho _G(z_1,z_2)\) for several examples. In these examples, for a given point \(z_1\) in G, we define the function u(xy) for all x and y such that \(x+\mathrm {i}y\) is in G by

$$\begin{aligned} u(x,y)=\rho _G(z_1,x+iy) \end{aligned}$$
(17)

Then we use the MATLAB function hypdist to compute the values of the function u(xy) in the domain G and plot the contour lines for the function u(xy) corresponding to the several levels.

3.2 L-Shaped Polygon

As our first example, we consider the simply connected domain G in the interior of the L-shaped polygon with the vertices \(6+\mathrm {i}\), \(1+\mathrm {i}\), \(1+4\mathrm {i}\), \(-1+4\mathrm {i}\), \(-1-\mathrm {i}\), and \(6-\mathrm {i}\). The contour lines of the function u(xy) obtained with \(n=6\times 2^9\) discretization points on the boundary of the L-shaped polygon are shown in Fig. 1 (left) for \(z_1=2\mathrm {i}\) and in Fig. 1 (right) for \(z_1=2\). Table 1 presents the values of the hyperbolic metric \(\rho _G(z_1,z_2)\) for \(z_1=2\mathrm {i}\) (left), \(z_1=2\) (right), and for several values of \(z_2\).

Fig. 1
figure 1

The contour lines of the function u(xy) for the L-shaped polygon for \(z_1=2\mathrm {i}\) (left) and \(z_1=2\) (right)

Table 1 The values of the hyperbolic metric \(\rho _G(z_1,z_2)\)

3.3 Amoeba-Shaped Boundary

In the second example, we consider the simply connected domain G in the interior of the curve \(\varGamma \) (amoeba-shaped boundary [3]) with the parametrization

$$\begin{aligned} \eta (t)=\left( e^{\cos t}\cos ^22t+e^{\sin t}\sin ^22t\right) e^{\mathrm {i}t}, \quad 0\le t\le 2\pi . \end{aligned}$$

The contour lines for the function u(xy) computed with \(n=2^{12}\) are shown in Fig. 2 (left) for \(z_1=2\) and in Fig. 2 (right) for \(z_1=-1+\mathrm {i}\).

Fig. 2
figure 2

The contour lines of the function u(xy) for the amoeba-shaped boundary for \(z_1=2\) (left) and \(z_1=-1+\mathrm {i}\) (right)

3.4 Circular Arc Quadrilateral

For the third example, we consider the simply connected domain G in the interior of the circular arc quadrilateral consisting of the right-half of the circle with center 1 and radius 1, the upper-half of the circle with center \(\mathrm {i}\) and radius 1, the left-half of the circle with center \(-1\) and radius 1, and the lower-half of the circle with center \(-\mathrm {i}\) and radius 1. The contour lines for the function u(xy) computed with \(n=2^{12}\) are shown in Fig. 3 (left) for \(z_1=1.5\) and in Fig. 3 (right) for \(z_1=0\).

Fig. 3
figure 3

The contour lines of the function u(xy) for the circular arc quadrilateral \(z_1=1.5\) (left) and \(z_1=0\) (right)

3.5 Circular Arc Polygon

In the fourth example, we consider the simply connected domain G in the interior of the circular arc polygon with seven sides. The contour lines for the function u(xy) computed with \(n=7\times 2^{10}\) are shown in Fig. 4 (left) for \(z_1= 4+5\mathrm {i}\) and in Fig. 4 (right) for \(z_1=3+3\mathrm {i}\).

Fig. 4
figure 4

The contour lines of the function u(xy) for the circular arc polygon \(z_1= 4+5\mathrm {i}\) (left) and \(z_1=3+3\mathrm {i}\) (right)

4 Reduced Modulus

The reduced modulus for simply connected domains is defined in terms of the conformal radius of simply connected domains introduced in Sect. 2.

Let \(G\subset \overline{{\mathbb C}}\) be a bounded simply connected domain and \(\alpha \in G\). The reduced modulus of the domain G with respect to the point \(\alpha \) is defined by [23, p. 16], [8, p.168, 560], [7, pp. 26–27]

$$\begin{aligned} m(G,\alpha ) = \frac{1}{2\pi }\log R(G,\alpha ), \end{aligned}$$
(18)

where \(R=R(G,\alpha )\) is the conformal radius of G with respect to the point \(\alpha \). It follows from this definition that \(m(G,\alpha )<0\) when \(R(G,\alpha )<1\), \(m(G,\alpha )=0\) when \(R(G,\alpha )=1\), and \(m(G,\alpha )>0\) when \(R(G,\alpha )>1\).

For an unbounded simply connected domain \(G\subset \overline{{\mathbb C}}\) with \(\infty \in G\), the reduced modulus of the domain G with respect to \(\infty \) is defined by [23, p. 17]

$$\begin{aligned} m(G,\infty ) = -\frac{1}{2\pi }\log R(G,\infty ), \end{aligned}$$
(19)

where \(R=R(G,\infty )\) is the conformal radius of G with respect to \(\infty \).

4.1 Computing the Reduced Modulus of Simply Connected Domains

As was explained in Sect. 2, the conformal radius of simply connected domains can be computed using the integral equation with the generalized Neumann kernel. For bounded simply connected domains, it follows from (10) that the reduced modulus of the domain G with respect to the point \(\alpha \) is given by

$$\begin{aligned} m(G,\alpha ) = \frac{h}{2\pi } \end{aligned}$$

where the constant h is given by (7). For unbounded simply connected domains, it follows from (15) that the reduced modulus of the domain G with respect to the point \(\infty \) is given by

$$\begin{aligned} m(G,\infty ) = -\frac{h}{2\pi }. \end{aligned}$$

The above method for computing the conformal radius and the reduced modulus of bounded and unbounded simply connected domains can be implemented in MATLAB as in the following function.

figure b

4.2 Domain Exterior to an Ellipse

As our first example, we consider the simply connected domain \(G_r\) in the exterior of the ellipse

$$\begin{aligned} \eta (t)=\cos t-\mathrm {i}r\sin t, \quad 0\le t\le 2\pi , \quad 0<r\le 1. \end{aligned}$$

For \(r=0\), the ellipse reduces to the segment \([-1,1]\) and for \(r=1\) to the unit circle.

We can easily show that the function

$$\begin{aligned} z=\varPsi (w)=w+\frac{1-r^2}{4}\frac{1}{w} \end{aligned}$$

maps the domain exterior to the circle \(|w|=(1+r)/2\) onto the domain exterior of the ellipse. Hence, the inverse mapping

$$\begin{aligned} w=\varPhi (z)=z\left( \frac{1}{2}+\frac{1}{2}\sqrt{1-\frac{1-r^2}{z^2}}\right) , \end{aligned}$$
(20)

maps the domain exterior to the ellipse onto the domain \(|w|>(1+r)/2\), where the branch of the square root is chosen such that \(\sqrt{1}=1\). It is clear that the function \(\varPhi \) satisfies \(\varPhi (\infty )=\infty \) and \(\varPhi '(\infty )=1\). Hence, \(R(G,\infty )=(1+r)/2\) and

$$\begin{aligned} m(G,\infty )=-\frac{1}{2\pi }\log \frac{1+r}{2}=\frac{1}{2\pi }\log \frac{2}{1+r}. \end{aligned}$$

We use the MATLAB function confrad to compute the reduced modulus \(m(G_r,\infty )\) with \(n=2^{12}\) for \(0.005\le r\le 1\). The obtained results are shown in Fig. 5.

Fig. 5
figure 5

The computed and the exact reduced modulus of the domain \(G_r\) exterior to an ellipse (left) and the absolute error in the computed values (right)

4.3 Domain Interior to an Ellipse

For the second example, we consider the simply connected domain \(G_r\) in the interior of the ellipse

$$\begin{aligned} \eta (t)=\cosh r\cos t+\mathrm {i}\sinh r\sin t, \quad 0\le t\le 2\pi , \quad 0<r. \end{aligned}$$

Let \(w=\varPhi (z)\) be the unique conformal mapping from the interior of the ellipse onto the interior of the unit circle with the normalization \(\varPhi (0)=0\) and \(\varPhi '(0)>0\). The exact form of the inverse conformal mapping \(z=\varPhi ^{-1}(w)\) is given in [10]. In particular, it was shown in [10] that \((\varPhi ^{-1})'(0)=\pi /(2\sqrt{s}K(s))\) where \(s=\mu ^{-1}(2r)\) where \(\mu ^{-1}\) is the inverse of the Grötzsch modulus function, see (28) below. Hence, \(\varPhi '(0)=2\sqrt{s}K(s)/\pi \). Thus, the mapping function \({\hat{\varPhi }}\) defined by

$$\begin{aligned} w={\hat{\varPhi }}(z)=\frac{\varPhi (z)}{\varPhi '(0)}=\frac{\pi }{2\sqrt{s}K(s)}\varPhi (z) \end{aligned}$$

is the unique conformal mapping from the interior of the ellipse onto the

$$\begin{aligned} |w|<\frac{\pi }{2\sqrt{s}K(s)} \end{aligned}$$

with the normalization \({\hat{\varPhi }}(0)=0\) and \({\hat{\varPhi }}'(0)=1\). Thus, \(R(G_r,0)=\pi /(2\sqrt{s}K(s))\) and hence

$$\begin{aligned} m(G_r,0)=\frac{1}{2\pi }\log \frac{\pi }{2\sqrt{s}K(s)}, \quad s=\mu ^{-1}(2r). \end{aligned}$$

We use the MATLAB function confrad to compute the reduced modulus \(m(G_r,0)\) with \(n=2^{12}\) for \(0.2\le r\le 20\). The obtained results are shown in Fig. 6.

Fig. 6
figure 6

The computed and the exact reduced modulus of the domain \(G_r\) interior to an ellipse (left) and the absolute error in the computed values (right)

4.4 Slitted Unit Disk

In the third example, we consider three types of slitted unit disks. In each case the exact reduced moduli are given in [23, p. 33].

1) \(G_1=\mathbb {D}\backslash (-1,0]\) where \(\mathbb {D}\) is the unit disk. The exact value of the reduced modulus of \(G_1\) with respect to \(r\in (0,1)\) is given by [23]

$$\begin{aligned} m(G_1,r)=\frac{1}{2\pi }\log \frac{4r(1-r)}{1+r}. \end{aligned}$$

To use the integral equation to compute \(m(G_1,r)\), we first use the auxiliary map

$$\begin{aligned} \zeta =\varPhi _1(z)=2\sqrt{r}\sqrt{z}, \end{aligned}$$

where the branch of the square root is chosen on the negative real line, to open up the slit and map the region \(G_1\) onto a region \(\hat{G}_1\) bordered by piecewise smooth Jordan curve where \(\varPhi _1(r)=2r\) and \(\varPhi '_1(r)=1\). Then, it follows from [23, Cor. 2.2.1] that \(m(G_1,r)=m(\hat{G}_1,2r)\). We use the MATLAB function confrad to compute the reduced modulus \(m(\hat{G}_1,2r)\) with \(n=2^{12}\) for \(0.01\le r\le 0.99\). The obtained results are shown in Fig. 7 (left).

2) \(G_2=\mathbb {D}\backslash [r,1)\) for \(0<r<1\). The exact value of the reduced modulus of \(G_2\) with respect to the origin is given by [23]

$$\begin{aligned} m(G_2,0)=\frac{1}{2\pi }\log \frac{4r}{(1+r)^2}. \end{aligned}$$

To compute \(m(G_2,r)\), we first use the auxiliary map

$$\begin{aligned} \zeta =\varPhi _1(z)=2\mathrm {i}\sqrt{r}\sqrt{z-r}, \end{aligned}$$

where the branch of the square root is chosen on the positive real line, to map the region \(G_2\) onto a region \(\hat{G}_2\) bordered by piecewise smooth Jordan curve where \(\varPhi _1(0)=-2r\) and \(\varPhi '_1(0)=1\). Then, \(m(G_2,0)=m(\hat{G}_2,-2r)\). We use the MATLAB function confrad to compute \(m(\hat{G}_2,-2r)\) with \(n=2^{12}\) for \(0.01\le r\le 0.99\). The obtained results are shown in Fig. 7 (center).

3) \(G_3=\mathbb {D}\backslash (-1,a]\) for \(0\le a<1\). The exact value of the reduced modulus of \(G_3\) with respect to \(r\in (a,1)\) is given by [23]

$$\begin{aligned} m(G_3,r)=\frac{1}{2\pi }\log \frac{4(r-a)(1-ra)(1-r)}{(1+r)(1-a)^2}. \end{aligned}$$

To compute \(m(G_3,r)\), we first use the auxiliary map

$$\begin{aligned} \zeta =\varPhi _1(z)=2\sqrt{r-a}\sqrt{z-a}, \end{aligned}$$

where the branch of the square root is chosen on the negative real line, to map the region \(G_3\) onto a region \(\hat{G}_3\) bordered by a piecewise smooth Jordan curve where \(\varPhi _1(r)=2(r-a)\) and \(\varPhi '_1(r)=1\). Hence, \(m(G_3,r)=m(\hat{G}_3,2(r-a))\). We use the MATLAB function confrad to compute \(m(\hat{G}_3,2(r-a))\) with \(n=2^{12}\) for \(a=0,0.25,0.5\), 0.75 and \(a+0.01\le r\le 0.99\). The obtained results are shown in Fig. 7 (right).

Fig. 7
figure 7

The absolute error for \(G_1\) (left), \(G_2\) (center), and \(G_3\) (right)

4.5 Polygon

For the fourth example, we consider the simply connected domain \(G_\ell \) in the interior of a polygon with \(\ell \) vertices where \(\ell \ge 3\) (see Fig. 8 (left) for \(\ell =8\)). We assume that the vertices of the polygon are given by

$$\begin{aligned} v_k=e^{2k\pi \mathrm {i}/\ell }, \quad k=0,1,2,\ldots ,\ell -1. \end{aligned}$$

In this example, the exact value of the reduced modulus is unknown. We use the MATLAB function confrad to compute the reduced modulus \(m(G_\ell ,0)\) with \(n=\ell \times 2^{9}\) for \(\ell =3,4,\ldots ,40\). The obtained results are shown in Fig. 8. It is clear from this figure that \(m(G_\ell ,0)<0\) which means that \(R(G_\ell ,0)<1\) for the above values of \(\ell \). In other words, the conformal mapping \(\varPhi \) with the normalization (8) maps the domain \(G_\ell \) onto a disk interior to the unit disk.

Fig. 8
figure 8

The domain \(G_\ell \) for \(\ell =8\) (left) and the computed reduced modulus for the domain \(G_\ell \) for \(3\le \ell \le 40\) (right)

5 Harmonic Measure

Let G be a Jordan domain in \(\overline{{\mathbb C}}\) and \(\varGamma \) be its boundary. Let also L be a boundary arc on \(\varGamma \) such that \(L\ne \emptyset \) and \(\varGamma \backslash L\ne \emptyset \). The harmonic measure of L with respect o G is the \(C^2(G)\) function \(u: G \rightarrow (0,1)\) satisfying the Laplace equation

$$\begin{aligned} \varDelta u = 0 \end{aligned}$$

in G and \(u(z) \rightarrow 1\) when \(z \rightarrow L \) and \(u(z) \rightarrow 0\) when \(z\rightarrow \varGamma \setminus L\,\). The harmonic measure is one of the key notions of potential theory and it has numerous applications to geometric function theory [8]. The harmonic measure of L with respect to G will be denoted by \(\omega (z,L)\) (see e.g., [2, p. 123], [8, Ch. I], and [22, p. 111]).

5.1 Harmonic Measure for the Unit Disk

Assume that G is the unit disk \(|z|<1\), \(\varGamma \) is the unit circle \(|z|=1\), and L is the right half of the unit circle. It is clear that the Möbius transformation

$$\begin{aligned} z \mapsto \frac{z-\mathrm {i}}{\mathrm {i}z-1} \end{aligned}$$

maps the unit circle onto the real line and the interior of the unit circle onto the upper half plane. More precisely, it maps the right half of the unit circle onto the negative real line, maps the point \(\mathrm {i}\) onto 0, maps the left half of the unit circle onto the positive real line, and maps \(-\mathrm {i}\) onto \(\infty \). Hence, the harmonic measure of L with respect to G is given by [2, p. 123], [8, Ch. I],

$$\begin{aligned} \omega (z,L)=\frac{1}{\pi }\mathrm{Im}\,\log \frac{z-\mathrm {i}}{\mathrm {i}z-1}, \end{aligned}$$
(21)

where the branch with \(\log 1=0\) is chosen.

5.2 Harmonic Measure for a Polygon

Assume that G is the interior domain of a polygon \(\varGamma \) with m vertices \(\{z_1,z_2,\ldots ,z_m\}\), labelled in counterclockwise orientation, and L is the segment \([z_k,z_{k+1}]\) for \(k=1,2,\ldots ,m\) (we define \(z_{m+1}=z_1\)) [(see Fig. 9 (left)].

To compute \(\omega (z,L)\), we discretize the parametrization \(\eta (t)\), \(0\le t\le 2\pi \), of the polygon \(\varGamma \) on each segment \([z_k,z_{k+1}]\) by \(n_s\) graded points on \([2(k-1)\pi /m,2k\pi /m]\). Thus, the whole polygon \(\varGamma \) is discretized by \(n=mn_s\) point \(t_i\), \(i=1,2,\ldots ,n\) in \([0,2\pi ]\) such that \(z_k=\eta (t_{1+(k-1)n_s})\) for \(k=1,2,\ldots ,m\). Then we use the method presented in Sect. 3 to compute the conformal mapping \(\zeta =\varPhi (z)\) from the interior of \(\varGamma \) onto the unit disk \(|\zeta |<1\). The mapping function \(\varPhi \) maps the two points \(z_k\) and \(z_{k+1}\) onto two points \(\zeta _1\) and \(\zeta _3\), respectively, on the unit circle \(|\zeta |=1\). The segment L is then mapped onto the arc \(\hat{L}\) on the unit circle \(|\zeta |=1\) from \(\zeta _1\) to \(\zeta _3\). Let \(\zeta _2\) be the point on the middle of \(\hat{L}\) between \(\zeta _1\) and \(\zeta _3\) so that \(\zeta _1\), \(\zeta _2\) and \(\zeta _3\) arranged in counterclockwise orientation [(see Fig. 9 (center)]. Then the Möbius transformation

$$\begin{aligned} w=\varPsi (\zeta )=\frac{(\zeta -\zeta _1)(\zeta _2-\zeta _3)-\mathrm {i}(\zeta -\zeta _3)(\zeta _2-\zeta _1)}{(\zeta -\zeta _3)(\zeta _2-\zeta _1)-\mathrm {i}(\zeta -\zeta _1)(\zeta _2-\zeta _3)} \end{aligned}$$

maps the unit disk \(|\zeta |<1\) onto the unit disk \(|w|<1\) and maps the unit circle \(|\zeta |=1\) onto the unit circle \(|w|=1\) such that the points \(\zeta _1\), \(\zeta _2\) and \(\zeta _3\) are mapped onto the points \(-\mathrm {i}\), 1 and \(\mathrm {i}\), respectively. Thus, the mapping function \(\varPsi \) maps the arc \(\hat{L}\) on \(|\zeta |=1\) onto the right half of the unit circle \(|w|=1\) [see Fig. 9 (right)].

Fig. 9
figure 9

The arc L between \(z_1\) and \(z_3\) and

Finally, the mapping function

$$\begin{aligned} w=\varPsi (\varPhi (z)) \end{aligned}$$

maps the domain G onto the disk \(|w|<1\) and maps the segment L on \(\varGamma \) onto the right half of the unit circle \(|w|=1\). Hence, by (21), the harmonic measure of L with respect to G is given by

$$\begin{aligned} \omega (z,L)=\frac{1}{\pi }\mathrm{Im}\,\log \frac{\varPsi (\varPhi (z))-\mathrm {i}}{\mathrm {i}\varPsi (\varPhi (z))-1}. \end{aligned}$$

The above method for computing the harmonic measure of a segment \(L=[z_k,z_{k+1}]\) with respect to the polygon domain G can be implemented in MATLAB as in the function hm.m where the discretization of the parametrization of the polygon is computed using the MATLAB function polygonp.m (both functions can be downloaded from https://github.com/mmsnasser/ci-simply/tree/master/harmonic

5.3 Polygon with 5 Sides

As our first example, we consider the simply connected domain G in the interior of the polygon with 5 sides (the polygon shown in Fig. 10 and the vertices of the polygon are \(2-2\mathrm {i}\), \(2+\mathrm {i}\), \(2\mathrm {i}\), \(-2\), and \(-1-3\mathrm {i}\)). We use the MATLAB function hm with \(n_s=2^{9}\) to compute the harmonic measure \(\omega (z,L)\) of each side L of the polygon with respect to the polygon domain G. The level curves of the function \(\omega (z,L)\) are shown in Fig. 10.

Fig. 10
figure 10

The level curves of the function \(\omega (z,L)\) for the polygon with 5 sides

5.4 Polygon with 13 Sides

For the second example, we consider the simply connected domain G in the interior of the polygon with 13 sides where the vertices of the polygon are 4, \(4+2\mathrm {i}\), \(2+4\mathrm {i}\), \(4\mathrm {i}\), \(-1+3\mathrm {i}\), \(-2+3\mathrm {i}\), \(-3+\mathrm {i}\), \(-3\), \(-2-2\mathrm {i}\), \(-1-3\mathrm {i}\), \(-3\mathrm {i}\), \(1-2\mathrm {i}\), and \(3-2\mathrm {i}\). The MATLAB function hm with \(n_s=2^{9}\) is used to compute the harmonic measure \(\omega (z,L)\) for each side L of the polygon with respect to the polygon domain G. The level curves of the function \(\omega (z,L)\) for the first 6 sides are shown in Fig. 11.

Fig. 11
figure 11

The level curves of the function \(\omega (z,L)\) for the polygon with 13 sides

6 Quadrilateral Domains

Let \(w=\varPhi (z)\) be the conformal mapping from the interior of the unit circle \(D=\{z\in {\mathbb C}:|z|=1\}\) onto the interior of the rectangle

$$\begin{aligned} R_r=\{w\, :\, 0<\mathrm{Re}\,w<1, \; 0<\mathrm{Im}\,w< r\} \end{aligned}$$
(22)

such that

$$\begin{aligned} \varPhi (z_1)=0,\quad \varPhi (z_2)=1,\quad \varPhi (z_3)=1+\mathrm {i}r,\quad \varPhi (z_4)=\mathrm {i}r, \end{aligned}$$

where \(z_1\), \(z_2\), \(z_3\), and \(z_4\) are points on \(\partial D\) (in the counterclockwise orientation) and \(r>0\) is an undetermined positive real constant. The constant r is known as the modulus of the quadrilateral \((D;z_1,z_2,z_3,z_4)\) and denoted by \(M(D;z_1,z_2,z_3,z_4)\). The modulus of the quadrilateral domains is invariant under conformal mappings, and hence general bounded simply connected domains can be handled by mapping them onto the unit disk with the help of method presented in Sect. 2.

If the domain \(R_r\) is known (i.e., if r is known), then we can map \(R_r\) onto the unit disk using the method described in Sect. 2. Let \(\zeta =\varPsi _1(w)\) be the conformal mapping from \(R_r\) onto the disk \(|\zeta |<1\) such that

$$\begin{aligned} \varPsi _1(\alpha )=0, \quad \varPsi '_1(\alpha )>0 \end{aligned}$$

where \(\alpha \) is a given point in \(R_r\). The mapping function \(z=\varPsi _1(w)\) maps the points 0, 1, and \(1+\mathrm {i}r\) on \(\partial R_r\) onto points \(\zeta _1\), \(\zeta _2\), and \(\zeta _3\) on the unit circle. Then the Möbius transform

$$\begin{aligned} z=\varPsi _2(\zeta )=z_3+\frac{(z_3-z_1)(z_2-z_3)(\zeta _2-\zeta _1)(\zeta -\zeta _3)}{(z_2-z_1)(\zeta _2-\zeta _3)(\zeta -\zeta _1)-(z_2-z_3)(\zeta _2-\zeta _1)(\zeta -\zeta _3)} \end{aligned}$$

maps the unit disk \(|\zeta |<1\) onto the unit disk \(|z|<1\) such that the points \(\zeta _1\), \(\zeta _2\) and \(\zeta _3\) are mapped onto the points \(z_1\), \(z_2\) and \(z_3\), respectively. Thus, the mapping function

$$\begin{aligned} z=\varPsi (w)=\varPsi _2(\varPsi _1(w)) \end{aligned}$$
(23)

maps the domain \(R_r\) onto the unit disk D such that the points 0, 1, \(1+\mathrm {i}r\) are mapped onto the points \(z_1\), \(z_2\) and \(z_3\), respectively. If \(z=\varPsi (w)\) maps also the point \(\mathrm {i}r\) onto the point \(z_4\), then \(\varPsi ^{-1}\) will be the required map, i.e.,

$$\begin{aligned} w=\varPhi (z)=\varPsi ^{-1}(z). \end{aligned}$$

6.1 Iterative Method

In this section, for a given quadrilateral \((D;z_1,z_2,z_3,z_4)\), we present an iterative method for computing the unknown constant r and the mapping function \(z=\varPsi (w)\) such that \(\varPsi (0)=z_1\), \(\varPsi (1)=z_2\), \(\varPsi (1+\mathrm {i}r)=z_3\), and \(\varPsi (\mathrm {i}r)=z_4\). First we choose an initial value \(r_0=1\), then we use the function \(\varPsi \) to map \(R_{r_0}\) to a quadrilateral \((D;z_1,z_2,z_3,z_{4,0})\) where \(z_{4,0}\) is a point on the arc \([z_3,z_1]\) containing \(z_4\) (see Fig. 12). The point \(z_{4,0}\) could be on either side of \(z_4\) on the arc \([z_3,z_1]\). We add a correction \(\varDelta _0\) to \(r_0\) to get a new approximation \(r_1\). Then we map \(R_{r_1}\) to a quadrilateral \((D;z_1,z_2,z_3,z_{4,1})\) using the function \(\varPsi \). The point \(z_{4,1}\) is now close to the point \(z_4\). We continue with this iterative method to generate a sequence of approximation \({r_0,r_1,r_2,\ldots }\) and the mapping function \(\varPsi \) maps the rectangle \(R_{r_{k}}\) to a quadrilateral \((D;z_1,z_2,z_3,z_{4,k})\). We stop the iteration when the distance (on the unit circle) between the two points \(z_4\) and \(z_{4,k}\) is small. Then, we consider \(r_{k}\) as an approximation to r.

Fig. 12
figure 12

The first two iterations

Since, for each iteration k, the point \(z_{4,k}\) is on the arc \([z_3,z_1]\), we can always choose suitable corrections \(\varDelta _{k}\) to ensure the convergence of the iterative method. In this paper, for \(k\ge 1\), we choose

$$\begin{aligned} \varDelta _k=\frac{1}{2\pi }\arg \left( \frac{z_{4,k}}{z_4}\right) . \end{aligned}$$
(24)

To accelerate the convergence of the iterative method, we introduce a factor \(\delta _k\) and we calculate \(r_k\) using the formula

$$\begin{aligned} r_{k+1}=r_{k}+\delta _{k}\varDelta _{k}, \quad k\ge 0, \end{aligned}$$
(25)

where \(r_0=1\), \(\delta _0=\delta _1=1\), and for \(k\ge 2\),

$$\begin{aligned} \delta _k = {\left\{ \begin{array}{ll} 2\delta _{k-1}, &{} \text{ if } \arg \left( \frac{z_{4,k-2}}{z_4}\right) \arg \left( \frac{z_{4,k-1}}{z_4}\right)>0{ and}\arg \left( \frac{z_{4,k-1}}{z_4}\right) \arg \left( \frac{z_{4,k}}{z_4}\right) >0, \\ \frac{1}{2}\delta _{k-1}, &{} \text{ if } \arg \left( \frac{z_{4,k-2}}{z_4}\right) \arg \left( \frac{z_{4,k-1}}{z_4}\right)<0{ and}\arg \left( \frac{z_{4,k-1}}{z_4}\right) \arg \left( \frac{z_{4,k}}{z_4}\right) <0, \\ \delta _{k-1}, &{} \text{ otherwise }. \end{array}\right. } \end{aligned}$$
(26)

In other words, when the three points \(z_{4,k-2}\), \(z_{4,k-1}\) and \(z_{4,k}\) are in the same side of \(z_4\), we double \(\delta _{k-1}\) to increase the correction added to \(r_{k}\) and so push \(z_{4,k}\) toward \(z_4\). However, when the three points \(z_{4,k-2}\), \(z_{4,k-1}\) and \(z_{4,k}\) oscillate around \(z_4\), we bisect \(\delta _{k-1}\) to reduce the correction added to \(r_{k}\). To avoid getting very long rectangle or very narrow rectangle during the iterations, we do not allow \(\delta _k\varDelta _k\) to be more than \(0.2r_k\) or less than \(-0.2r_k\).

6.2 Algorithm

The above iterative method is summarized as follows.

Initialization:

Set \(r_0=1\), \(\delta _0=\delta _1=1\).

Iterations:

For \(k=1,2,3,\ldots \), where k denotes the iteration number:

  • Map the domain interior to the rectangle with the vertices \(\{0,1,1+\mathrm {i}r_{k-1},\mathrm {i}r_{k-1}\}\) onto the unit disk D by the function \(\varPsi \) in (23) such \(\varPsi (0)=z_1\), \(\varPsi (1)=z_2\), \(\varPsi (1+\mathrm {i}r_{k-1})=z_3\).

  • Let \(z_{4,k-1}=\varPsi (\mathrm {i}r_{k-1})\).

  • Compute \(\varDelta _{k-1}\) from (24).

  • For \(k\ge 2\), compute \(\delta _{k-1}\) from (26).

  • If \(\delta _{k-1}\varDelta _{k-1}>0.2r_{k-1}\), then set \(\delta _{k-1}\varDelta _{k-1}=0.2r_{k-1}\) and \(\delta _{k-1}=\delta _{k-1}/2\).

  • If \(\delta _{k-1}\varDelta _{k-1}<-0.2r_{k-1}\), then set \(\delta _{k-1}\varDelta _{k-1}=-0.2r_{k-1}\) and \(\delta _{k-1}=\delta _{k-1}/2\).

  • The approximate value of r is updated through \(r_k=r_{k-1}+\delta _{k-1}\varDelta _{k-1}\).

  • Stop the iteration if \(|r_k-r_{k-1}|<\varepsilon \) or \(k>\mathtt{Max}\) where \(\mathtt{Max}\) is the maximum number of allowed iterations and \(\varepsilon \) is a given tolerance.

In our numerical experiments, we choose \(\mathtt{Max}=50\) and \(\varepsilon =0.5\times 10^{-13}\). The iterative method produces a sequence of numbers \(r_0,r_1,r_2,r_3,\ldots \) which converges to the required constant r. The iterative method provides us also with a conformal map \(z=\varPsi (w)\) from \(R_r\) onto the given domain D. Then the required map \(\varPhi \) is given by

$$\begin{aligned} w=\varPhi (z)=\varPsi ^{-1}(z). \end{aligned}$$

The numerical examples presented in this section show that the iterative method converges for several examples. However, no proof of convergence is available so far.

6.3 Examples

We consider the computing of the conformal mapping from the quadrilateral domains

$$\begin{aligned} (D;e^{\mathrm {i}\theta _1},e^{\mathrm {i}\theta _2},e^{\mathrm {i}\theta _3},e^{\mathrm {i}\theta _4}), \end{aligned}$$

onto rectangular domains for the following values of \(\theta _1\), \(\theta _2\), \(\theta _3\), and \(\theta _4\):

  1. 1.

    \(Q_1:\) \(\theta _1=-\pi \), \(\theta _2=-0.5\pi \), \(\theta _3=0\), \(\theta _4=0.5\pi \).

  2. 2.

    \(Q_2:\) \(\theta _1=-0.5\pi \), \(\theta _2=-0.25\pi \), \(\theta _3=0.25\pi \), \(\theta _4=0.5\pi \).

  3. 3.

    \(Q_3:\) \(\theta _1=-0.5005\pi \), \(\theta _2=-0.4995\pi \), \(\theta _3=0.4995\pi \), \(\theta _4=0.5005\pi \).

  4. 4.

    \(Q_4:\) \(\theta _1=-\pi \), \(\theta _2=-0.0001\pi \), \(\theta _3=0\), \(\theta _4=0.5\pi \).

The values of the modulus \(r=M(Q_j)\), \(j=1,2,3,4\), the number of iterations required for convergence, and the total CPU time (sec) required for convergence are listed in Table 2. For the four domains, we use \(n=2^{11}\). Orthogonal polar grids in the circular domains and their images under the conformal mapping are shown in Figs. 13, 14, 15 and 16. The points \(z_1,z_2,z_3,z_4\) on the unit circle and their images on the rectangle are shown as small colored squares such that a point \(z_k\) and its image has the same color. For \(Q_3\), \(z_1=e^{-0.5005\pi }\) and \(z_2=e^{-0.4995\pi }\) which are very close to each other. Similarly, \(z_3=e^{0.4995\pi }\) and \(z_4=e^{0.5005\pi }\) are very close to each other. The length of the arcs between \(z_1\) and \(z_2\) and between \(z_3\) and \(z_4\) is \(0.001\pi \). Thus, we can not distinguish between \(z_1\) and \(z_2\) and between \(z_3\) and \(z_4\) in Fig. 15 (left). The small arc between \(z_1\) and \(z_2\) is mapped by the conformal mapping to the lower side of the rectangle. Similarly, the small arc between \(z_3\) and \(z_4\) is mapped by the conformal mapping to the upper side of the rectangle. Although these arcs are too small, the proposed iterative method converges after only 36 iterations. In \(Q_4\), the two points \(z_2=e^{-0.0001\pi }\) and \(z_3=1\) are very close to each other where the length of the arcs between them is \(0.0001\pi \), and hence we can not distinguish between \(z_2\) and \(z_3\) in Fig. 16 (left). The small arc between \(z_2\) and \(z_3\) is mapped by the conformal mapping to the right side of the rectangle. The proposed iterative method converges after only 40 iterations.

For the three domains \(Q_2\), \(Q_3\), and \(Q_4\), the error per iteration is shown in Fig. 17. For \(Q_3\) and \(Q_4\), we have points on the unit circle that are very close to each other. This explains why the number of iterations for \(Q_3\) and \(Q_4\) is larger than the number of iterations for \(Q_2\). For \(Q_1\), the method converges after only one iteration since the exact value of r is 1 which is the same as our initial value \(r_0\).

Table 2 The numerical results
Fig. 13
figure 13

The quadrilateral domain \(Q_1\) and its image

Fig. 14
figure 14

The quadrilateral domain \(Q_2\) and its image

Fig. 15
figure 15

The quadrilateral domain \(Q_3\) and its image

Fig. 16
figure 16

The quadrilateral domain \(Q_4\) and its image

Fig. 17
figure 17

The successive error \(|r_{k}-r_{k-1}|\) for the three domains \(Q_2\), \(Q_3\), and \(Q_4\) vs the number of iteration k

6.4 Explicit Formula for the Modulus

Consider the quadrilateral domain

$$\begin{aligned} (D;1,e^{\mathrm {i}\theta _1},e^{\mathrm {i}\theta _2},e^{\mathrm {i}\theta _3}), \end{aligned}$$

which can be mapped conformally onto the rectangular domain \(R_r=\{w\, :\, 0<\mathrm{Re}\,w<1, \; 0<\mathrm{Im}\,w< r\}\) such that the point 1 is mapped to 0, \(e^{\mathrm {i}\theta _1}\) is mapped to 1, \(e^{\mathrm {i}\theta _2}\) is mapped to \(1+r\mathrm {i}\), and \(e^{\mathrm {i}\theta _3}\) is mapped to \(r\mathrm {i}\). The quadrilateral domain can be mapped also by Möbius transform onto the upper half-plane such that the point 1 is mapped to \(-1\), \(e^{\mathrm {i}\theta _1}\) is mapped to 0, \(e^{\mathrm {i}\theta _2}\) is mapped to a positive real number s, and \(e^{\mathrm {i}\theta _3}\) is mapped to \(\infty \). See Fig. 18.

Fig. 18
figure 18

The quadrilateral domain (left), the rectangular domain (center), and the upper half-plane (right)

The exact value of the positive constant s can be obtained in terms of the values of \(\theta _1\), \(\theta _2\), and \(\theta _3\). For distinct points \(z_1\), \(z_2\), \(z_3\), and \(z_4\) in \({\mathbb C}\), we define the absolute (cross) ratio by [4]

$$\begin{aligned} |z_1,z_2,z_3,z_4|=\frac{|z_1-z_3||z_2-z_4|}{|z_1-z_2||z_3-z_4|}. \end{aligned}$$

This definition can be extended if \(z_4=\infty \) by taking the limit, i.e.,

$$\begin{aligned} |z_1,z_2,z_3,\infty |=\frac{|z_1-z_3|}{|z_1-z_2|}. \end{aligned}$$

Thus, for the four points 1, \(e^{\mathrm {i}\theta _1}\), \(e^{\mathrm {i}\theta _2}\), and \(e^{\mathrm {i}\theta _3}\) on the unit circle, we have

$$\begin{aligned} |1,e^{\mathrm {i}\theta _1},e^{\mathrm {i}\theta _2},e^{\mathrm {i}\theta _3}|=\frac{\sin \left( \frac{\theta _2}{2}\right) }{\sin \left( \frac{\theta _1}{2}\right) }\frac{\sin \left( \frac{\theta _3-\theta _1}{2}\right) }{\sin \left( \frac{\theta _3-\theta _2}{2}\right) }. \end{aligned}$$

Similarly, for the four points \(-1\), 0, s, and \(\infty \) on the real line, we have

$$\begin{aligned} |-1,0,s,\infty |=1+s. \end{aligned}$$

An important property of Möbius transformations is that they preserve the absolute ratios [4], thus

$$\begin{aligned} |-1,0,s,\infty |=|1,e^{\mathrm {i}\theta _1},e^{\mathrm {i}\theta _2},e^{\mathrm {i}\theta _3}|, \end{aligned}$$

and hence the exact value of \(1+s\) is given by the formula

$$\begin{aligned} 1+s=\frac{\sin \left( \frac{\theta _2}{2}\right) }{\sin \left( \frac{\theta _1}{2}\right) }\frac{\sin \left( \frac{\theta _3-\theta _1}{2}\right) }{\sin \left( \frac{\theta _3-\theta _2}{2}\right) }. \end{aligned}$$
(27)

Let \(\varOmega _1\) be the family of curves lying in D and joining the arcs \((1,e^{\mathrm {i}\theta _1})\) and \((e^{\mathrm {i}\theta _2},e^{\mathrm {i}\theta _3})\) (see Fig. 18). Similarly, let \(\varOmega _2\) be the family of curves lying in \(R_r\) and joining the segments \((1,1+\mathrm {i}r)\) and \((\mathrm {i}r,0)\), and let \(\varOmega _3\) be the family of curves lying in the upper half-plane and joining the sets \((-1,0)\) and \((s,\infty )\). The modulus is invariant under conformal mapping [1, 13, 24] and hence [7, p. 20]

$$\begin{aligned} M(\varOmega _1)=M(\varOmega _2)=M(\varOmega _3)=\frac{1}{r}. \end{aligned}$$

The exact value of \(M(\varOmega _3)\) can be obtained also in terms of the real constant s as in the following formula from [24, Eq. (5.52) and Ex. 5.60(1)],

$$\begin{aligned} M(\varOmega _3)=\frac{\pi }{2\mu \left( \frac{1}{\sqrt{1+s}}\right) } \end{aligned}$$

were \(\mu (s)\) is the Grötzsch modulus function [2, Ch. 5]

$$\begin{aligned} \mu (s)=\frac{\pi }{2}\frac{K(s')}{K(s)}, \quad K(s)=\int _{0}^{1}\frac{dx}{\sqrt{(1-x^2)(1-s^2x^2)}}, \quad s'=\sqrt{1-s^2}. \end{aligned}$$
(28)

Consequently, the exact value of the constant r is given by

$$\begin{aligned} r=\frac{2}{\pi }\mu \left( \frac{1}{\sqrt{1+s}}\right) \end{aligned}$$
(29)

where the value of the \(s+1\) is given by (27). In this paper, the values of the function \(\mu \) are computed as described in [20].

To test the Algorithm 6.2, we fix \(\theta _1=0.5\pi \) and \(\theta _3=1.5\pi \). Then, we choose values for \(\theta _2\) between \(0.5001\pi \) and \(1.4999\pi \). The numerical results obtained with \(n=2^{13}\) are shown in Fig. 19. Figure 19 shows the relative error in the computed values of r vs \(\theta _2\) (left), the total CPU time (in seconds) required for computing each value of r vs \(\theta _2\) (center), and the successive error \(|r_{k}-r_{k-1}|\) for each value of \(\theta _2\) vs the iteration number k (right). We see from the figure, with less than 40 iterations, the successive error for the iterative method method is less than \(10^{-13}\) for all values of \(\theta _2\) except for \(\theta _2=0.5001\pi \) (red line). As expected, the relative error in the computed values of r is very small when \(\theta _2\) is a way from \(\theta _1\) and \(\theta _3\). The numerical results obtained with \(n=2^{10}\) are shown in Fig. 20.

Fig. 19
figure 19

Comparison with the exact formula (29) for \(n=2^{13}\)

Fig. 20
figure 20

Comparison with the exact formula (29) for \(n=2^{10}\)

6.5 The Crowding Phenomenon

According to [6, pp. 20–21], the term crowding was coined in 1980 [15] to describe the error/instability in numerical computing of conformal mapping. Thereafter it has become a “benchmark issue” for all numerical conformal mapping software. As explained in [21, p. 77], mapping a rectangle with aspect ratio m to the unit disk seems to be impossible for \(m=24\). Problems start already with \(m=8\) and become more serious with increasing m. The critical value of m depends on the computer floating point arithmetic with \(10<m<20\) for double precision arithmetic [6, pp. 20–21], [21, pp. 75–77].

For rectangle \(R_r\) in (22), the aspect ratio is \(m=r\) for \(r>1\) and \(m=1/r\) for \(r<1\). Assume that \(\theta _1=\pi /2\) and \(\theta _3=3\pi /2\) are fixed as above and \(\pi /2<\theta _2<3\pi /2\). In this subsection, we use the analytic example presented in Sect. 6.4 to find the critical value of r for mapping the quadrilateral \((D;1,\mathrm {i},e^{\mathrm {i}\theta _2},-\mathrm {i})\) onto the rectangle \(R_r\) with double precision arithmetic.

In view of (27), we have

$$\begin{aligned} 1+s=\frac{2}{1+\cot \left( \frac{\theta _2}{2}\right) }. \end{aligned}$$

Thus, by (29) the value of the modulus r can be written in terms of \(\theta _2\),

$$\begin{aligned} r=\frac{2}{\pi }\mu \left( \sqrt{\frac{1+\cot \left( \frac{\theta _2}{2}\right) }{2}}\right) . \end{aligned}$$
(30)

Also, the value of \(\theta _2\) can be written in terms of the modulus r,

$$\begin{aligned} \theta _2=2\cot ^{-1}\left( 2\left( \mu ^{-1}\left( \frac{r\pi }{2}\right) \right) ^2-1\right) . \end{aligned}$$
(31)

The values of the modulus r obtained with the formula (30) for \(\pi /2+10^{-15}<\theta _2<3\pi /2-10^{-15}\) are shown in Fig. 21 (left). Similarly, Fig. 21 (right) shows values \(\theta _2\) obtained with the formula (31) for \(1/12<r<12\). We see from Fig. 21 (right) that the values of \(\theta _2\) become very close to \(\theta _3=3\pi /2\) even for small values of r. In fact, for \(r=12\), the value of \(\theta _2\) obtained with formula (31) satisfies

$$\begin{aligned} \frac{3\pi }{2}-\theta _2=1.776\times 10^{-15}. \end{aligned}$$

Similarly, for \(r=1/12\), we have

$$\begin{aligned} \theta _2-\frac{\pi }{2}=1.776\times 10^{-15}. \end{aligned}$$
Fig. 21
figure 21

The values of r in terms of \(\theta _2\) (left) and the values of \(\theta _2\) in terms of r (right)

For further investigation, we use the MATLAB symbolic toolbox to obtain more accurate results for the formulas (30) and (31). For \(r\ge 1\), the values of \(\log _{10}(3\pi /2-\theta _2)\) are shown in Fig. 22 (left). It is clear from Fig. 22 (left) that, up to double precision accuracy of the computer, \(\theta _2=3\pi /2\) for the value of r as small as \(r=13\). Similarly, for \(0<r\le 1\), the values of \(\log _{10}(\theta _2-\pi /2)\) are shown in Fig. 22 (right). Up to double precision accuracy of the computer, it follows from Fig. 22 (right) that \(\theta _2=\pi /2\) for \(r=1/13\). As a consequence, up to double precision accuracy of the computer, mapping a rectangle onto a quadrilateral \((D;1,\mathrm {i},e^{\mathrm {i}\theta _2},-\mathrm {i})\) is impossible when the aspect ratio of the rectangle is as small as \(r=13\).

Fig. 22
figure 22

The relation between r and \(\theta _2\) for \(r>1\) (left) and \(0<r<1\) (right)

We see from Fig. 22 (left) that the relation between r and \(\log _{10}(3\pi /2-\theta _2)\) is linear for \(r>1\). We use MATLAB function polyfit to find the coefficients of the line, and hence, we can estimate

$$\begin{aligned} \theta _2(r)\approx \frac{3\pi }{2}-32.3663566817311\times 10^{-1.36452159123521r}, \quad r>1. \end{aligned}$$
(32)

Similarly, Fig. 22 (right) shows that there is a linear relationship between 1/r and \(\log _{10}(\theta _2-\pi /2)\) for \(0<r<1\). By using MATLAB function polyfit to find the coefficients of the line, we can estimate

$$\begin{aligned} \theta _2(r)\approx \frac{\pi }{2}+32.3665310118084\times 10^{-1.36452172896714/r}, \quad 0<r<1. \end{aligned}$$
(33)

Equation (32) illustrates how fast the value of \(\theta _2\) approaches \(\theta _3=3\pi /2\) even for small values of r, \(r>1\). Similarly, Eq. (33) illustrates that the value of \(\theta _2\) approaches \(\theta _1=\pi /2\) even for small values of 1/r, \(0<r<1\).