Function Repository Resource:


Source Notebook

Apply functions to remap the Mandelbrot set

Contributed by: Mark Greenberg and Rohit Namjoshi

ResourceFunction["MandelbrotSetRemap"][cen, mag]

renders a smooth mapping of the Mandelbrot set centered on cen with a magnification of mag.

Details and Options

The center cen should be a complex number.
The magnification mag can be any positive number, though greater magnification requires a higher MaxIterations setting to see the details and therefore longer render time. If mag is omitted, a default value of 1.25 is used.
ResourceFunction["MandelbrotSetRemap"] accepts the following options:
ColorFunctionAutomaticcolor applied to each pixel's remapped value v where 0 ≤ v ≤ 1.
ColorFunctionScalingTrueif True,v will be scaled to 0 ≤ v ≤ 1.
ImageSize{260,200}size of the image.
"MappingFunction""Smooth"function that remaps the Mandelbrot Set.
MaxIterations16maximum number of iterations for a pixel. Higher values give more detail and longer render times.
"Parallel"Falsewhether ParallelMap should be used to speed up computation. Using "Parallel" with a preset will slow down the computation.
"Parameter1"-.7+.77ia complex parameter. See the "MappingFunction" table below
“Parameter2”1.33+77ia complex parameter. See the “MappingFunction” table below
“Parameter3”-.13-.77ia complex parameter. See the “MappingFunction” table below
“Parameter4”-1.9-.77ia complex parameter. See the “MappingFunction” table below
“Parameter5”2.a real parameter. See the “MappingFunction” table below
“Parameter6”1.a real parameter. See the “MappingFunction” table below
If "MappingFunction" is a custom function that outputs a list of values, ColorFunction should accept a list as its argument.
ImageSizew is equivalent to ImageSize{w,w}.
Render times can increase greatly for larger images or complicated functions.
The "MappingFunction" option has several presets:
"Beanstalks"based on the distance to the corners of the image
"Cobweb"based on the final value of IntegerPart[zre] + Round[zim] + "Parameter1"
"DandelionSeeds"based on the weighted distances between three points (located by "Parameter1", "Parameter2", and "Parameter3") with weights provided by "Parameter5" and "Parameter6"
“Decomposition”based on the final vector angle of z
"Filigree"based on the maximum absolute value of the vector angle of z
"Foliage"based on the maximum vector angle of z
"LineOrbitTrap"based on the minimum distance of z to a line passing through "Parameter2" and "Parameter3"
"ModTrailings"based on the modulus of z
"ParallelogramOrbitTrap"based on the distance to a quadrilateral (default is a parallelogram) with vertices at "Parameter1" through "Parameter4" and multipliers of "Parameter5" and "Parameter6"
"RibsAndTusks"based on the minimum and maximum distance to a quadrilateral with vertices on the image corners and multipliers of “Parameter5” and “Parameter6”
"Smooth"(default) gives a smooth gradient inside and outside
"ThreePointsOrbitTrap"based on the minimum distance of z to equlateral triangle vertices (default) or any triangle defined by the vertices at "Parameter1" through "Parameter3"
Each preset mapping function is compiled when it is first used, which can take several seconds to complete. Subsequent calls use the compiled version which is significantly faster.
The definition for a custom MappingFunction should accept ten arguments, customMapping[px, center, corner, maxIt,param1,param2,param3,param4,param5,param6]:
pxcomplex location of the pixel currently being remapped
centercomplex location of the image's center
cornercomplex location of the image's lower-left corner
maxItmaximum number of iterations
param1...param4complex numbers potentially provided by the user
param5,param6real numbers potentially provided by the user
center and corner are useful for mappings that scale or are aware of the image dimensions.


Basic Examples (2) 

Render a smooth mapping of the whole Mandelbrot set:


Zoom into part of the Mandelbrot set:

ResourceFunction["MandelbrotSetRemap"][.385 - .27 I, 100, MaxIterations -> 48]
ResourceFunction["MandelbrotSetRemap"][-1.4, 36, MaxIterations -> 54]

Options (9) 

ColorFunction (3) 

Use one of the presets, the default "BlueGold" or more vibrant color functions called "Vivid" and "Psychedelic":

Table[ResourceFunction["MandelbrotSetRemap"][-.7, ColorFunction -> cf], {cf, {"BlueGold", "Vivid", "Psychedelic"}}]

Assign a built-in color scheme to the mapping:

Table[ResourceFunction["MandelbrotSetRemap"][-.7, ColorFunction -> cf], {cf, {"Rainbow", "BoldColorFractalGradient", ColorData[{"TemperatureMap", "Reversed"}]}}]

Use the value(s) returned by the MappingFunction as input to RGBColor, Hue, or any function that returns a color:

