MANDELBROT_ASCII
Generate an ASCII Image of the Mandelbrot Set


MANDELBROT_ASCII is a C program which generates an ASCII image of the Mandelbrot set using two lines of C code.

The Mandelbrot set is a set of points C in the complex plane with the property that the iteration

        z(n+1) = z(n)^2 + c
      
remains bounded.

All the points in the Mandelbrot set are known to lie within the circle of radius 2 and center at the origin.

To make a plot of the Mandelbrot set, one starts with a given point C and carries out the iteration for a fixed number of steps. If the iterates never exceed 2 in magnitude, the point C is taken to be a member of the Mandelbrot set.

The MANDELBROT_ASCII program makes an image of the Mandelbrot set using ASCII graphics, sometimes called "typewriter graphics". Moreover, the entire program consists of a pair of cryptic lines of text:

main(n){float r,i,R,I,b;for(i=-1;i<1;i+=.06,puts(""))for(r=-2;I=i,(R=r)<1;
r+=.03,putchar(n+31))for(n=0;b=I*I,26>n++&&R*R+b<4;I=2*R*I+i,R=R*R-b+r);}
      

Working out how the program can do what it does is a true puzzle!

Languages:

MANDELBROT_ASCII is available in a C version.

Related Data and Programs:

ASCII_ART_GRAYSCALE, a data directory of examples of grayscale "ASCII Art" files, in which images are created using printable characters.

JULIA, a C program which generates a TGA or TARGA graphics file of a Julia set.

MANDELBROT, a C program which generates an ASCII PPM image of the Mandelbrot fractal set;

MANDELBROT_PPM, a C program which generates a binary PPM image of the Mandelbrot fractal set;

PIG_LATIN, a C program which converts its input to Pig Latin; a winner of the International Obfuscated C Code Competition in the "Most Humorous" category, by Don Dodson.

Reference:

  1. Alexander Dewdney,
    A computer microscope zooms in for a close look at the most complicated object in mathematics,
    Scientific American,
    Volume 257, Number 8, August 1985, pages 16-24.
  2. Heinz-Otto Peitgen, Hartmut Juergens, Dietmar Saupe,
    Chaos and Fractals - New Frontiers in Science,
    Springer, 1992,
    ISBN: 0-387-20229-3,
    LC: Q172.5.C45.P45.

Source Code:

Examples and Tests:

You can go up one level to the C source codes.


Last revised on 13 October 2011.