1 Introduction

As pointed out by Ransford and Rostand, the computation of the logarithmic capacity of compact subsets of the complex plane is in general a “notoriously hard” problem [24, p. 1499]. This is particularly true for non-connected sets consisting of many, or even infinitely many, components. An important and frequently studied example in this context is given by the classical Cantor middle third set and its generalizations, for which no analytic formula for their logarithmic capacity is known. Among the different approaches to computing the logarithmic capacity of these fractal sets are the method of Ransford and Rostand which uses linear programming [24]; a method of Banjai, Embree, and Trefethen based on Schwarz-Christoffel mappings (also see [24]); the study of the spectral theory of orthogonal polynomials by Krüger and Simon [13]; and our algorithm based on conformal maps onto lemniscatic domains [14]. Further numerical methods for computing the logarithmic capacity of compact sets can be found, for example, in [4, 5, 23, 25].

In this paper, we derive and study an alternative method for numerically approximating the logarithmic capacity of compact sets consisting of very many “small” components, which uses the charge simulation method (CSM) [1, 2, 20], also known as the method of fundamental solutions [3, 30]. In the CSM, Green’s function of the complement of the given compact set is approximated by a linear combination of logarithmic potentials which depend on so-called charge points inside each component of the set. Solving the (dense) linear algebraic system for the coefficients of the linear combination then yields the desired approximation of the logarithmic capacity.

For the types of sets we consider, choosing one charge point in each component is sufficient. A similar approach has been used in [12], where the CSM was used to solve the harmonic image inpainting problem. The linear algebraic system that needs to be solved therefore is significantly smaller than in methods that are based on discretizing the boundaries of each component (for example, our own boundary integral equation (BIE) method presented in [14]). We solve the linear algebraic systems arising in the CSM iteratively with the GMRES method [26]. In order to speed up the iteration, we use the centrosymmetric structure of the system matrices, the fast multipole method [9] for computing matrix-vector products, and a problem-adapted preconditioner. We apply the new method to generalized Cantor sets and the Cantor dust. These sets consist of infinitely many components, and we compute approximations of their logarithmic capacities by extrapolating from computed logarithmic capacities of finite approximations that consist of many components. Timing comparisons with our method from [14] show the computational efficiency, and comparisons of the computed capacity values with other published results demonstrate the high accuracy of the new method.

The paper is organized as follows. In Section 2, we present the necessary background on the logarithmic capacity and the CSM. In Section 3, we study the approximation of the logarithmic capacity for generalized Cantor sets, and in Section 4 we do the same for the Cantor dust. The paper ends with concluding remarks in Section 5.

2 Logarithmic capacity and the CSM

Let \(E \subseteq \mathbb {C}\) be a compact set and denote \(E^c := (\mathbb {C} \cup \{\infty \}) \setminus E\). Suppose that the unbounded connected component G of \(E^c\) is regular in the sense that it possesses a Green’s function \(g = g_E = g_G\). Then, the logarithmic capacity of E, denoted by \(\mathrm {cap}(E)\), satisfies

$$\begin{aligned} \mathrm {cap}(E) = \underset{z \rightarrow \infty }{\lim }\, \exp (\log |{z}| - g(z)); \end{aligned}$$
(1)

see, e.g., [22, Theorem 5.2.1], [14, Eq. (2.2)], or Szegő’s original article [28]. Recall that Green’s function with pole at infinity of G is the real-valued function such that

  1. 1.

    g is harmonic in \(G \setminus \{ \infty \}\) and \(g(z) - \log |{z}|\) is bounded in a neighborhood of infinity,

  2. 2.

    g is continuous in \(\overline{G} \setminus \{ \infty \}\) and vanishes on \(\partial G\).

We assume that the boundary of the unbounded domain G with \(\infty \in G\) consists of a finite number of Jordan curves, in which case Green’s function g with pole at infinity of G exists [7, p. 41].

In the CSM, a harmonic function is approximated by a linear combination of fundamental solutions of the Laplace equation, which are logarithmic potentials in the two-dimensional case [3, 30]. In our setting, Green’s function g is approximated by a function of the form

$$\begin{aligned} h(z) = c + \sum \limits _{j=1}^N p_j \log |z-w_j|, \quad z \in G, \end{aligned}$$
(2)

where \(c, p_1, \ldots , p_N\) are undetermined real constants, and where \(w_1, \ldots , w_N \in \mathbb {C} \setminus \overline{G}\) are pairwise distinct. The points \(w_1, \ldots , w_N\) are called the charge points, and the coefficients \(p_1, \ldots , p_N\) the charges [1]. The function h in (2) is harmonic in \(\mathbb {C} \setminus \{ w_1, \ldots , w_N \}\). Since g behaves as \(\log |{z}|\) for \(z \rightarrow \infty\), we require

$$\begin{aligned} \sum \limits _{j=1}^N p_j = 1. \end{aligned}$$
(3)

The coefficients \(c, p_1, \ldots , p_N\) in (2) are usually determined from the boundary condition \(g(z) = 0\) on \(\partial G\), by imposing the condition \(h(z)=0\) in a finite set of collocation points on \(\partial G\); see, e.g., [1,2,3, 20, 30]. The number of collocation points is usually at least N+1, so that this procedure leads to a square or overdetermined linear algebraic system [30, p. 12]. Below we will use a slightly different approach to obtain a linear algebraic system for the coefficients.

In view of (1), the approximation h of g yields

$$\begin{aligned} \mathrm {cap}(E) = \underset{z \rightarrow \infty }{\lim }\, \exp (\log |{z}| - g(z)) \approx \underset{z \rightarrow \infty }{\lim }\, \exp (\log |{z}| - h(z)) = e^{-c}. \end{aligned}$$
(4)

The following result gives an error bound for this approximation.

Lemma 2.1

Let \(E \subseteq \mathbb {C}\) be compact such that the unbounded connected component G of \(E^c\) is bounded by m Jordan curves, and let g be Green’s function with pole at infinity of G. Let h be as in (2) with (3), then

$$\begin{aligned} |\mathrm {cap}(E) - e^{-c}| \le e^{-c} \left( M + \frac{1}{2} M^2 e^M \right) , \end{aligned}$$
(5)

where \(M := |{\hat{c}-c}| \le \max _{\zeta \in \partial G} |{h(\zeta )}|\) and \(\hat{c} := \lim _{z \rightarrow \infty } (g(z) - \log |{z}|) \in \mathbb {R}\).

Proof

As above, let \(w_1\in \mathbb {C}\setminus \overline{G}\) be the first charge point. The auxiliary functions

$$\begin{aligned} u(z) = g(z) - \log |{z - w_1}|, \quad v(z) = h(z) - \log |{z - w_1}|, \end{aligned}$$

are continuous in \(\overline{G}\) and harmonic in G, including at infinity with \(u(\infty ) = \hat{c}\) and \(v(\infty ) = c\). Since \(w_1 \notin \overline{G}\), the Möbius transformation \(\varphi (z) = 1/(z - w_1)\) maps G onto the bounded domain \(R = \varphi (G)\), whose boundary consists of m Jordan curves. The functions \(u \circ \varphi ^{-1}\) and \(v \circ \varphi ^{-1}\) are harmonic in R and continuous in \(\overline{R}\). Then, by the maximum principle for harmonic functions on bounded domains (see, e.g., [22, Theorem 1.1.8]),

$$\begin{aligned} \left| {\left( u \circ \varphi ^{-1}\right) (w) - \left( v \circ \varphi ^{-1}\right) (w)}\right| \le \underset{\omega \in \partial R}{\max } \,\left| {\left( u \circ \varphi ^{-1}\right) (\omega ) - \left( v \circ \varphi ^{-1}\right) (\omega )}\right| , \quad w \in \overline{R}. \end{aligned}$$

This yields

$$\begin{aligned} |{u(z) - v(z)}| \le \underset{\zeta \in \partial G}{\max }\, |{u(\zeta ) - v(\zeta )}| = \underset{\zeta \in \partial G}{\max } \,|{g(\zeta ) - h(\zeta )}| = \underset{\zeta \in \partial G}{\max }\, \,|{h(\zeta )}|, \quad z \in \overline{G}. \end{aligned}$$

The last equality holds since g vanishes on \(\partial G\). Taking the limit \(z\rightarrow \infty\) we obtain \(|{\hat{c} - c}| \le \max _{\zeta \in \partial G}\, |{h(\zeta )}|\). The estimate (5) follows from \(\mathrm {cap}(E) = e^{-\hat{c}}\) and Taylor’s formula.\(\square\) 

On the right-hand side of (5), we can replace the (in general unknown) quantity M by the upper bound given by the maximum of the (known) function h on \(\partial G\). In this way, we obtain a computable upper bound on the error. We will give an example in Section 3.2.

Remark 2.2

We give another interpretation of the approximation \(e^{-c} \approx \mathrm {cap}(E)\) in the case \(p_1, \ldots , p_N > 0\). Then, \(h(z)>0\) is equivalent to \(\prod _{j=1}^N |{z - w_j}|^{p_j} > e^{-c}\). Since the real numbers \(p_1, \ldots , p_N>0\) are not necessarily rational, the set \(\mathcal {L}= \{ z \in \mathbb {C} \cup \{ \infty \} : h(z) > 0 \}\) is the exterior of a generalized lemniscate. This is an unbounded domain (with \(\infty \in \mathcal {L}\)), and h is Green’s function with pole at infinity of \(\mathcal {L}\). In particular, \(e^{-c}\) is the logarithmic capacity of the compact set \(\mathcal {L}^c\). If \(\mathcal {L}\) has connectivity N, it is a lemniscatic domain; see [18, 27] and references therein as well as Walsh’s original article [29]. Otherwise, the connectivity of \(\mathcal {L}\) is lower, and \(\mathcal {L}\) is the exterior of a level curve of Green’s function of a lemniscatic domain. Thus, in the method we propose here, the original domain \(G = E^c\) is approximated by the domain \(\mathcal {L}\), and the method returns \(\mathrm {cap}(\mathcal {L}^c)\) as approximation of \(\mathrm {cap}(G^c) = \mathrm {cap}(E)\).

If not all charges are positive, then the set \(\{ z \in \mathbb {C} \cup \{ \infty \} : h(z) > 0 \}\) is a canonical domain of the more general form in [29, Theorem 3].

In the following two sections, we will apply the CSM in order to compute (approximations of) the logarithmic capacity of generalized Cantor sets (Section 3) and the Cantor dust (Section 4).

3 Generalized cantor sets

