Mandelbrot Set: Shallow-Regime Sampling Optimizations

The Escape-Time Algorithm and Its Bottleneck

The standard escape-time algorithm iterates zn+1=zn2+cz_{n+1} = z_n^2 + c starting from z0=0z_0 = 0. If zn>2|z_n| > 2 for some nn, the orbit escapes and cc is colored by the escape iteration count. If the orbit survives to a cap NmaxN_{\max}, the pixel is colored black — the point is treated as interior.

Interior points are the expensive case: every one runs to the cap. In a shallow-regime render (full-set views, zoom depths where double precision holds) the typical iteration cap is a few hundred to a few thousand. If a large fraction of pixels land inside the set, those pixels dominate the total work budget.

The leverage is a conservative interior predicate — a cheap test that proves a point is inside:

inside(c)=true    cM.\texttt{inside}(c) = \text{true} \;\Longrightarrow\; c \in M.

The predicate is allowed to miss interior points (false negatives fall through to escape-time at no extra cost), but must never claim an exterior point is interior (a false positive would mis-color a pixel). This asymmetry is the whole design.

We build three layers, ordered by cost and coverage.

Layer 1: Main Cardioid (Exact)

The main cardioid is the set of cc for which fc(z)=z2+cf_c(z) = z^2 + c has an attracting fixed point. A fixed point satisfies z=z2+cz = z^2 + c with multiplier λ=2z\lambda = 2z; attracting means λ<1|\lambda| < 1. Parametrizing by the multiplier:

c(λ)=λ2λ24,λ=eiθ.c(\lambda) = \frac{\lambda}{2} - \frac{\lambda^2}{4}, \qquad \lambda = e^{i\theta}.

To test membership we invert: the fixed point is z=12(114c)z = \tfrac{1}{2}(1 - \sqrt{1 - 4c}) and the interior condition is 2z<1|2z| < 1. The complex square root can be eliminated. With

q=(cx14)2+cy2,q = \left(c_x - \tfrac{1}{4}\right)^2 + c_y^2,

the cardioid interior is exactly the set where

q(q+cx14)<14cy2.q\,\bigl(q + c_x - \tfrac{1}{4}\bigr) < \tfrac{1}{4}\,c_y^2.

This is not an approximation — it is the exact interior. It costs four multiplications and two additions per point.

Layer 2: Period-2 Disk (Exact)

The genuine period-2 points satisfy fc2(z)=zf_c^{\circ 2}(z) = z. The degree-4 polynomial factors as (z2+z+c+1)(z2z+c1)=0(z^2 + z + c + 1)(z^2 - z + c - 1) = 0, where the first factor gives the 2-cycle after dividing out fixed points. By Vieta’s formulas the product of the two 2-cycle elements is z0z1=c+1z_0 z_1 = c + 1, and the 2-cycle multiplier is

λ=(fc2)(z0)=4z0z1=4(c+1).\lambda = (f_c^{\circ 2})'(z_0) = 4z_0 z_1 = 4(c+1).

Since λ\lambda is linear in cc, the interior λ<1|\lambda| < 1 maps to an exact disk:

c+1<14.|c + 1| < \tfrac{1}{4}.

Period 2 is the only nontrivial hyperbolic component whose multiplier is linear in cc. Every higher-period component has a nonlinear multiplier-to-parameter map, so none of them is an exact disk in the cc-plane.

Layer 3: Period-3 Bulbs (Inscribed Disks, MC-Calibrated)

The period-3 superattracting parameters — where 00 lies on the 3-cycle, fc3(0)=0f_c^{\circ 3}(0) = 0 — are roots of

c3+2c2+c+1=0.c^3 + 2c^2 + c + 1 = 0.

One root is real (c1.7549c \approx -1.7549, on the antenna); the conjugate pair (c0.1226±0.7449ic \approx -0.1226 \pm 0.7449i) sits on the two round bulbs attached to the main cardioid. The boundaries of these bulbs are not circles — their exact boundary is determined by a degree-9 resultant in cc — so we inscribe a disk at each center instead.

