This function is provided as a basis for visualizing the Mandelbrot set with
phasePortrait
. While usual visualizations color the points
outside the Mandelbrot set dependent on the velocity of divergence,
this function produces the information required for coloring the Mandelbrot
set itself. For numbers that can be identified as not being elements of the
Mandelbrot set, we obtain a NaN+NaNi
value; for all other numbers,
the function gives back the value after a user-defined number of iterations.
The function has been implemented in C++; it runs fairly fast.
mandelbrot(z, itDepth = 500L)
z | Complex number; the point in the complex plane to which the output of the function is mapped |
---|---|
itDepth | An integer which defines the depth of the iteration, i.e. the
maximum number of iteration (default: |
Either NaN+NaNi
or the complex number obtained after
itDepth
iterations
The Mandelbrot set comprises all complex numbers z
for which the
sequence a[n+1] = a[n]^2 + z
starting with a[0] = 0
remains
bounded for all n > 0
. This condition is certainly not true, if, at
any time, abs(a[]) >= 2
. The function mandelbrot
performs the
iteration for n = 0, ..., itDepth - 1
and permanently checks for
abs(a[n+1]) >= 2
. If this is the case, it stops the iteration and
returns NaN+NaNi
. In all other cases, it returns a[itDepth]
.
Other fractals:
juliaNormal()
Other maths:
blaschkeProd()
,
jacobiTheta()
,
juliaNormal()
# This code shows the famous Mandelbrot figure in total, just in the # opposite way as usual: the Mandelbrot set itself is colored, while the # points outside are uniformly black. # Adjust xlim and ylim to zoom in wherever you like. # \donttest{ phasePortrait(mandelbrot, xlim = c(-2.3, 0.7), ylim = c(-1.2, 1.2), hsvNaN = c(0, 0, 0), nCores = 1) # Max. two cores on CRAN, not a limit for your use # }