In this section, we start with setting up the CSM for the generalized Cantor sets. Next, we give an analytic example (illustrating this approach and Lemma 2.1), and study the structure and properties of the matrices arising in the CSM. We then show how the resulting linear algebraic systems can be solved iteratively, and finally we present the results of numerical computations of the logarithmic capacity of generalized Cantor sets.

3.1 Setting up the CSM

Fix some \(q\in (0,1/2)\), let \(E_0 := [0,1]\), and define recursively

$$\begin{aligned} E_k:=qE_{k-1}\cup \left( q E_{k-1}+ 1-q \right) , \quad k\ge 1. \end{aligned}$$
(6)

Thus, the set \(E_k\) is obtained by removing the middle \(1-2q\) from each interval of the set \(E_{k-1}\); see Fig. 1 for \(E_1\) (left) and \(E_2\) (right) corresponding to \(q=1/4\). Then, the generalized Cantor set \(E=E(q)\) is defined as

$$\begin{aligned} E:=\bigcap \limits _{k=0}^{\infty } E_k. \end{aligned}$$
(7)

For \(q=1/3\), we obtain the classical Cantor middle third set. The limiting cases are \(E=\{0,1\}\) for \(q=0\) and \(E=[0,1]\) for \(q=1/2\).

Fig. 1
figure 1

The sets \(E_1, D_1\) (left) and \(E_2, D_2\) (right) for \(q=1/4\)

The set \(E_k\) consists of \(m = 2^k\) disjoint intervals \(I_{k,j}\), \(j = 1, 2, \ldots , m\), numbered from left to right. The intervals have the same length

$$\begin{aligned} |{I_{k,1}}| = |{I_{k,2}}| = \ldots = |{I_{k,m}}| = q^k. \end{aligned}$$
(8)

Denote the midpoint of \(I_{k,j}\) by \(w_{k,j}\). Let

$$\begin{aligned} r_k = \frac{1}{2} q^k = w_{k,1}, \end{aligned}$$
(9)

then

$$\begin{aligned} 0< r_k = w_{k,1}< w_{k,2}< \cdots< w_{k,m} = 1-r_k<1. \end{aligned}$$
(10)

Instead of the sets \(E_k\) consisting of closed intervals, we will use sets \(D_k\) consisting of closed disks in the CSM. More precisely, let

$$\begin{aligned} D_0 := \left\{ z \in \mathbb {C} \,:\, \left| {z - \frac{1}{2}}\right| \le \frac{1}{2} \right\} , \end{aligned}$$

and define recursively

$$\begin{aligned} D_k:=qD_{k-1}\cup \left( qD_{k-1}+1-q\right) , \quad k\ge 1. \end{aligned}$$

Then, \(D_k\) consists of \(m=2^k\) disjoint disks \(D_{k,j}\) with the centers \(w_{k,j}\), \(j=1,2,\ldots ,m\), i.e.,

$$\begin{aligned} D_k=\bigcup _{j=1}^m D_{k,j}; \end{aligned}$$

see Fig. 1 for \(D_1\) (left) and \(D_2\) (right) corresponding to \(q=1/4\). All of the m disks have the same radius \(r_k\) from (9). Since \(E_0 = D_0 \cap \mathbb {R}\), we obtain \(E_k = D_k \cap \mathbb {R}\) for all \(k \ge 1\) by induction. Moreover, we have the following result.

Theorem 3.1

In the notation established above,

$$\begin{aligned} \bigcap \limits _{k=0}^{\infty } D_k = E \quad \text {and} \quad \mathrm {cap}(E) = \underset{k \rightarrow \infty }{\lim }\, \mathrm {cap}(D_k). \end{aligned}$$

Proof

Clearly, \(E \subseteq D := \bigcap _{k=0}^\infty D_k\). Next, we show that if \(z \in \mathbb {C} \setminus E\), then \(z \notin D\). If \(z \in \mathbb {R}\setminus E\), then there exists \(k \in \mathbb {N}\) such that \(z \notin E_k = D_k \cap \mathbb {R}\supseteq D \cap \mathbb {R}\), hence \(z \notin D\). If \(z \in \mathbb {C} \setminus \mathbb {R}\), i.e., \(|{{\mathrm {Im}}(z)}| > 0\), then there exists \(k \in \mathbb {N}\) such that \(0< r_k < |{{\mathrm {Im}}(z)}|\), which shows that \(z \notin D_k \supseteq D\). Together we obtain \(D = E\). Finally, \(\mathrm {cap}(E) = \lim _{k \rightarrow \infty } \mathrm {cap}(D_k)\) by [22, Theorem 5.1.3], since \(D_0 \supseteq D_1 \supseteq D_2 \supseteq \ldots\) are compact and \(E = \bigcap _{k=0}^\infty D_k\).\(\square\) 

Our overall strategy for computing an approximation of \(\mathrm {cap}(E)\), where the set E consists of infinitely many components, is to first approximate \(\mathrm {cap}(D_k)\) for reasonably many and large values of k with the CSM. Then, we extrapolate from the computed approximations of \(\mathrm {cap}(D_k)\) to obtain an approximation of \(\lim _{k \rightarrow \infty } \mathrm {cap}(D_k) = \mathrm {cap}(E)\).

The set \(G_k := D_k^c = (\mathbb {C}\cup \{\infty \}) \setminus D_k\) is an unbounded multiply connected domain of connectivity m with

$$\begin{aligned} \partial G_k = C_{k,1}\cup \cdots \cup C_{k,m}, \end{aligned}$$

where \(C_{k,j} := \partial D_{k,j}\) is the circle with center \(w_{k,j}\) and radius \(r_k\) for \(j=1,2,\ldots ,m\).

As described in Section 2, we approximate \(g_k\), Green’s function with pole at infinity of \(G_k\), with the CSM by

$$\begin{aligned} h_k(z) = c_k + \sum \limits _{\ell = 1}^m p_{k,\ell } \log |{z - w_{k, \ell }}|, \quad z \in G_k, \end{aligned}$$
(11)

with

$$\begin{aligned} \sum \limits _{\ell =1}^m p_{k,\ell } = 1. \end{aligned}$$
(12)

In the CSM for unbounded multiply connected domains, we usually choose many charge points inside each boundary component \(C_{k,j}\), \(j=1,2,\ldots ,m\) [2, 20]. However, because \(r_k\) is very small for large \(m=2^k\), we choose only one point inside \(C_{k,j}\), which is its center \(w_{k,j}\).

Remark 3.2

The fact that we use just a single charge point for each boundary component \(C_{k,j}\) is an essential difference to other discretization-based methods for computing the logarithmic capacity of sets consisting of many components. For example, our own BIE method presented in [14] “opens up” the intervals of \(E_k\) to obtain a compact set of the same capacity, but bounded by smooth Jordan curves. The computation of the logarithmic capacity then is based on discretizing the \(m=2^k\) boundary curves using n points on each of them. Consequently, for the same k, the linear algebraic systems in the method presented here are smaller by a factor of n compared to those in [14]. This is one of the main reasons for the very significant computational savings that we obtain with the new method; see Section 3.5. Using only a single charge point for each boundary component can be justified by the fact that the boundary components become very small when k increases. This is illustrated in [12] where, as mentioned in the Introduction, a similar approach has been used. (In terms of the current paper, the derivation of the system matrix in [12] assumes that the value of \(r_k\) in the (14) is negligible in comparison with \(|w_{k,j}-w_{k,\ell }|\) for \(j\ne \ell\).)

Green’s function \(g_k\) of \(G_k\) vanishes on the boundary \(\partial G_k\). This does not hold for the approximation \(h_k\). Instead, we require that \(h_k\) has zero mean on each circle \(C_{k,j}\), i.e.,

$$\begin{aligned} \frac{1}{2 \pi \mathrm {i}} \int _0^{2 \pi } h_k(\eta _{k,j}(t)) \, \mathrm {d}t = 0, \quad j = 1, \ldots , m, \end{aligned}$$
(13)

with the parametrization \(\eta _{k,j}(t)=w_{k,j}+r_k e^{\mathrm {i}t}\), \(0 \le t \le 2 \pi\). On the circle \(C_{k,j}\),

$$\begin{array}{l}h_k(\eta _{k,j}(t)) = c_k + \sum \limits _{\ell = 1}^m p_{k,\ell } \log \left| {w_{k,j} + r_k e^{\mathrm {i}t} - w_{k, \ell }}\right| ,\\ \qquad \qquad \; \;\; =c_k+p_{k,j}\log r_k+\overset m{\underset{\ell\neq j}{\sum_{\ell=1}}}p_{k,\ell}\log\left|w_{k,j}+r_ke^{\mathrm it}-w_{k,\ell}\right|,\quad j=1,\dots,m,\end{array}$$
(14)

for all \(t \in [{0, 2 \pi }]\). For \(\ell \ne j\), the function \(\log |{z - w_{k,\ell }}|\) is harmonic in the disk \(D_{k,j} = \{ z \in \mathbb {C} : |{z-w_{k,j}|} \le r_k \}\), hence

$$\begin{aligned} \frac{1}{2\pi }\int _{0}^{2\pi }\log \left| w_{k,j}+r_ke^{ \mathrm {i}t}-w_{k,\ell }\right| \, \mathrm {d}t = \log |{w_{k,j} - w_{k, \ell }}| \end{aligned}$$

by the mean value property of harmonic functions; see, e.g., [31, Theorem 4.6.7] or [22, Theorem 1.1.6]. Thus, integrating (14) and requiring (13) yields the linear algebraic system

$$\begin{aligned} c_k+p_{k,j}\log r_k+ \overset{m}{\underset{\ell \ne j}{\underset{\ell =1}{\sum }}} p_{k,\ell }\log |w_{k,j}-w_{k,\ell }|=0, \quad j=1,2,\ldots ,m. \end{aligned}$$
(15)

We will now consider (15) for a fixed size \(m=2^k\), and therefore we will drop the index k in the following for simplicity. We write (15) in the form

$$\begin{aligned} A\mathbf {p}=c\,\mathbf {e}, \end{aligned}$$
(16)

where \(\mathbf {p}=[p_{1},\dots ,p_{m}]^T\), \(\mathbf {e}=[1,\dots ,1]^T\in \mathbb {R}^m\), and

