page_title: Mandelbrot set
section_title: Computer drawings
hierarchical_section_title: Mandelbrot set / Computer drawings
context_page_description: The Mandelbrot set is the set of complex numbers for which the function does not diverge when iterated from, i.e., for which the sequence, etc., remains bounded in absolute value.
  Its definition is credited to Adrien Douady who named it in tribute to the mathematician Benoit Mandelbrot. The set is connected to a Julia set, and related Julia sets produce similarly complex fractal shapes.
  Mandelbrot set images may be created by sampling the complex numbers and testing, for each sample point, whether the sequence goes to infinity. Treating the real and imaginary parts of as image coordinates on the complex plane, pixels may then be coloured according to how soon the sequence crosses an arbitrarily chosen threshold, with a special color used for the values of for which the sequence has not crossed the threshold after the predetermined number of iterations. If is held constant and the initial value of —denoted by —is variable instead, one obtains the corresponding Julia set for each point in the parameter space of the simple function.
context_section_description: There exist a multitude of various algorithms for plotting the Mandelbrot set via a computing device. Here, the most widely used and simplest algorithm will be demonstrated, namely, the naïve "escape time algorithm".
  In the escape time algorithm, a repeating calculation is performed for each x, y point in the plot area and based on the behavior of that calculation, a color is chosen for that pixel.
  The x and y locations of each point are used as starting values in a repeating, or iterating calculation (described in detail below). The result of each iteration is used as the starting values for the next. The values are checked during each iteration to see whether they have reached a critical "escape" condition, or "bailout". If that condition is reached, the calculation is stopped, the pixel is drawn, and the next x, y point is examined.
  The color of each point represents how quickly the values reached the escape point. Often black is used to show values that fail to escape before the iteration limit, and gradually brighter colors are used for points that escape. This gives a visual representation of how many cycles were required before reaching the escape condition.
  To render such an image, the region of the complex plane we are considering is subdivided into a certain number of pixels. To color any such pixel, let  be the midpoint of that pixel. We now iterate the critical point 0 under , checking at each step whether the orbit point has modulus larger than 2. When this is the case, we know that  does not belong to the Mandelbrot set, and we color our pixel according to the number of iterations used to find out. Otherwise, we keep iterating up to a fixed number of steps, after which we decide that our parameter is "probably" in the Mandelbrot set, or at least very close to it, and color the pixel black.
  In pseudocode, this algorithm would look as follows. The algorithm does not use complex numbers and manually simulates complex-number operations using two real numbers, for those who do not have a complex data type. The program may be simplified if the programming language includes complex-data-type operations.
  for each pixel (Px, Py) on the screen do
      x0 = scaled x coordinate of pixel (scaled to lie in the Mandelbrot X scale (-2.5, 1))
      y0 = scaled y coordinate of pixel (scaled to lie in the Mandelbrot Y scale (-1, 1))
      x := 0.0
      y := 0.0
      iteration := 0
      max_iteration := 1000
      while (x*x + y*y ≤ 2*2 AND iteration < max_iteration) do
          xtemp := x*x - y*y + x0
          y := 2*x*y + y0
          x := xtemp
          iteration := iteration + 1
   
      color := palette[iteration]
      plot(Px, Py, color)
  Here, relating the pseudocode to ,  and :
  and so, as can be seen in the pseudocode in the computation of x and y:
   and 
  To get colorful images of the set, the assignment of a color to each value of the number of executed iterations can be made using one of a variety of functions (linear, exponential, etc.).
caption: Still image of a movie of increasing magnification on 0.001643721971153 − 0.822467633298876i
exif: {}