mandelbrot: The Mandelbrot Set

View source: R/mandelbrot.R

mandelbrotR Documentation

The Mandelbrot Set

Description

Calculate the Mandelbrot set

Usage

mandelbrot(x = c(-2, 1), y = c(-1.5, 1.5), nx = 600, ny = 600, iter = 50)

Arguments

x

x limits

y

y limits

nx

x resolution

ny

y resolution

iter

maximum number of iterations

Details

The set is obtained by iterating z_{j+1}=z_j^2+c where z and c are complex numbers. The initial value of z, z_0 is 0, and the value of c is chosen arbitrarily. It can be shown that if after a certain number of iterations, the modulus of Z is greater than 2, then the value of z will head off to infinity. The Mandelbrot set is defined as the set of points c in the complex plane for which the iteration procedure is bound (that is, for which z does not head off to infinity).

Value

A list with components: x, a vector of x coordinates (real part), y, a vector of y coordinates (imaginary part), and z, a nx * ny matrix with the number of interations i used to evaluate the complex point c = x + yi.

Examples

z <- mandelbrot()
# The set is black
image(z, col=c(hcl.colors(n=100, pal="Lisbon"), "black"), las=1)


mariodosreis/fractal documentation built on March 19, 2024, 3:28 p.m.