# What are the arguments supplied to ColorFunction in MandelbrotSetPlot?

On the document of MandelbrotSetPlot, it said:

With ColorFunction->f, where f is a function, the argument of f is a real number in proportional to the number of iterates, and f must return color directives, such as RGBColor and Hue, or named colors, such as Red and Blue.

It seems to have only one argument. But an example uses the third argument:

So I tried evaluating

Reap[MandelbrotSetPlot[{-2 - 2 I, 2 + 2 I},
ColorFunction -> ((Sow[{##}]; If[#1 == 1,
Black,
RGBColor[(1 - #3)^2, (1 - #3)^3, 1 - #3]]) &)
]
]


and noticed that it has exactly five arguments. The first, second and third arguments are real numbers between 0. and 1., while the fourth is an integer and the fifth is a complex number.

I think the third argument is proportional to the number of iterations. What do the other arguments mean?

### Update:

I think Mathematica just calculates the upper half of the Mandelbrot set.

Graphics[{PointSize@0,
Point[{Re@#, Im@#} & /@
Reap[MandelbrotSetPlot[ColorFunction -> (Sow@#5 &)]][[2, 1]]]}]


• I think the statement in docs that: "ColorFunction->"name" is equivalent to ColorFunction->(If[#==1,Black,ColorData["name"][#]]&)." is not true. There should be #3 not #. First and the second arguments are coordinates. Here they are in (0,1) interval because ColorFunctionScaling is True. – Kuba Nov 29 '14 at 9:28
• The fourth argument is 1 if the point is in the Mandelbrot set, and 0 otherwise. – alephalpha Nov 29 '14 at 10:19

Just to summarize the comments by @alephalpha and @Kuba for

MandelbrotSetPlot[{xmin + ymin I, xmax + ymax I}, ColorFunction -> (f[#,#2,#3,#4,#5]&)]

1. Slot #1 corresponds to the horizontal coordinate x.

• If ColorFunctionScaling -> True, then #1 ranges from 0 to 1 as x ranges from xmin to xmax.
• If ColorFunctionScaling -> False, then #1 ranges from 0 to 1 as x ranges from 0 to 1. The value of #1 is 0 for x <= xmin and is 1 for x >= xmax.
2. Slot #2 corresponds to the vertical coordinate y.

• If ColorFunctionScaling -> True, then #2 ranges from 0 to 1 as y ranges from ymin < 0 to ymax < 0. However, #2 ranges from 1 to 0 to ymax as y ranges from ymin < 0 to 0 to ymax > 0, unless ymax > -ymin, plus yet more bizarre conditions ...
• If ColorFunctionScaling -> False, then #2 ranges from 1 to 0 to 1 as y ranges from -1 to 0 to 1. The value of #2 is 1 for y <= ymin and is 1 for y >= ymax.
3. Slot #3 is roughly proportional to the log of the number of iterations.

• If ColorFunctionScaling -> True, then #3 ranges from 0 and 1, logarithmically.
• If ColorFunctionScaling -> False, then #3 ranges from 0 to MaxIterations (default 100), logarithmically.
4. Slot #4 is 1 if the point is in the Mandelbrot set, and is 0 otherwise.

5. Slot #5 is apparently the final iterated value of complex iterate z, whose absolute value exceeds the EscapeRadius (default 2). Although, the magnitude of this z is much greater than the escape radius...

• I think Slot #2 corresponds to the absolute value of the vertical coordinate. The Mandelbrot set is symmetric, so Mathematica might just calculate the upper half. – alephalpha Jan 23 '15 at 5:59
• Ahhh, thanks for that. The Abs may explain the bizarre behaviour. @Kuba: thanks for the edits! I will use them in future. – KennyColnago Jan 30 '15 at 23:02