$$\begin{aligned} A = - \begin{bmatrix} \log r &{}\log |w_{1}-w_{2}| &{}\cdots &{}\log |w_{1}-w_{m-1}| &{}\log |w_{1}-w_{m}| \\ \log |w_{2}-w_{1}| &{}\log r &{}\cdots &{}\log |w_{2}-w_{m-1}| &{}\log |w_{2}-w_{m}| \\ \vdots &{}\vdots &{}\ddots &{}\vdots &{}\vdots \\ \log |w_{m-1}-w_{1}| &{}\log |w_{m-1}-w_2| &{}\cdots &{}\log r &{}\log |w_{m-1}-w_m| \\ \log |w_{m}-w_{1}| &{}\log |w_{m}-w_{2}| &{}\cdots &{}\log |w_{m}-w_{m-1}| &{}\log r \\ \end{bmatrix}. \end{aligned}$$
(17)

Note that \(A \in \mathbb {R}^{m,m}\) and that \(m = 2^k\) is even.

Theorem 3.3

For \(k \ge 1\), the entries \(a_{ij}\) of A satisfy

$$\begin{aligned} \log \frac{1}{1 - 2r} \le a_{ij} \le \log \frac{1}{r}, \quad 1 \le i, j \le m, \end{aligned}$$
(18)

and they decay away from the diagonal in each row and column, i.e.,

$$\begin{aligned}&a_{i,1}< \ldots< a_{i, i-1} < a_{i,i}, \quad a_{i,i}> a_{i, i+1}> \ldots > a_{i,m}, \end{aligned}$$
(19)
$$\begin{aligned}&a_{1,j}< \ldots< a_{j-1, j} < a_{j,j}, \quad a_{j,j}> a_{j+1, j}> \ldots > a_{m,j}, \end{aligned}$$
(20)

for \(1 \le i, j \le m\).

Proof

Since \(0< r = w_1< w_2< \ldots < w_m\), we have that

$$\begin{aligned} |{w_i - w_1}|> |{w_i - w_2}|> \ldots> |{w_i - w_{i-1}}| > r, \quad r< |{w_i - w_{i+1}}|< \ldots < |{w_i - w_m}|, \end{aligned}$$

which is equivalent to (19). Since A is symmetric, (19) is equivalent to (20).

Let \(1 \le i, j \le m\). The upper bound in (18) follows from \(a_{ij} \le a_{ii} = \log (1/r)\). For the lower bound, notice that \(|{w_i - w_j}| \le 1 - 2r\) by (10), and that \(1 - 2r > 0\) if and only if \(k \ge 1\). We then obtain \(a_{ij} \ge \log \frac{1}{1 - 2r}\) for \(i \ne j\), which also holds for \(a_{ii}\), since \(a_{ii}\) is the largest element in the row.\(\square\) 

We will continue under the assumption that A is nonsingular, which will be justified below; see Section 3.3 as well as Fig. 3 and the corresponding discussion. Note that (12) can be written as \(\mathbf {e}^T\mathbf {p}=1\), and therefore multiplying (16) from the left with \(\mathbf {e}^TA^{-1}\) yields \(1 = \mathbf {e}^T\mathbf {p} = c\,\mathbf {e}^T A^{-1} \mathbf {e}\) or, equivalently,

$$\begin{aligned} c=\frac{1}{\mathbf {e}^TA^{-1}\mathbf {e}}. \end{aligned}$$
(21)

Thus, in order to compute \(e^{-c}\), which is our approximation of \(\mathrm {cap}(E)\) (see (4)), we need to compute (or accurately estimate) the quantity \(\mathbf {e}^TA^{-1}\mathbf {e}\), preferably without explicitly inverting the full matrix A. One option is to numerically solve the linear algebraic system

$$\begin{aligned} A\mathbf {x}=\mathbf {e}, \end{aligned}$$
(22)

and then to compute \(c = 1/(\mathbf {e}^T \mathbf {x})\).

3.2 An analytic example: two disks

In this section, we study the accuracy of the CSM approximation and the tightness of the bounds in Lemma 2.1 on a simple example where an exact formula for the logarithmic capacity is known. We consider the set \(D_1\) consisting of the union of the two disks with the centers

$$\begin{aligned} w_1=\frac{1}{6}, \quad w_2=\frac{5}{6}, \end{aligned}$$

and the radius r, where \(0<r\le w_1=1/6\). Denote by

$$\begin{aligned} G=\{ z : |z-1/6|>r \text { and } |z-5/6|>r \} \end{aligned}$$

the complement of \(D_1\) in the extended complex plane. Then, \(z \mapsto z-\frac{1}{2}\) maps G onto the domain \(\widehat{G}=\{z\,:\,|z+1/3|>r \text { and } |z-1/3|>r\}\), and it follows from [22, Theorem 5.2.3] and [27, Theorem 4.2] (see also [14, Example 4.6]) that

$$\begin{aligned} \mathrm {cap}(D_1)=\mathrm {cap}(\widehat{G}^c) =\frac{2K}{\pi }\sqrt{(1/3)^2-r^2}\sqrt{2L(1+L^2)} =\frac{2K}{3\pi }\sqrt{1-9r^2}\sqrt{2L(1+L^2)}, \end{aligned}$$
(23)

where

$$\begin{aligned} K = K(L^2) = \int _0^1 \frac{1}{\sqrt{(1-t^2) (1-L^4 t^2)}} \, \mathrm {d}t, \quad L = 2 \rho \prod \limits _{k=1}^\infty \left( \frac{1 + \rho ^{8k}}{1 + \rho ^{8k-4}} \right) ^2, \end{aligned}$$

and

$$\begin{aligned} \rho = \frac{\sqrt{1/3 + r} - \sqrt{1/3 - r}}{\sqrt{1/3 + r} + \sqrt{1/3 - r}} = \frac{\sqrt{1 + 3r} - \sqrt{1 - 3r}}{\sqrt{1 + 3r} + \sqrt{1 - 3r}} =\frac{3r}{1 + \sqrt{1 - 9r^2}}. \end{aligned}$$

Thus, for \(r\ll 1/6\), we have

$$\begin{aligned} \rho \approx 3r/2, \quad L\approx 2\rho \approx 3r\ll 1, \end{aligned}$$

hence

$$\begin{aligned} K = K(L^2) \approx K(0)=\frac{\pi }{2}, \end{aligned}$$

and now (23) implies that

$$\begin{aligned} \mathrm {cap}(D_1) \approx \frac{1}{3}\times 1\times \sqrt{2L} \approx \frac{1}{3} \sqrt{6r} =\sqrt{\frac{2r}{3}} \quad \text{(for } r\ll 1/6\text{). } \end{aligned}$$
(24)

For the CSM, we set up the linear algebraic system (22) with the system matrix

$$\begin{aligned} A= - \begin{bmatrix} \log r &{}\log |w_1-w_2|\\ \log |w_2-w_1| &{}\log r \\ \end{bmatrix} = \begin{bmatrix} -\log r &{}-\log \frac{2}{3}\\ -\log \frac{2}{3} &{}-\log r \\ \end{bmatrix} \end{aligned}$$

from (17), so that

$$\begin{aligned} A^{-1} = \frac{1}{(\log r)^2- \left(\log \frac{2}{3}\right)^2} \begin{bmatrix} -\log r &{} \log \frac{2}{3}\\ \log \frac{2}{3} &{}- \log r \\ \end{bmatrix}, \end{aligned}$$

and hence (see (21))

$$\begin{aligned} c=-\frac{(\log r)^2- \left( \log \frac{2}{3}\right) ^2}{2\left( \log r - \log \frac{2}{3}\right) }= -\frac{1}{2}\left( \log r + \log \frac{2}{3}\right) = - \frac{1}{2} \log \frac{2 r}{3}. \end{aligned}$$
(25)

Consequently, the CSM estimate is

$$\begin{aligned} \mathrm {cap}(D_1)\approx \exp \left( -c\right) =\exp \left( \frac{1}{2} \log \frac{2r}{3} \right) =\sqrt{\frac{2r}{3}}. \end{aligned}$$
(26)

Comparing (24) and (26) shows that the CSM gives very accurate results for \(r \ll 1/6\). This conclusion is illustrated in Fig. 2, where the (blue) solid line shows that the error between the exact capacity (23) and the CSM estimate (26) is \(2.87\times 10^{-18}\) for \(r=10^{-7}\), but increases to 0.01 for \(r=1/6\).

We next consider the bound (5) from Lemma 2.1, i.e., the inequality

$$\begin{aligned} \left| {\mathrm {cap}(D_1) - e^{-c}}\right| \le e^{-c} \left( M + \frac{1}{2} M^2 e^M \right) , \end{aligned}$$
(27)

where \(M = |{\hat{c} - c}| \le \max _{\zeta \in \partial G} |{h(\zeta )}|=\max _{\zeta \in \partial D_1} |{h(\zeta )}|\), and

$$\begin{aligned} h(z) = c + p_1 \log |z-w_1| + p_2\log |z-w_2|, \quad z \in G. \end{aligned}$$

Here, c is given by (25), \(\mathrm {cap}(D_1)\) is given by (23), \(\hat{c} = - \log (\mathrm {cap}(D_1))\), and \([p_1,p_2]^T\) is the solution of the linear algebraic system (16), i.e.,

$$\begin{aligned} \begin{bmatrix} -\log r &{}-\log \frac{2}{3}\\ -\log \frac{2}{3} &{}-\log r \\ \end{bmatrix} \begin{bmatrix} p_1\\ p_2 \\ \end{bmatrix}= \begin{bmatrix} c\\ c \\ \end{bmatrix}. \end{aligned}$$

Thus, in view of (25), we have \(p_1=p_2=1/2\), and hence

$$\begin{aligned} h(z) = \frac{1}{2}\log \frac{3}{2r} + \frac{1}{2} \log \left| {z-\frac{1}{6}}\right| + \frac{1}{2} \log \left| {z-\frac{5}{6}}\right| , \end{aligned}$$

which yields

$$\begin{aligned} M \le \underset{\zeta \in \partial D_1}{\max }\, |{h(\zeta )}| = \frac{1}{2}\log \frac{3}{2}+\frac{1}{2}\log \left( r+\frac{2}{3}\right) = \frac{1}{2}\log \left( \frac{3}{2}r+1\right) . \end{aligned}$$

Using this upper bound on M in (27), we obtain

$$\begin{aligned} \left| {\mathrm {cap}(D_1) - e^{-c}}\right| \le \sqrt{\frac{r}{6}} \log \left( \frac{3}{2}r+1\right) \left( 1 + \frac{1}{4} \log \left( \frac{3}{2}r+1\right) \sqrt{\frac{3}{2}r+1} \right) =: \hat{M}. \end{aligned}$$
(28)