Table[ResourceFunction["MandelbrotSetRemap"][-.7, ColorFunction -> cf], {cf, {RGBColor[.5, #, #] &, Hue[#, #, Sqrt[#]] &}}]

ColorFunctionScaling (1) 

Set the ColorFunctionScaling option to False to use values outside 0 ≤ v ≤ 1 in custom color functions:

Table[ResourceFunction["MandelbrotSetRemap"][-.7, ColorFunction -> (Hue[.75 - #, 1, Mod[#, 1] + .25] &), ColorFunctionScaling -> cfs], {cfs, {True, False}}]

ImageSize (1) 

The ImageSize may be given as a single number for a square image or {w,h}:

Table[ResourceFunction["MandelbrotSetRemap"][-.7, ImageSize -> sz], {sz, {260, {260, 100}}}]

MappingFunction (2) 

Use one of twelve preset mapping functions:

Table[Column[{mf, ResourceFunction["MandelbrotSetRemap"][-.7, "MappingFunction" -> mf]}, Alignment -> Center], {mf, {"Beanstalks", "Cobweb", "DandelionSeeds", "Decomposition", "Filigree", "Foliage", "LineOrbitTrap", "ModTrailings", "ParallelogramOrbitTrap", "RibsAndTusks", "Smooth", "ThreePointsOrbitTrap"}}]

Explore artistic possibilities by zooming in:

Table[Column[{mf, ResourceFunction["MandelbrotSetRemap"][-.049 - .84 I, 200, MaxIterations -> 30, "MappingFunction" -> mf]}, Alignment -> Center], {mf, {"Beanstalks", "Cobweb", "DandelionSeeds", "Decomposition", "Filigree", "Foliage", "LineOrbitTrap", "ModTrailings", "ParallelogramOrbitTrap", "RibsAndTusks", "Smooth", "ThreePointsOrbitTrap"}}]

MaxIterations (1) 

Higher settings for MaxIterations give more details:

Table[ResourceFunction["MandelbrotSetRemap"][-.7, ColorFunction -> "Vivid", MaxIterations -> mi], {mi, {8, 16, 48, 128}}]

Parallel (1) 

Setting the Parallel option to True helps speed up complicated mapping functions:

ellipseOrbitTrap = Function[{c, center, corner, maxIterations}, Module[{ trap, trapDist, list},
    trap = Circle[{.8, 1}, {1.3, 2.7}];
    trapDist = 1000000;
    list = NestWhileList[
      (trapDist = Min[trapDist, RegionDistance[trap, ReIm[#]]]; #^2 + c) &,
      0, Abs[#] <= 6 &, 1, maxIterations];
  ResourceFunction["MandelbrotSetRemap"][-0.7 + .46 I, 2.8, "Parallel" -> p, "MappingFunction" -> ellipseOrbitTrap]], {p, {False, True}}]

Applications (1) 

Make a cool image:

ResourceFunction["MandelbrotSetRemap"][-.805 - .176 I, 170, MaxIterations -> 64, "MappingFunction" -> "ThreePointsOrbitTrap", ColorFunction -> ColorData["SunsetColors"], Parameter1 -> .2 - .5 I, ImageSize -> {600, 400}]

Neat Examples (2) 

Combining images made with MandelbrotSetRemap can produce some spectacular results:

img1 = ResourceFunction["MandelbrotSetRemap"][.08 + 1.009 I, 10, MaxIterations -> 32, "MappingFunction" -> "ModTrailings", ColorFunction -> "SunsetColors", ImageSize -> {600, 400}];
img2 = ResourceFunction["MandelbrotSetRemap"][.08 + 1.009 I, 10, "MappingFunction" -> "Decomposition", ColorFunction -> "FuchsiaTones", ImageSize -> {600, 400}];
ImageAdjust[ImageMultiply[{img1, img2}]]

Here is the same part of the Mandelbrot set rendered with MandelbrotSetPlot and MandelbrotSetRemap using the same ColorFunction:

  MandelbrotSetPlot[{.3535 - .0666 I, .361 - .062 I}, MaxIterations -> 42, ImageSize -> {600, 400}, ColorFunction -> "SunsetColors"],
  ResourceFunction["MandelbrotSetRemap"][.357 - .0644 I, 550, MaxIterations -> 42, ImageSize -> {600, 400}, ColorFunction -> "SunsetColors"],
  ResourceFunction["MandelbrotSetRemap"][.357 - .0644 I, 550, MaxIterations -> 42, ImageSize -> {600, 400}, "MappingFunction" -> "ParallelogramOrbitTrap", ColorFunction -> "SunsetColors"]


Mark Greenberg

Version History

  • 1.1.0 – 10 February 2023
  • 1.0.0 – 02 November 2021

License Information