Learn R Programming

future (version 1.82.0)

mandelbrot: Mandelbrot convergence counts

Description

Mandelbrot convergence counts

Usage

mandelbrot(...)

# S3 method for matrix mandelbrot(Z, maxIter = 200L, tau = 2, ...)

# S3 method for numeric mandelbrot( xmid = -0.75, ymid = 0, side = 3, resolution = 400L, maxIter = 200L, tau = 2, ... )

mandelbrot_tiles( xmid = -0.75, ymid = 0, side = 3, nrow = 2L, ncol = nrow, resolution = 400L, truncate = TRUE )

Value

Returns an integer matrix (of class Mandelbrot) with non-negative counts (\(C\)).

Arguments

Z

A complex matrix (\(Z\)) for which convergence counts (\(C\)) should be calculated.

maxIter

Maximum number of iterations (\(c^{max}\)) per bin.

tau

A threshold (\(\tau\)); the radius when calling divergence (\(|z_{i}| > \tau\)).

xmid, ymid, side, resolution

Alternative specification of the complex plane Z, where mean(Re(Z)) == xmid, mean(Im(Z)) == ymid, diff(range(Re(Z))) == side, diff(range(Im(Z))) == side, and dim(Z) == c(resolution, resolution).

nrow, ncol

Number of rows and columns of tiles to partition the complex plane Z into.

truncate

If TRUE, all tiles are truncated to have identical dimensions, otherwise the last row and column of tiles may be smaller.

Escape time algorithm

The convergence counts are calculated using the standard escape-time algorithm for the Mandelbrot set: for each complex number \(c\), the sequence \(z_{i+1} \leftarrow z_{i}^2 + c\) (starting at \(z_{0} = c\)) is iterated until either its modulus (\(|z_{i}|\)) exceeds the escape radius \(\tau\) (tau) or the maximum number of iterations (\(c^{max}\)) has been reached. The count (\(c_{i}\)) recorded is the iteration at which the sequence escaped, or \(c^{max}\) for points that never escaped.

References

Mandelbrot set, https://en.wikipedia.org/wiki/Mandelbrot_set, 2026

Examples

Run this code
counts <- mandelbrot(xmid = -0.75, ymid = 0, side = 3)
str(counts)
if (FALSE) {
plot(counts)
}

if (FALSE) {
demo("mandelbrot", package = "future", ask = FALSE)
}

Run the code above in your browser using DataLab