The values of the computable upper bound \(\hat{M}\) on the absolute error are shown by the dotted line in Fig. 2. We observe that for larger values of r the bound becomes quite tight. Figure 2 also shows the error bound \(e^{-c} \left( M + \frac{1}{2} M^2 e^M\right)\), which we can compute in this example since \(\mathrm {cap}(D_1)\) is known analytically. Clearly, the bound is very tight in this example.

Fig. 2
figure 2

The absolute error \(|{\mathrm {cap}(D_1) - e^{-c}}|\) between the exact capacity \({\mathrm{cap}}(D_1)\) given by (23) and the CSM estimate \(e^{-c}\) in (26), the error bound from Lemma 2.1, and the upper bound \(\hat{M}\) in (28)

3.3 Structure and properties of the system matrices

In Section 3.2, we have considered the case of just two disks, and we were able to invert the \((2\times 2)\)-matrix of the linear algebraic system (22) explicitly. For approximating the logarithmic capacity of the generalized Cantor sets by extrapolating from the values \(\mathrm {cap}(D_k)\) for reasonably large k, we will have to solve much larger linear algebraic systems, and thus we need to apply more sophisticated techniques for the numerical solution of (22).

Our first observation in this direction is that the matrix A in (17) is symmetric as well as centrosymmetric, which means that

$$\begin{aligned} J_mAJ_m=A,\quad \text{ where }\quad J_m=\left[ \begin{array}{lll} &{} &{} 1\\ &{} \cdot ^{\displaystyle \cdot ^{\displaystyle \cdot }} &{} \\ 1 &{} &{} \end{array}\right] \in \mathbb {R}^{m\times m}. \end{aligned}$$

Because of the centrosymmetry, the matrix A can be block-diagonalized with an orthogonal transformation at no additional cost; see [6]. If we partition

$$\begin{aligned} A = \begin{bmatrix} A_{11} &{} A_{12}\\ A_{21} &{} A_{22} \end{bmatrix}, \quad \text{ where }\quad A_{11},A_{22}\in \mathbb {R}^{\frac{m}{2}\times \frac{m}{2}}, \end{aligned}$$

then

$$\begin{aligned} A=Q\begin{bmatrix} B &{} 0\\ 0 &{} C\end{bmatrix}Q^T,\quad \text{ where }\quad Q=\frac{1}{\sqrt{2}}\begin{bmatrix}I_{m/2} &{} I_{m/2}\\ J_{m/2} &{} -J_{m/2}\end{bmatrix} \quad \text{ with }\quad Q^TQ=QQ^T=I_m, \end{aligned}$$

and

$$\begin{aligned} B=A_{11}+A_{12}J_{m/2},\quad C=A_{11}-A_{12}J_{m/2}. \end{aligned}$$
(29)

Since A is symmetric, the matrices \(B,C\in \mathbb {R}^{\frac{m}{2}\times \frac{m}{2}}\) are also symmetric. If we partition

$$\begin{aligned} \mathbf {x}=\begin{bmatrix}\mathbf {x}_1\\ \mathbf {x}_2\end{bmatrix}, \end{aligned}$$

and use the orthogonal decomposition of A, then (22) can be transformed via a left-multiplication with \(Q^T\) into the equivalent system

$$\begin{aligned} \begin{bmatrix} B &{} 0 \\ 0 &{} C \end{bmatrix} \begin{bmatrix}\mathbf {x}_1+J_{m/2}\mathbf {x}_2\\ \mathbf {x}_1-J_{m/2}\mathbf {x}_2 \end{bmatrix}= \begin{bmatrix}2 {\mathbf {e}}\\ \mathbf {0}\end{bmatrix}, \end{aligned}$$

where \(\mathbf {e}=[1,\dots ,1]^T\in \mathbb {R}^{m/2}\). Since we assume that A and thus C is nonsingular, the second block row implies that \(\mathbf {x}_1=J_{m/2}\mathbf {x}_2\), and hence it remains to solve the system

$$\begin{aligned} B \mathbf {y}=\mathbf {e}, \end{aligned}$$
(30)

where \(\mathbf {y} = \mathbf {x}_1\), to obtain \(c = 1/(2 \mathbf {e}^T \mathbf {y})\). In finite precision, we obtain a computed approximate solution \(\widetilde{\mathbf {y}} \approx \mathbf {y}\) of (30), which leads to

$$\begin{aligned} c \approx \frac{1}{2\mathbf {e}^T\widetilde{\mathbf {y}}}. \end{aligned}$$

Figure 3 shows the 2-norm condition numbers computed in MATLABFootnote 1 of A and B for \(q=1/3\) (i.e., the classical Cantor middle third set) as functions of \(m = 2^k\). We observe that the condition numbers grow linearly in m. A similar behavior of the condition numbers can be seen in the Cantor dust example (see Fig. 10), and has been observed in [10, Figure 6], where the matrix F in [10, Eq. (36)] has the same form as our matrices A and B. According to [10, p. 398], such behavior of the condition numbers in the CSM is expected, since the matrices “resemble a discretization of the kernel of a single-layer potential whose inverse is the Laplacian operator.” Analyses of the invertibility of matrices in other applications of the CSM can be found in [19].

Fig. 3
figure 3

2-norm condition numbers of \(A \in \mathbb {R}^{m,m}\) and \(B \in \mathbb {R}^{m/2, m/2}\) from (17) and (29) for \(q=1/3\) as functions of \(m = 2^k\), \(k = 2,3, \ldots , 12\)

From a numerical point of view, solving (30) is clearly preferable over solving (22), since B has only half the size of A, while both matrices are dense and have essentially the same condition number (cf. Fig. 3). We will solve the linear algebraic system (30) using iterative methods that require one matrix-vector product with B in every step; see Section 3.4. Because of the structure of the entries of B, this multiplication can be performed using the fast multipole method (FMM) [9]. Using the definition of B in (29), each matrix-vector product of the form \(B\mathbf{y} = A_{11}{} \mathbf{y}+A_{12}J_{m/2}{} \mathbf{y}\) requires two applications of the FMM. The following result shows that B can be written in a form so that only one application of the FMM is required.

Lemma 3.4

The entries of B are given by