The inscribed radius must be backed off below the geometric inscribed radius, or the test stops being conservative near the curved boundary. Rather than deriving the exact inscribed radius analytically, we measure a safe lower bound by Monte Carlo:

  1. Draw 1.5 million random samples from the bounding box [2.2,0.7]×[1.3,1.3][-2.2, 0.7] \times [-1.3, 1.3].
  2. Run escape-time with Nmax=1024N_{\max} = 1024 to classify each sample as interior or escaping.
  3. For each period-3 center, record the minimum distance to any escaping sample. This is a stochastic lower bound on the true inscribed radius.
  4. Apply a safety shrink factor SHRINK=0.90\text{SHRINK} = 0.90 to that lower bound.

The antenna center admits only a tiny disk (the filament region is spiky, so escaping points are nearby). The two cardioid-attached bulbs give usable disks:

CenterMC lower boundUsed radius (×0.90\times 0.90)
0.1226+0.7449i-0.1226 + 0.7449i0.092\approx 0.0920.083\approx 0.083
0.12260.7449i-0.1226 - 0.7449i0.092\approx 0.0920.083\approx 0.083

The antenna center yields 0.008\approx 0.008, below the 0.02 threshold used to filter out negligible disks.

Visual Confirmation

The figure below renders the set with log-scaled escape-time coloring and overlays the three analytic regions. The period-3 inscribed disks sit visibly inside their bulbs with margin to spare.

Mandelbrot set with analytic interior regions overlaid
Mandelbrot set (log escape-time coloring). Yellow: cardioid boundary. Blue: period-2 disk. Green: period-3 inscribed disks. All three boundaries lie strictly inside their respective components.

Conservativeness and Coverage

We verify on a fresh 3-million-point random sample (bounding box [2.2,0.7]×[1.3,1.3][-2.2, 0.7] \times [-1.3, 1.3], Nmax=1024N_{\max} = 1024) that no layer produces false positives, then measure interior coverage:

PredicateInterior caughtFalse positives
cardioid~78%0
cardioid + period-2~91%0
cardioid + period-2 + period-3~94%0

The cardioid alone captures roughly three-quarters of all interior mass. Adding the period-2 disk crosses 90%. The period-3 disks add a few more percentage points. The long tail of smaller bulbs is deliberately left to escape-time.

If period-3 shows false positives, the shrink factor is too loose — reduce SHRINK until the count reaches zero.

Coverage by analytic layer
Fraction of interior points caught by each cumulative predicate layer. Coverage is monotonically non-decreasing; each layer adds strictly more skipped interior points.

Iteration-Work Savings

Coverage of interior mass understates the true benefit: interior points are exactly the expensive ones, each costing NmaxN_{\max} iterations. We model work explicitly:

On the 3-million-point sample with Nmax=1024N_{\max} = 1024:

reduction=1work with testsbaseline work3540%.\text{reduction} = 1 - \frac{\text{work with tests}}{\text{baseline work}} \approx 35\text{–}40\%.

The exact figure depends on what fraction of the bounding box is interior, which varies with the view. Full-set views have higher interior fraction and therefore larger savings; deep zooms into exterior spirals have near-zero interior fraction and therefore near-zero benefit from these tests.

Iteration work saved by analytic tests
Total iteration count with and without the three-layer conservative predicate. Interior points dominate the work budget; skipping them analytically cuts the total by roughly 35–40%.

Design Notes

Why not use larger disks? The period-3 boundary is curved and the inscribed disk underestimates the component. The shrink factor is the margin of safety. A tighter MC sample (more points, higher NmaxN_{\max}) converges the lower bound upward, allowing a slightly larger disk, but the gain diminishes quickly.

Why stop at period 3? The inscribable disk radius shrinks roughly as 1/q21/q^2 along the Mandelbrot boundary for period-qq components, and filament-region components admit almost no inscribed disk at all (the antenna period-3 center above). Past period 3 the per-branch overhead exceeds the iteration savings.

Clean handoff. These tests handle the large round interior components. Everything else — fine filament structures, higher-period bulbs, deep zooms — is handled by escape-time plus periodicity detection (Brent’s cycle detection, or atom-domain tests). The two methods are complementary and compose without interaction.

Deep-zoom regime. In the deep-zoom regime the interior-skipping question becomes secondary to a different bottleneck: double precision no longer resolves the structure, and per-pixel extended-precision arithmetic dominates the budget. The analytic tests remain valid (the cardioid and period-2 disk are exact in exact arithmetic) but the savings they provide are negligible relative to the precision cost.