# Distance Estimator

Robert P. Munafo, 2011 Feb 28.

A less common representation function for the Mandelbrot Set. Distance Estimator allows you to see every pixel that contains any points in the Mandelbrot Set (no matter how few such points there are). This makes the filament structure much easier to see.

The Distance Estimator algorithm, presented below, is similar to algorithm "DEM/M" in The Science of Fractal Images. Most images in this encyclopedia show the filaments and were computed with a Distance Estimator algorithm.

The algorithm is based on the derivative of the iteration function and works because the dwell bands are spaced closer together as you approach a point in the Mandelbrot set. Calcuating the derivative is equivalent to measuring the spacing of the dwell bands.

Distance-Estimator is the best representation function for exploring the Mandelbrot set, and it is used in many good color schemes. The DEM-Dwell Hybrid article illustrates the difference.

function distance_estimator param(c) : complex param(max_iterations) : integer param(escape_radius) : real should be 2.0 or larger result: real begin function declare z, z2, dz : complex declare iterations : integer declare still_iterating : boolean let still_iterating = true let iterations = 0 let z = c let dz = 0 let escape_radius = 2.0 or larger value while (still_iterating) do let z2 = z^{2}+ c let dz = 2 * z * dz + 1 let z = z2 let iterations = iterations + 1 if (magnitude(z) > escape_radius) then let still_iterating = false else if (iterations >= max_iterations) then let still_iterating = false end if end while let z = magnitude(z) let dz = magnitude(dz) let result = log(z*z) * z / dz end function

The value of result is a real giving the approximate distance between the point z and the nearest point that is in the Mandelbrot Set. If you are viewing an area that contains Filaments, then nearly all of the 'interesting' parts of the view will have values of result that are very small positive numbers, like 0.01 or 0.00001.

Since images are usually plotted through a color table, and since color tables require an index (like a number from 1 to 100), you will probably want to convert the result of distance_estimator to a color table index. A good formula that accomplishes this is:

let color_table_index = 0 - k * log(distance_estimator(z, max_iteraions))

where k is a constant that depends on the size of your color table and the maximum zoom magnification factor according to the following formula:

k = color_table_size / log(maximum_zoom_magnification)

For example, if your color table has 200 elements and the maximum
magnification is 10^{10}, and if log is a base-10 logarithm, then k
would be 200/10 = 20.

## Distance Estimator for Julia Set Images

According to Milnor (in Dynamics in One Complex Variable, appendix G), the distance estimate for Julia sets is close to the ratio magnitude(G)/G', where G and G' are defined as follows:

G(Z_{0}) = limit(k->infinity) [log(magnitude(Z_{k})/2^{k}]

G'(Z_{0}) = limit(k->infinity) [magnitude(dZ_{k})
/ (2^{k} magnitude(Z_{k}))]

dZ_{k} = 2^{k} Z_{k-1} Z_{k-2} ^{...} Z_{2} Z_{1} Z_{0}

When one of the Z_{k} is close to 0 (that is, for points near the
origin and any points with an iterate that maps onto the origin)
the distance estimate is inaccurate.

See also interior distance estimate

Acknowledgments

The Distance Estimator method was pioneered by Thurston, and was made known to the general community by Peitgen and Richter in their book The Beauty of Fractals. A precise algorithm is given in The Science of Fractal Images, page 198, where it is called DEM/M.

revisions: 20080319 oldest version on record; 20100505 fix some typos in the source code; 20100907 replace "2.0" with escape_radius; 20110228 link to DEM-Dwell Hybrid article; 20111208 Slight rewrite and add a couple xrefs

From the Mandelbrot Set Glossary and Encyclopedia, by Robert Munafo, (c) 1987-2020. Mu-ency index

This page was written in the "embarrassingly readable" markup language RHTF, and was last updated on 2020 Mar 26. s.11