% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/demo_api-mandelbrot.R
\name{mandelbrot}
\alias{mandelbrot}
\alias{as.raster.Mandelbrot}
\alias{plot.Mandelbrot}
\alias{mandelbrot_tiles}
\alias{mandelbrot.matrix}
\alias{mandelbrot.numeric}
\title{Mandelbrot convergence counts}
\usage{
mandelbrot(...)

\method{mandelbrot}{matrix}(Z, maxIter = 200L, tau = 2, ...)

\method{mandelbrot}{numeric}(
  xmid = -0.75,
  ymid = 0,
  side = 3,
  resolution = 400L,
  maxIter = 200L,
  tau = 2,
  ...
)
}
\arguments{
\item{Z}{A complex matrix (\eqn{Z}) for which convergence
counts (\eqn{C}) should be calculated.}

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

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

\item{xmid, ymid, side, resolution}{Alternative specification of
the complex plane \code{Z}, where
\code{mean(Re(Z)) == xmid},
\code{mean(Im(Z)) == ymid},
\code{diff(range(Re(Z))) == side},
\code{diff(range(Im(Z))) == side}, and
\code{dim(Z) == c(resolution, resolution)}.}
}
\value{
Returns an integer matrix (of class Mandelbrot) with
non-negative counts (\eqn{C}).
}
\description{
Mandelbrot convergence counts
}
\section{Escape time algorithm}{

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

\examples{
counts <- mandelbrot(xmid = -0.75, ymid = 0, side = 3)
str(counts)
\dontrun{
plot(counts)
}

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

}
\references{
Mandelbrot set, \url{https://en.wikipedia.org/wiki/Mandelbrot_set}, 2026
}
\keyword{internal}
