({{, (RefLink[MandelbrotSetIterationCount, paclet:ref/MandelbrotSetIterationCount])[c] 
returns the number of iterations of the function f(z)==(z^2)+c, beginning with z==0, that are needed to determine whether c is in the Mandelbrot set.}})

OpenersNotesSection(Spacer1)Details and Options

The Mandelbrot set is the set of all complex numbers c for which the sequence (Subscript[z, n])=(Subscript[z, n-1]^2)+c does not diverge to infinity when starting with (Subscript[z, 0])=0.

With the option (RefLink[MaxIterations, paclet:ref/MaxIterations])->n, the sequence (Subscript[z, n])=(Subscript[z, n-1]^2)+c will be iterated at most n times to determine if the sequence diverges.

The default setting is (RefLink[MaxIterations, paclet:ref/MaxIterations])->1000.

If the maximum number of iterations is reached, z is assumed to be in the Mandelbrot set.

For some points that the algorithm knows in advance to be inside the Mandelbrot set, (RefLink[MandelbrotSetIterationCount, paclet:ref/MandelbrotSetIterationCount]) will return one greater than the value of (RefLink[MaxIterations, paclet:ref/MaxIterations]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (11)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Find the number of iterations needed to determine that (1/2)+(i/2) is not in the Mandelbrot set:

MandelbrotSetIterationCount[1/2+I/2]

Zero is known to be inside the Mandelbrot set and therefore returns n+1:

MandelbrotSetIterationCount[0]

It takes a few additional iterations to determine that 0.250001 is not in the Mandelbrot set:

MandelbrotSetIterationCount[0.250001]

MandelbrotSetIterationCount[0.250001,MaxIterations->4000]

(RefLink[MandelbrotSetIterationCount, paclet:ref/MandelbrotSetIterationCount]) works on all kinds of numbers:

MandelbrotSetIterationCount[{1/4,0.26,1+I,1/Pi,N[1/Pi,20]}]

OpenersExampleSection1(Spacer1)Options  (2)

OpenersExampleSubsection0(Spacer1)MaxIterations  (1)

Sometimes (RefLink[MaxIterations, paclet:ref/MaxIterations]) needs to be increased to get the true number of iterations:

{MandelbrotSetIterationCount[-1.85+I*10^-290],MandelbrotSetIterationCount[-1.85+I*10^-290,MaxIterations->2000]}

OpenersExampleSubsection1(Spacer1)WorkingPrecision  (1)

Sometimes increasing (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision]) gives a more accurate result:

m=0.3131411150544352`-I/2;{MandelbrotSetIterationCount[m,MaxIterations->2000],MandelbrotSetIterationCount[m,MaxIterations->2000,WorkingPrecision->1000000]}

OpenersExampleSection2(Spacer1)Properties & Relations  (1)

(RefLink[ArrayPlot, paclet:ref/ArrayPlot]) applied to (RefLink[MandelbrotSetIterationCount, paclet:ref/MandelbrotSetIterationCount]) is essentially (RefLink[MandelbrotSetPlot, paclet:ref/MandelbrotSetPlot]):

MandelbrotSetPlot[]

ArrayPlot[Log[Map[MandelbrotSetIterationCount,Table[Complex[x,y],{y,-1.3,1.3,.01},{x,-2,.6,.01}],{2}]/. {0->1}]]

OpenersExampleSection3(Spacer1)Possible Issues  (1)

With (RefLink[MaxIterations, paclet:ref/MaxIterations])->(RefLink[Infinity, paclet:ref/Infinity]), the calculation may not converge in a finite number of steps:

TimeConstrained[MandelbrotSetIterationCount[1/4+10^-11,MaxIterations->Infinity],1]

Since (1/4) is known to be in the Mandelbrot set, it returns (RefLink[DirectedInfinity, paclet:ref/DirectedInfinity]):

MandelbrotSetIterationCount[1/4,MaxIterations->Infinity]

OpenersExampleSection5(Spacer1)Neat Examples  (3)

Make a (RefLink[Histogram, paclet:ref/Histogram]) of iteration counts along the imaginary axis:

Histogram[MandelbrotSetIterationCount[Table[I*y,{y,-1.5,1.5,.0001}],MaxIterations->25]]

Display the iteration count as height:

ListPlot3D[Log[MandelbrotSetIterationCount[Table[x+I*y,{x,-2,1,0.01},{y,-1.5,1.5,0.01}],MaxIterations->25]+1],Mesh->False]

Half of a rotated Mandelbrot set:

data = Table[MandelbrotSetIterationCount[Table[x+I y/Sin[ArcTan[c/y]],{y,-1,1,0.03},{x,-2,0.6,0.03}],MaxIterations->50],{c,-1,0,0.03}];

Image3D[(#1/Max[#1]&)[N[Log10[Clip[data,{1,Infinity}]]]]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MandelbrotSetPlot, paclet:ref/MandelbrotSetPlot])  ▪  (RefLink[MandelbrotSetMemberQ, paclet:ref/MandelbrotSetMemberQ])  ▪  (RefLink[MandelbrotSetDistance, paclet:ref/MandelbrotSetDistance])  ▪  (RefLink[JuliaSetIterationCount, paclet:ref/JuliaSetIterationCount])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Iterated Maps & Fractals, paclet:guide/IteratedMapsAndFractals])}})}})