$$\begin{aligned} b_{ij} = {\left\{ \begin{array}{ll} -\log (2r\sqrt{z_{i}}), &{} i=j,\\ -\log |z_{i}-z_{j}|, &{} i\ne j,\quad 1\le i,j\le m/2, \end{array}\right. } \end{aligned}$$

where \(z_{i} := (w_{i}-1/2)^2\) for \(i=1,\dots , m/2\).

Proof

First note that by definition the entries of \(A_{11}\) are given by

$$\begin{aligned} a_{ij} = {\left\{ \begin{array}{ll} -\log r, &{} i=j,\\ -\log |w_{i}-w_{j}|, &{} i\ne j,\quad 1\le i,j\le m/2, \end{array}\right. } \end{aligned}$$

and the entries of \(A_{12}\) are given by

$$\begin{aligned} \hat{a}_{ij} = -\log |w_{i}-w_{m/2+j}|, \quad 1\le i,j\le m/2. \end{aligned}$$

By construction, the \(w_{j}\), \(j=1,2,\ldots ,m\), are real numbers in the interval (0, 1), which are symmetric about 1/2. Furthermore, we have

$$\begin{aligned} w_{m/2+j} = 1-q+w_{j}, \quad w_{m/2+1-j}+w_{j} = q,\quad j=1,\dots , m/2. \end{aligned}$$

Thus,

$$\begin{aligned} \hat{a}_{ij} = -\log |w_{i}-w_{j}-1+q|, \quad 1\le i,j\le m/2, \end{aligned}$$

and hence the entries \(\tilde{a}_{ij}\) of the matrix \(A_{12}J_{m/2}\) are given by

$$\begin{aligned} \tilde{a}_{ij} = \hat{a}_{i,m/2+1-j} = -\log |w_{i}-w_{m/2+1-j}-1+q| = -\log |w_{i}+w_{j}-1|, \quad 1\le i,j\le m/2. \end{aligned}$$

Finally, by (29), the entries \(b_{ij}\) of B are given for \(i=j\) by

$$\begin{aligned} b_{ii}=a_{ii} + \tilde{a}_{ii} = -\log r-\log |2w_{i}-1| = -\log \left| 2r(w_{i}-1/2)\right| , \end{aligned}$$

and for \(i\ne j\) by

$$\begin{aligned} b_{ij}=a_{ij}+\tilde{a}_{ij}=-\log |w_{i}-w_{j}|-\log |w_{i}+w_{j}-1|, =-\log \left| (w_{i}-1/2)^2-(w_{j}-1/2)^2\right| , \end{aligned}$$

which completes the proof.\(\square\) 

From this lemma, we have

$$\begin{aligned} B =- {\small \begin{bmatrix} \log (2r\sqrt{z_{1}}) &{} \log |z_{1}-z_{2}| &{}\cdots &{}\log |z_{1}-z_{m/2-1}| &{}\log |z_{1}-z_{m/2}| \\ \log |z_{2}-z_{1}| &{}\log (2r\sqrt{z_{2}}) &{}\cdots &{}\log |z_{2}-z_{m/2-1}| &{} \log |z_{2}-z_{m/2}| \\ \vdots &{} \vdots &{} \ddots &{} \vdots &{} \vdots \\ \log |z_{m/2-1}-z_{1}| &{}\log |z_{m/2-1}-z_{2}| &{} \cdots &{}\log (2r\sqrt{z_{m/2-1}}) &{}\log |z_{m/2-1}-z_{m/2}| \\ \log |z_{m/2}-z_{1}| &{} \log |z_{m/2}-z_{2}| &{}\cdots &{}\log |z_{m/2}-z_{m/2-1}| &{}\log (2r\sqrt{z_{m/2}}) \\ \end{bmatrix},} \end{aligned}$$
(31)

and we can easily see that B is symmetric (as already mentioned above), but not centrosymmetric.

Theorem 3.5

For \(k \ge 2\), the entries \(b_{ij}\) of B satisfy

$$\begin{aligned} \log \frac{1}{q (1-q)}< \log \frac{1}{(1-q) (q - 2r)} \le b_{ij} \le \log \frac{1}{r (1 - 2q + 2r)} < \log \frac{1}{r (1-2q)}, \end{aligned}$$
(32)

and they decay away from the diagonal in each row and column, i.e.,

$$\begin{aligned}&b_{i,1}< \ldots< b_{i, i-1} < b_{i,i}, \quad b_{i,i}> b_{i, i+1}> \ldots > b_{i,m/2}, \end{aligned}$$
(33)
$$\begin{aligned}&b_{1,j}< \ldots< b_{j-1, j} < b_{j,j}, \quad b_{j,j}> b_{j+1, j}> \ldots > b_{m/2,j}, \end{aligned}$$
(34)

for \(1 \le i, j \le m/2\).

Proof

In (32), we need \(q - 2r > 0\), which is equivalent to \(r < q/2\) and thus to \(k \ge 2\).

Decay. Since

$$\begin{aligned} 0< r=w_1< w_2< \ldots< w_{m/2}=q-r< q < \frac{1}{2}, \end{aligned}$$
(35)

we have

$$\begin{aligned} 1/4> z_1> z_2> \ldots> z_{m/2} > 0. \end{aligned}$$
(36)

This implies

$$\begin{aligned} |{z_i - z_1}|> |{z_i - z_2}|> \ldots > |{z_i - z_{i-1}}|, \quad |{z_i - z_{i+1}}|< \ldots < |{z_i - z_{m/2}}|, \end{aligned}$$

and equivalently

$$\begin{aligned} b_{i,1}< \ldots < b_{i, i-1}, \quad b_{i, i+1}> \ldots > b_{i,m/2}. \end{aligned}$$

It remains to show \(b_{i, i \pm 1} < b_{ii}\), which is equivalent to \(|{z_i - z_{i \pm 1}}| > 2 r \sqrt{z_i}\). Note that

$$\begin{aligned} |{z_i - z_j}| = |{w_i - w_j}| |{w_i + w_j - 1}| = |{w_i - w_j}| (1 - (w_i + w_j)). \end{aligned}$$

Since \(|{w_i - w_{i-1}}| > r\) and \(w_i + w_{i-1}< 2 w_i < 1\), we have \(|{z_i - z_{i-1}}| > r (1 - 2 w_i) = 2 r \sqrt{z_i}\), i.e., \(b_{i, i-1} < b_{ii}\). Since \(|{w_i - w_{i+1}}| > 2r\), we have

$$\begin{aligned} |{z_i - z_{i+1}}|> 2r (1 - (w_i + w_{i+1})) > r (1 - 2 w_i). \end{aligned}$$

The last estimate is equivalent to \(1 > 2 w_{i+1}\), which holds by (35). This, together with \(2 r \sqrt{z_i} = r |{2 w_i - 1}| = r (1 - 2 w_i)\), establishes \(b_{ii} > b_{i, i+1}\). We thus have shown (33). Since B is symmetric, (33) is equivalent to (34).

Bounds for \(b_{ij}\). Let \(1 \le i, j \le m/2\). To establish the upper bound, it is enough to show \(b_{ii} \le \log \frac{1}{r(1 - 2q + 2r)}\), which is equivalent to \(1 - 2q + 2r \le 2 \sqrt{z_i} = 1 - 2 w_i\) and to \(w_i \le q-r\), which holds by (35). Next, we show the lower bound for \(b_{ij}\). It follows from (36) that

$$\begin{aligned} |z_i-z_j|\le |z_1-z_{m/2}|. \end{aligned}$$

We have \(z_1=(0.5-w_1)^2=(0.5-r)^2\) and \(z_{m/2}=(0.5-w_{m/2})^2=(0.5-q+r)^2\) by (35). Thus,

$$\begin{aligned} |z_i-z_j|\le \left| (0.5-r)^2-(0.5-q+r)^2\right| =|(q-2r)(1-q)| \end{aligned}$$

and hence, for \(i\ne j\),

$$\begin{aligned} b_{ij}=-\log |z_i-z_j|\ge -\log |(q-2r)(1-q)|. \end{aligned}$$

The latter inequality holds also for \(b_{ii}\) since it is the largest element in its row. The rest is clear.\(\square\) 

Let \(\hat{\mathbf {y}}=B\mathbf {y}\) where \(\mathbf {y}=[y_{1},\dots ,y_{m/2}]^T\) and \(\hat{\mathbf {y}}=[\hat{y}_{1},\dots ,\hat{y}_{m/2}]^T\). In general, computing the vector \(\hat{\mathbf {y}}\) requires \(O(m^2)\) operations. However, for real \(\mathbf {y}\), the form of B in (31) yields

$$\begin{aligned} \hat{y}_j = -\log \left( 2r\sqrt{z_j}\right) y_j - {\mathrm {Re}}\left( \overset{m/2}{\underset{\ell \ne j}{\underset{\ell =1}{\sum }}}\, y_\ell \log (z_{j}-z_{\ell }) \right) , \quad j=1,2,\ldots ,m/2, \end{aligned}$$
(37)

and hence computing the vector \(\hat{\mathbf {y}}\) requires one application of the FMM, which uses only O(m) operations; see [9]. In MATLAB, the sum in (37) can be computed fast and efficiently using the MATLAB function cfmm2dpart from the toolbox FMMLIB2D [8]. Using the input parameters \(\mathbf{y}\), \(\mathbf{z}=[z_{1},\dots ,z_{m/2}]^T\) and r, the vector \(\hat{\mathbf {y}}=B\mathbf {y}\) can be computed by calling the following MATLAB function:

figure a

Here, iprec is the precision flag for the FMM. In our computations, we use iprec=4, which means that the tolerance for the FMM is \(0.5\times 10^{-12}\).

3.4 Iteratively solving the linear algebraic systems

As mentioned above, the matrix B is symmetric and nonsingular. Thus, we can apply the MINRES method [21] (which is well defined for symmetric nonsingular matrices) and the GMRES method [26] (which is well defined for all nonsingular matrices) in order to solve the system (30) iteratively.Footnote 2 The two methods are mathematically equivalent and minimize the Euclidean residual norm over a sequence of Krylov subspaces in every step. More precisely, when started with the initial vector \(\mathbf {y}_0=0\), they generate iterates

$$\begin{aligned} \mathbf {y}_j\in \mathcal{K}_j(B,\mathbf {e})=\mathrm{span}\left\{ \mathbf {e},B \mathbf {e},\dots , B^{j-1}\mathbf {e}\right\} , \end{aligned}$$

such that

$$\begin{aligned} \Vert \mathbf {e}-B\mathbf {y}_j\Vert _2=\underset{\mathbf {z}\in \mathcal{K}_j(B,\mathbf {e})}{\min }\, \Vert \mathbf {e}-B\mathbf {z}\Vert _2. \end{aligned}$$

Each method is based on generating an orthonormal basis of the Krylov subspaces \(\mathcal{K}_j(B,\mathbf {e})\) for \(j=1,2,\dots\), and this process requires one matrix-vector product with B in every step, which can be computed using the FMM as described above.

The essential difference between the two methods is that MINRES uses the symmetry of the system matrix in order to generate the orthonormal Krylov subspace bases with short (3-term) recurrences, while GMRES is based on full recurrences. Thus, the computational cost of a MINRES step (in terms of memory requirements and floating point operations) is significantly lower than of a GMRES step. However, methods based on short recurrences explicitly perform the orthogonalization only with respect to a few recent vectors. In finite precision computations, this can lead to a much faster overall loss of orthogonality, and even a loss of rank in the computed Krylov subspace “basis.” Such loss of rank corresponds to a delay of convergence; see, e.g., [16] or [15, Section 5.9] for comprehensive analyses of this phenomenon and further references.

In the application in this paper, the observed delay of convergence is so severe that MINRES is not competitive with GMRES, although it is based on short recurrences.

Example 3.6

We apply the MATLAB implementations of MINRES and GMRES with the initial vector \(\mathbf {y}_0=0\) to linear algebraic systems of the form (30) for \(q=1/3\) with \(m=2^{14}\) and \(m=2^{16}\). The matrix-vector products with B are performed using the function By_eval described above, and hence our function calls to the iterative methods are

figure b

Our tolerance for the relative residual norm is tol=1e-12 and we use MAXIT=400 as the maximal number of iterations, but this number is not reached in our experiment. In Fig. 4, we plot the relative residual norms of the two methods. In exact arithmetic, these norms are identical. In our finite precision computation, we observe that MINRES suffers from a significant delay of convergence. This delay not only leads to many more iterative steps until the tolerance is reached, but also to a much longer computation time in comparison with GMRES:

 

GMRES time (s)

MINRES time (s)

\(m=2^{14}\)

1.91

3.14

\(m=2^{16}\)

8.00

15.46

Fig. 4
figure 4

Relative residual norms of GMRES (solid) and MINRES (dashed) for the linear algebraic systems (30) for \(q=1/3\) with \(m=2^{14}\) (left) and \(m=2^{16}\) (right) in Example 3.6

As a consequence of these numerical observations, we have decided to use GMRES in all our experiments.

We will now describe a problem-adapted technique to precondition the system (30), which will lead to an even faster convergence of GMRES. Consider the matrix A in (17) for a fixed size \(m=2^k\). Because of the symmetric distribution of the \(w_j\), \(j=1,\dots ,m\), for any fixed \(j=1,\dots ,k-1\), we can write this matrix in the block form

$$\begin{aligned} A =- \begin{bmatrix} D &{}D_{12} &{}\cdots &{}D_{1p} \\ D_{21} &{}D &{}\ddots &{} \vdots \\ \vdots &{}\ddots &{}\ddots &{} D_{p-1,p} \\ D_{p1} &{} \cdots &{} D_{p,p-1} &{} D \\ \end{bmatrix}, \quad \text {where}\,\, D\in \mathbb {R}^{2^j\times 2^j}, \text {and}\,\, p=2^{k-j}. \end{aligned}$$
(38)

By construction, the entries of A decay row- and column-wise with their distance from the diagonal; see Theorem 3.3. Hence, the “block diagonal part” \(P_m:= {{\,\mathrm{diag}\,}}(D,\dots ,D)\) contains the largest entries of A. This block diagonal matrix is easy to invert when j is not too large, since it requires just one inversion of D. Hence, it can be used as a preconditioner for the linear algebraic system (22).

From (29), we have \(B=A_{11}+A_{12}J_{m/2}\), where \(A_{11}\) is the leading \(\left( \frac{m}{2}\times \frac{m}{2}\right)\)-block of A, and \(A_{12}\) is the upper off-diagonal block, which overall contains smaller entries than \(A_{11}\). The “block diagonal part” of \(A_{11}\) contains p/2 copies of D. We use this matrix

$$\begin{aligned} P_{m/2} := {{\,\mathrm{diag}\,}}(D,\dots ,D) \in \mathbb {R}^{\frac{m}{2}\times \frac{m}{2}} \end{aligned}$$

as our preconditioner for the system (30) with B, i.e., instead of (30) we apply GMRES to the system

$$\begin{aligned} P_{m/2}^{-1}B{\mathbf{y}}=P_{m/2}^{-1}{\mathbf{e}}. \end{aligned}$$
(39)

The effectiveness of this approach is illustrated next.

Example 3.7

We consider the same linear algebraic systems as in Example 3.6. Figure 5 shows the relative residual norms of GMRES applied to the system \(B\mathbf {y}=\mathbf {e}\) (solid) and the preconditioned system \(P_{m/2}^{-1}B\mathbf {y}=P_{m/2}^{-1}\mathbf {e}\) (dotted), where we have used \(j=4\) for the preconditioner \(P_{m/2}\), and have inverted the matrix \(D\in \mathbb {R}^{16\times 16}\) explicitly using MATLAB’s inv function. The solid curves in Fig. 5 are the same as in Fig. 4. We observe that the preconditioning reduces the number of GMRES iterations to reach the relative residual norm tolerance of \(10^{-12}\) by more than \(50\%\), and that the required times are reduced accordingly:

 

GMRES time (s)

Preconditioned GMRES time (s)

\(m=2^{14}\)

1.91

0.98

\(m=2^{16}\)

8.00

3.83

The effect of the preconditioner on the matrix condition number can be seen in Fig. 6, where we show the condition numbers of \(P_m^{-1}A\) and \(P_{m/2}^{-1}B\) as functions of m for several values of j. The results presented in Fig. 7 suggest that

$$\begin{aligned} \frac{\kappa \left( P_m^{-1}A\right) }{\kappa (A)} \approx \frac{1}{2^{j+1/2}} \quad \text{ and }\quad \frac{\kappa \left( P_{m/2}^{-1}B\right) }{\kappa (B)} \approx \frac{1}{2^{j+1/2}}. \end{aligned}$$

Clearly, the condition numbers of the preconditioned matrices decrease with increasing j, while a larger j leads to higher computational costs for applying the preconditioner. In our experiments, we found that \(j=4\) represents a good trade-off value. For this value, we have \(\frac{\kappa (P_m^{-1}A)}{\kappa (A)} \approx 0.045\) and \(\frac{\kappa (P_{m/2}^{-1}B)}{\kappa (B)} \approx 0.045\).

Fig. 5
figure 5

Relative residual norms of GMRES (solid) and preconditioned GMRES (dotted) with \(m=2^{14}\) (left) and \(m=2^{16}\) (right) in Example 3.7

Fig. 6
figure 6

2-norm condition numbers of the matrices \(P_m^{-1}A \in \mathbb {R}^{m,m}\) and \(P_{m/2}^{-1}B \in \mathbb {R}^{m/2, m/2}\) as functions of \(m = 2^k\) for \(q=1/3\), \(j=1,2,3,4\), and \(k=j+1,j+2, \ldots ,12\)

Fig. 7
figure 7

\(\kappa (P_m^{-1}A)/\kappa (A)\) and \(\kappa (P_{m/2}^{-1}B)/\kappa (B)\) as functions of \(m = 2^k\) for \(q=1/3\), \(j=1,2,3,4\), and \(k=5,6, \ldots ,12\)

Using the preconditioner \(P_{m/2}\), the above MATLAB function By_eval is modified as follows:

figure c

3.5 Computing the logarithmic capacity of generalized Cantor sets

We now present the results of numerical computations with the method described above for computing the logarithmic capacity of generalized Cantor sets. Our method requires the parameters q (for the definition of the generalized Cantor set) and k (for the level of the approximation) as its only inputs; see (6). These parameters completely determine the preconditioned linear algebraic system (39) that we solve with GMRES, where the matrix-vector products are computed using the FMM as described above. As in the examples above, the tolerance for the relative GMRES residual norm is \(10^{-12}\). GMRES then returns a computed approximation \(\widetilde{\mathbf{y}} \approx {\mathbf{y}}\), and we report the value \(\exp (-1/(2{\mathbf{e}}^T \widetilde{\mathbf{y}}))\) as \(\mathrm {cap}(D_k)\) in our tables below.

Example 3.8

(Classical Cantor middle third set) We consider the classical Cantor middle third set, i.e., the set (7) with \(q=1/3\) in (6). Table 1 gives the approximate values of \(\mathrm {cap}(D_k)\) for \(k=5,6\dots ,20\) computed by the method presented in this paper, as well as the computation time (in seconds), and the number of GMRES iteration steps.

Table 1 Computed approximations of \(\mathrm {cap}(D_k)\) for \(q = 1/3\), timings, and number of GMRES iteration steps using the new proposed method for Example 3.8
Table 2 Computed approximations of \(\mathrm {cap}(E_k)\) and \(\mathrm {cap}(D_k)\) for \(q = 1/3\), and timings using the BIE method [14] for Example 3.8

We compare these results with the computed values and the corresponding timings for the BIE method from [14]. Approximating \(\text{cap}(E_k)\) with the BIE method requires a preliminary conformal map to “open up” the intervals of \(E_k\) to obtain a compact set of the same capacity, but bounded by smooth Jordan curves. Then, the method is used to compute the capacity of this new set. For approximating \({\text{cap}}(D_k)\) with the BIE method, no preliminary conformal map is needed since \(\partial D_k\) is smooth. For both cases, we take \(n=2^6\) discretization points on each of the \(m=2^k\) boundary curves, and the obtained results are presented in Table 2. (The value \(n = 2^6\) was chosen, since with this value the BIE method yields the logarithmic capacity of a single disk and of two disks with equal radius with a relative error of order \(10^{-16}\).) Furthermore, by Tables 1 and 2, there is a good agreement between the approximations of \(\text{cap}(D_k)\) obtained by the BIE method from [14] and the method presented in this paper. This agreement improves as k increases. As described in Remark 3.2, the new method is significantly more efficient, since it uses only a single charge point for each component of \(D_k\). In addition, we have used the special (centrosymmetric) structure of the system matrices as well as a preconditioner for GMRES to speed up the computations.

The estimate of \(\mathrm {cap}(E)\) in [14] was obtained by extrapolation from the computed values for \(\mathrm {cap}(E_k)\). Using the same approach here, we start by noting that the differences

$$\begin{aligned} d_k= \mathrm {cap}(D_k)-\mathrm {cap}(D_{k+1}),\quad k=5,6,\dots ,19, \end{aligned}$$

decrease linearly on a logarithmic scale. We store these 15 values in the vector d, and use the MATLAB command p=polyfit(5:19,log(d),1)) to compute a linear polynomial \(p(x)=p_1x+p_2\) of best approximation in the least squares sense for the values \(\log (d_k)\). The computed coefficients are

$$\begin{aligned} p_1=-0.671894676421546,\quad p_2=-2.39546038319728. \end{aligned}$$

Starting with our computed approximation of \(\mathrm {cap}(D_{20})\), we can then approximate \(\mathrm {cap}(D_k)\) for \(k\ge 21\) by extrapolation, i.e.,

$$\begin{aligned} \mathrm {cap}(D_k)\approx \mathrm {cap}(D_{20})-\sum \limits _{j=20}^{k-1}\exp (p(j)),\quad k\ge 21. \end{aligned}$$

Since \(\exp (p(52))<10^{-16}\), we use this formula with \(k=52\) for our final estimate of \(\mathrm {cap}(E)\) which is shown in Table 3. Applying the same extrapolation approach to the values obtained by the BIE method (see Table 2) yields the estimates of \(\mathrm {cap}(E)\) presented in Table 3.

Table 3 Estimates of the logarithmic capacity of the classical Cantor middle third set. Matching digits are underlined

Our estimate (obtained with the new proposed method) agrees in its first eight significant digits with the one that was “strongly suggested” by Ransford [23, p. 568]. All these estimates agree in their first six significant digits, and they are all contained in the interval

$$\begin{aligned}{}[0.22094810685,0.22095089228], \end{aligned}$$

which according to Ransford and Rostand [24] contains \(\mathrm {cap}(E)\).

Example 3.9

(Generalized Cantor set) We consider now the numerical approximation of \(\mathrm {cap}(E)\) for general \(q\in (0,0.5)\). The limiting cases are \(E=\{0,1\}\) with \(\mathrm {cap}(E)=0\) (for \(q=0\)) and \(E=[0,1]\) with \(\mathrm {cap}(E)=0.25\) (for \(q=0.5\)). For several values of q, we approximate the values of \(\mathrm {cap}(D_k)\) with the CSM and extrapolate these values to obtain an approximation of \(\mathrm {cap}(E)\) using the same approach as described in Example 3.8. The results are given in Table 4, where the values of q are chosen from the values considered in [14, Example 4.14] (note that q here is denoted by r in [14]). We also state the values of \(\mathrm {cap}(E)\) computed in [14] using a discretization with \(k=12\) (corresponding to \(m=4096\)), and then extrapolation. We observe that the estimates obtained by the two methods agree at least in their first four significant digits (matching digits are underlined).

Table 4 The computed approximations of \(\mathrm {cap}(E)\) for the generalized Cantor set; see Example 3.9

It was suggested in [24] that the values of \(\mathrm {cap}(E)\) can be approximated by

$$\begin{aligned} \mathrm {cap}(E)\approx f(q)=q(1-q)-\frac{q^3}{2}\left( \frac{1}{2}-q\right) ^{3/2}. \end{aligned}$$
(40)

Figure 8 shows the graph of the function f(q) as well as our computed approximations of \(\mathrm {cap}(E)\). The maximum distance between the values of f(q) and the computed approximations of \(\mathrm {cap}(E)\) from the third column of Table 4 is \(7.56\times 10^{-5}\), which is close to the results reported in [14].

Fig. 8
figure 8

The computed logarithmic capacity \({\mathrm {cap}}(E)\) (blue circles) and f(q) from (40) (dashed); see Example 3.9

4 Cantor dust

The Cantor dust is a generalization of the Cantor set to dimension two. We compute the logarithmic capacity of the generalized Cantor dust, and start by setting up the CSM, similarly to our approach in Section 3.

Let \(q \in (0,1/2)\) and \(F_0 = [0,1] \times [0,1]\). Define recursively

$$\begin{aligned} F_k := qF_{k-1}\cup \left( qF_{k-1}+1-q\right) \cup \left( qF_{k-1} +(1-q)\mathrm {i}\right) \cup \left( qF_{k-1}+(1-q)(1+\mathrm {i})\right) , \quad k \ge 1, \end{aligned}$$

i.e., \(F_k = E_k \times E_k\) with \(E_k\) from (6). Then, the generalized Cantor dust F is defined as

$$\begin{aligned} F:=\bigcap \limits _{k=0}^{\infty } F_k. \end{aligned}$$
(41)

Note that \(F_k\) consists of \(m = 4^k\) closed square regions, say \(S_{k,1}, S_{k,2}, \ldots , S_{k,m}\); see Fig. 9 for \(q=1/4\) with \(k=1\) (left) and \(k=2\) (right). The diameter of each of the squares \(S_{k,1},S_{k,2},\ldots ,S_{k,m}\) is \(2r_k\), where

$$\begin{aligned} r_k:=\frac{1}{\sqrt{2}}q^k. \end{aligned}$$
(42)

For \(j=1,2,\ldots ,m\), denote the center of \(S_{k,j}\) by \(w_{k,j}\). To be precise, we order the points \(w_{k,j}\) recursively by \(w_0 = (1+\mathrm {i})/2\) and

$$\begin{aligned} w_k = [w_{k,j}] = [q w_{k-1}, q w_{k-1} + (1-q), q w_{k-1} + (1-q) \mathrm {i}, q w_{k-1} + (1-q) (1 + \mathrm {i})] \in \mathbb {C}^{1, 4^k} \end{aligned}$$
(43)

for \(k \ge 1\). Let \(D_{k,j}\) be the disk with center \(w_{k,j}\) and radius \(r_k\), and let

$$\begin{aligned} D_k = \bigcup _{j=1}^m D_{k,j}; \end{aligned}$$

see Fig. 9 for \(q=1/4\) with \(k=1\) (left) and \(k=2\) (right).

Fig. 9
figure 9

The Cantor dust with \(q=1/4\) for \(k=1\) (left) and \(k=2\) (right)

Theorem 4.1

Let F be the Cantor dust defined by (41), then

$$\begin{aligned} \bigcap _{k=0}^{\infty } D_k = F \quad \text {and} \quad \mathrm {cap}(F) = \underset{k \rightarrow \infty }{\lim }\, \mathrm {cap}(D_k). \end{aligned}$$

Proof

By construction, \(F_k \subseteq D_k\) for all \(k \in \mathbb {N}_0\); hence, \(F \subseteq \bigcap _{k=0}^\infty D_k\). If \(z \in \mathbb {C} \setminus F\), then there exists \(k_0 \in \mathbb {N}\) with \(z \notin F_{k_0}\). In particular, \(d := {{\,\mathrm{dist}\,}}(z, F_{k_0}) > 0\) since \(F_{k_0}\) is compact. Since the maximal distance from a point on \(\partial D_{k,j}\) to the inscribed square \(S_{k,j}\) is \(r_k - \frac{1}{2} q^k = \frac{\sqrt{2} - 1}{2} q^k \rightarrow 0\) for \(k \rightarrow \infty\), we have \(z \notin D_{k_1}\) for a sufficiently large \(k_1\), hence \(z \notin \bigcap _{k=0}^\infty D_k\). Finally, \(\mathrm {cap}(F) = \lim _{k \rightarrow \infty } \mathrm {cap}(D_k)\) by [22, Theorem 5.1.3], since \(D_0 \supseteq D_1 \supseteq D_2 \supseteq \ldots\) are compact and \(F = \bigcap _{k=0}^\infty D_k\).\(\square\) 

As in Section 3, we first approximate \(\mathrm {cap}(D_k)\) for several k with the CSM, and then extrapolate these values to obtain an approximation of \(\mathrm {cap}(F)\). With the choice (42) of \(r_k\), and to make sure the disks \(D_{k,j}\), \(j = 1, \ldots , 4^k\), are disjoint, we will consider here only the case \(q<\sqrt{2}-1\). Then, the complement of \(D_k\), denoted by \(G_k := D_k^c = (\mathbb {C}\cup \{\infty \}) \setminus D_k\), is an unbounded multiply connected domain of connectivity \(m = 4^k\) with

$$\begin{aligned} \partial G_k = \partial D_{k,1}\cup \cdots \cup \partial D_{k,4^k}. \end{aligned}$$

We parametrize the circle \(\partial D_{k,j}\) by \(\eta _{k,j}(t) = w_{k,j} + r_k e^{\mathrm {i}t}\), \(0\le t\le 2\pi\), for \(j=1,2,\ldots ,4^k\).

As described in Section 3, we approximate Green’s function of \(G_k\) by a function \(h_k\) of the form (11) with (12). The condition (13) leads to the linear algebraic system (16) with the matrix \(A \in \mathbb {R}^{m,m}\) from (17), now with \(m = 4^k\) instead of \(2^k\), which is symmetric and centrosymmetric. Then,

$$\begin{aligned} \mathrm {cap}(D_k) \approx e^{-c_k} \quad \text {where} \quad c_k= \frac{1}{\mathbf {e}^T A^{-1} \mathbf {e}}. \end{aligned}$$

As before, we solve \(A \mathbf {x} = \mathbf {e}\) to obtain \(c_k\) as \(c_k = 1/(\mathbf {e}^T \mathbf {x})\). Note that the estimates of the entries of A in Theorem 3.3 do not carry over from the case of the generalized Cantor set to the generalized Cantor dust.

We will now fix \(m = 4^k\) and drop the index k in the following for simplicity. The matrix A for the generalized Cantor dust has the same structure as the matrix A for the generalized Cantor set. In particular, using that A is centrosymmetric, we can reduce the linear system \(A \mathbf {x} = \mathbf {e}\) of size m to the system

$$\begin{aligned} B { {y}} = { {e}} \end{aligned}$$

of size m/2, where B is given by (29), and obtain

$$\begin{aligned} c = \frac{1}{2 \mathbf {e}^T \mathbf {y}} \approx \frac{1}{2\mathbf {e}^T \widetilde{\mathbf {y}}}, \end{aligned}$$

where \(\widetilde{\mathbf {y}}\) is a computed approximate solution to \(B \mathbf {y} = \mathbf {e}\), as described in Section 3.3. The following analog of Lemma 3.4 for the generalized Cantor dust allows to compute a multiplication with B with a single application of the FMM.

Lemma 4.2

The entries of \(B = \begin{bmatrix} b_{ij} \end{bmatrix} \in \mathbb {R}^{m/2, m/2}\) are given by

$$\begin{aligned} b_{ij} = {\left\{ \begin{array}{ll} -\log |{2r_k \sqrt{z_{i}}}|, &{} i=j, \\ -\log |z_{i}-z_{j}|, &{} i\ne j, \quad 1\le i,j\le m/2, \end{array}\right. } \end{aligned}$$

where \(z_{i} := (w_i - (1+\mathrm {i})/2)^2\) for \(i=1,\dots , m/2\), and \(r_k\) is given by (42).

Proof

The entries of the matrix \(A_{11}\) are given by

$$\begin{aligned} a_{ij} ={\left\{ \begin{array}{ll} -\log r_k, &{} i=j,\\ -\log |w_{i}-w_{j}|, &{} i\ne j, \end{array}\right. } \end{aligned}$$

for \(1\le i,j\le m/2\). The entries of the matrix \(A_{12}\) are given by

$$\begin{aligned} \hat{a}_{ij} = -\log |w_{i}-w_{m/2+j}|, \quad 1\le i,j\le m/2. \end{aligned}$$

Unlike the generalized Cantor set, here the points \(w_j\), \(j=1,2,\ldots ,m\), are complex numbers in the square domain \((0,1)\times (0,1)\). By the definition (43) of the points \(w_{j}\), we have

$$\begin{aligned} w_{m/2+j} = (1-q)\mathrm {i}+w_{j}, \quad w_{m/2+1-j}+w_{j} = 1+q\mathrm {i}, \quad \text {for } 1\le j\le m/2. \end{aligned}$$

Thus,

$$\begin{aligned} \hat{a}_{ij} = -\log |w_{i}-w_{j}-(1-q)\mathrm {i}|, \quad 1\le i,j\le m/2, \end{aligned}$$

and hence the entries \(\tilde{a}_{ij}\) of the matrix \(A_{12}J_{m/2}\) are given by

$$\begin{aligned} \tilde{a}_{ij} = \hat{a}_{i,m/2+1-j} = -\log |w_{i}-w_{m/2+1-j}-(1-q)\mathrm {i}| = -\log |w_{i}+w_{j}-1-\mathrm {i}|, \quad 1\le i,j\le m/2. \end{aligned}$$

Finally, the entries \(b_{ij}\), \(1\le i,j\le m/2\), of the matrix B are given for \(i=j\) by

$$\begin{aligned} b_{ii} = a_{ii} + \tilde{a}_{ii} = -\log r_k-\log |2w_{i}-1-\mathrm {i}| = -\log |{2r_k(w_{i}-(1+\mathrm {i})/2)}| = -\log |{2r_k \sqrt{z_{i}}}|, \end{aligned}$$

and for \(i\ne j\) by

$$\begin{aligned} b_{ij}=a_{ij}+\tilde{a}_{ij}=-\log |w_i - w_j|-\log |w_i + w_j - 1-\mathrm {i}| = - \log |{z_i - z_j}|, \end{aligned}$$

as claimed.\(\square\) 

The matrix B is symmetric but not centrosymmetric. Similarly to the approach for the generalized Cantor set in Section 3.4, the condition number of B grows linearly with m; see Fig. 10. We solve \(B \mathbf {y} = \mathbf {e}\) with GMRES and construct a left preconditioner for the matrices A and B in the case of the generalized Cantor dust. For \(j = 1, 2, \ldots , k-1\), the matrix A can be written in the block form (38) where now \(D \in \mathbb {R}^{4^j \times 4^j}\) and \(p=4^{k-j}\). Define the block-diagonal matrices

$$\begin{aligned} P_m = {{\,\mathrm{diag}\,}}(D, \ldots , D) \in \mathbb {R}^{m,m} \quad \text {and} \quad P_{m/2} = {{\,\mathrm{diag}\,}}(D, \ldots , D) \in \mathbb {R}^{m/2,m/2}, \end{aligned}$$

where \(P_m\) contains \(p=4^{k-j}\) copies of the matrix D, and \(P_{m/2}\) contains p/2 copies of D. Then, the matrix \(P_m\) is used as a preconditioner for the system (22), and the matrix \(P_{m/2}\) is used as a preconditioner for the system (30). The condition numbers of the matrices \(P_m^{-1} A\) and \(P_{m/2}^{-1} B\) are shown in Fig. 11 for \(j=1,2\). In our numerical computation, we consider \(j=2\) and hence the size of the matrix D is \(16\times 16\). In this case, we have \(\kappa (P_m^{-1} A) \approx 0.077\,\kappa (A)\) and \(\kappa (P_{m/2}^{-1} B) \approx 0.077\,\kappa (B)\); see Fig. 12.

Fig. 10
figure 10

2-norm condition numbers of \(A \in \mathbb {R}^{m,m}\) and \(B \in \mathbb {R}^{m/2, m/2}\) from (17) and (29) for the Cantor dust with \(q = 1/3\) as functions of \(m = 4^k\) for \(k = 1, 2, \ldots , 7\)

Fig. 11
figure 11

2-norm condition numbers of \(P_m^{-1} A \in \mathbb {R}^{m,m}\) and \(P_{m/2}^{-1} B \in \mathbb {R}^{m/2, m/2}\) as functions of \(m = 4^k\) for \(q=1/3\), \(j=1,2\), and \(k=j+1,j+2, \ldots ,6\)

Fig. 12
figure 12

\(\kappa (P_m^{-1}A)/\kappa (A)\) and \(\kappa (P_{m/2}^{-1} B)/\kappa (B)\) as functions of \(m = 4^k\) for \(q=1/3\), \(j=1,2\), and \(k=3,4,5,6\)

In [17, Corollary 3], it is shown that

$$\begin{aligned} (1-2q)\root 3 \of {q} \le \mathrm {cap}(F) \le \sqrt{2} \root 3 \of {q}. \end{aligned}$$
(44)

For \(q=1/3\), the values of the lower and upper bounds rounded to four significant digits are 0.2311 and 0.9806, respectively. A comparison with (45) below illustrates that we do not expect the bounds (44) to be very tight. We therefore do not further consider them in our numerical examples.

Example 4.3

(Classical Cantor middle third dust) The classical Cantor middle third dust is obtained for \(q=1/3\). This example has been considered by Ransford and Rostand in [23, §5.4] where it was proved that

$$\begin{aligned} \mathrm {cap}(F)\in [0.573550,0.575095], \end{aligned}$$
(45)

and their “best guess” is

$$\begin{aligned} \mathrm {cap}(F)\approx \underline{0.57434}50704. \end{aligned}$$
(46)

As for the generalized Cantor sets, we compare our new method with the BIE method from [14]. In that method, we first approximate \(\mathrm {cap}(D_k)\) using \(n=2^6\) discretization points on each boundary component. This leads to linear algebraic systems of size \(nm\times nm\), where \(m=4^k\); see Remark 3.2. The computed results and the timings for \(k=1,2,\ldots ,6\) are given in Table 5. Similarly to Example 3.8, we extrapolate the values in Table 5 in order to obtain an approximation of \(\mathrm {cap}(F)\). For the approximate values of \(\mathrm {cap}(D_k)\) obtained by the BIE method, the differences

$$\begin{aligned} d_k= \mathrm {cap}(D_{k})-\mathrm {cap}(D_{k+1}),\quad k=1,\dots ,5, \end{aligned}$$

decrease linearly on a logarithmic scale. We store these 5 values in the vector d, and use the MATLAB command p=polyfit(1:5,log(d),1)) to compute a linear polynomial \(p(x)=p_1x+p_2\) of best approximation in the least squares sense for the values \(\log (d_k)\). The computed coefficients are

$$\begin{aligned} p_1=-0.981567064346955,\quad p_2=-4.487710197832711. \end{aligned}$$

Starting with our computed approximation of \(\mathrm {cap}(D_{6})\), we can then approximate \(\mathrm {cap}(D_k)\) for \(k\ge 6\) by extrapolation, i.e.,

$$\begin{aligned} \mathrm {cap}(D_k)\approx \mathrm {cap}(D_{6})-\sum \limits _{j=6}^{k-1}\exp (p(j)),\quad k\ge 6. \end{aligned}$$

We have \(\exp (p(35))<10^{-16}\), and hence we use this formula with \(k=35\) for our estimate

$$\begin{aligned} \mathrm {cap}(F)\approx \underline{0.57434}7200461138. \end{aligned}$$
(47)
Table 5 The computed approximate values of \({\mathrm {cap}}(D_k)\) for \(q = 1/3\); see Example 4.3

Next, we use the new method based on the CSM to compute approximations of \({\mathrm {cap}}(D_k)\). Since the size of the preconditioner matrix is \(16\times 16\), the method is used without preconditioning technique for \(k<3\). The method with preconditioning technique is used for \(k\ge 3\), so that the size of the linear system is \(m\times m\) with \(m\ge 64\). Table 5 gives the computed approximations of \(\mathrm {cap}(D_k)\), the timings, and the number of GMRES iteration steps for \(k=1,2\dots ,10\). We observe that the computed approximations of \(\mathrm {cap}(D_k)\) are increasing, although \(\mathrm {cap}(D_{k+1})\le \mathrm {cap}(D_k)\) (since \(D_{k+1}\subset D_k\) for \(k\ge 1\)). This is most likely due to the fact that we use the CSM with only one point in the interior of each disk \(D_{k,j}\), \(j=1,2,\ldots ,4^k\), so that the numerical approximations are not accurate enough to yield a decreasing sequence. As shown in Table 5, the BIE method indeed gives a decreasing sequence of approximations. But here we use \(n=2^6\) discretization points for each circle \(\partial D_{k,j}\) for \(j=1,2,\ldots ,4^k\), which results in significantly longer computation times.

For the approximate values of \(\mathrm {cap}(D_k)\) obtained with the CSM in Table 5, the differences

$$\begin{aligned} d_k= \mathrm {cap}(D_{k+1})-\mathrm {cap}(D_k),\quad k=1,2,\dots ,9, \end{aligned}$$

decrease linearly on a logarithmic scale. We store these 9 values in the vector d and use the MATLAB command p=polyfit(1:9,log(d),1)) to compute a linear polynomial

$$\begin{aligned} p(x)=-0.983339218806568\,x-3.806740804822764 \end{aligned}$$

of best approximation in the least squares sense for the values \(\log (d_k)\). Starting with our computed approximation of \(\mathrm {cap}(D_{10})\), we approximate \(\mathrm {cap}(D_k)\) for \(k\ge 11\) by extrapolation, i.e.,

$$\begin{aligned} \mathrm {cap}(D_k)\approx \mathrm {cap}(D_{10})+\sum \limits _{j=10}^{k-1}\exp (p(j)),\quad k\ge 11. \end{aligned}$$

We have \(\exp (p(34))<10^{-16}\), and hence we use this formula with \(k=34\) for our estimate

$$\begin{aligned} \mathrm {cap}(F)\approx \underline{0.57434}5031687538. \end{aligned}$$
(48)

This estimate agrees in its first eight significant digits with the estimate in (46) obtained in [23], and all three estimates stated above agree in their first five significant digits.

Finally, for \(q=1/3\), it is worth mentioning that the new method works for any \(r_k \in [q^k/\sqrt{2},q^k)\) (instead of (42)), i.e., the circles can be chosen as large as possible so that each circle \(\partial D_{k,j}\) encloses the square \(S_{k,j}\), and that these circles are disjoint. Numerical experiments (not presented in this paper) show that the new method produces a decreasing sequence of approximate values for \(\mathrm {cap}(D_k)\) if we choose, for example, \(r_k=1.25q^k/\sqrt{2}\). Note that the proof of Theorem 4.1 can be adapted to see that \(\mathrm {cap}(F) = \lim _{k \rightarrow \infty } \mathrm {cap}(D_k)\) also holds for these larger radii.

Example 4.4

(Generalized Cantor dust) We consider now the numerical approximation of \(\mathrm {cap}(F)\) for general \(q\in (0,0.5)\). For the limiting cases \(F = \{0,1,1+\mathrm {i},\mathrm {i}\}\) (corresponding to \(q=0\)) and \(F = [0,1]\times [0,1]\) (corresponding to \(q=0.5\)), the capacities are

$$\begin{aligned} \mathrm {cap}(F)=0 \quad \text {and} \quad \mathrm {cap}(F) = \frac{\Gamma (1/4)^2}{4\pi \sqrt{\pi }}\approx 0.590170299508048, \end{aligned}$$

respectively; see [14, Table 1]. The new method can be used for \(q<\sqrt{2}-1\), so that the disks \(D_{k,j}\) with the radius \(r_k\) given by (42) are disjoint. Here we use the method to approximate the value of \(\mathrm {cap}(F)\) for \(q=1/20,2/20,\ldots ,8/20\).

Similar to Example 4.3, the sequences of the computed approximations of \(\mathrm {cap}(D_k)\) are not necessarily decreasing. For this example, the method generates a decreasing sequence of approximate values for \(q=1/20,\ldots ,5/20\), and an increasing sequence for \(q=6/20,7/20,8/20\). Then, using the approach described in Example 4.3, the obtained approximate values are extrapolated to obtain approximations for \(\mathrm {cap}(F)\), which are stated in Table 6.

Table 6 The computed approximations of \(\mathrm {cap}(F)\); see Example 4.4

Similarly to the generalized Cantor sets, it would be of interest to closely approximate the values of \(\mathrm {cap}(F)\) with a function of \(q \in [{0, 0.5}]\). After some attempts, we came up with

$$\begin{aligned} f(q) = \sqrt{2} \frac{\Gamma (1/4)^2}{4 \pi \sqrt{\pi }} (q(1-q))^{1/4}, \end{aligned}$$
(49)

which is shown in Fig. 13. It is another open question to determine whether there is an exact analytic relation between the logarithmic capacities of the generalized Cantor set and generalized Cantor dust. The only relation we are aware of is \(\mathrm {cap}(F) \ge 2 \mathrm {cap}(E)\); see [24, p. 1516].

Fig. 13
figure 13

The computed logarithmic capacity \(\mathrm {cap}(F)\) (blue circles) and the function f in (49) (dashed)

5 Concluding remarks

In this paper, we have applied the CSM to the computation of the logarithmic capacity of compact sets consisting of very many “small” components. This application allows to use just a single charge point for each component, which leads to a significantly more efficient computational method in comparison with methods that use discretizations of the boundaries of the different components. We have obtained an additional speedup of the method by exploiting the structure of the system matrices, and by using a problem-adapted preconditioner for the linear algebraic systems. In the numerical examples, we have seen that for the same number of components, the new method is faster by a factor of 100 (sometimes even 1000) than our previous BIE method [14], while maintaining the same high level of accuracy. We have applied the method to generalized Cantor sets and the Cantor dust. We are not aware of any other computed approximations of the logarithmic capacity of the Cantor dust for \(q \ne 1/3\) in the literature.