**Introduction**

**What is the Mandelbrot set? A mathematician might say it was the locus of
points, C, for which the series Zn+1 = Zn * Zn + C, Z0 = (0,0) is bounded by a
circle of radius two, centered on the origin.**

**But most of us aren't mathematicians.**

**It's a pretty picture.****It's a mathematical wonder that we can appreciate, and to some extent understand, even if we don't understand the first paragraph.****It's just one example of an amazing new science with applications as far ranging as weather forecasting, population biology, and computerized plant creation.****It's a floor wax and a dessert topping!****It's all of these and more.**

**One of the fascinating things about the Mandelbrot set is the seeming
contradiction in it. It is said to be the most complex object in mathematics,
perhaps the most complex object ever seen. But at the same time, it is generated
by an almost absurdly simple formula. Multiply Z by itself. Add C. The answer is
the new value for Z. Repeat until the absolute value of Z is greater than two,
or until our counter expires. If abs(Z) ever exceeds two, then it will very
quickly head off towards infinity which means that the point is not in the
Mandelbrot set (that's the definition of the Mandelbrot set). These points are
typically assigned a colour based on how many iterations were done before abs(Z)
exceeded two. If abs(Z) doesn't exceed two after a large number of iterations,
then we give up and assume that the initial point is in the Mandelbrot set.
These points are typically coloured black. The black, barnacle covered pear is
the Mandelbrot set proper - all the bands of colour outside of it are simply
curious artifacts that help to expose the detail of the Mandelbrot set itself.**

#include "stdio.h" #define MaxIters 200 #define SIZE 80 #define BLACK -1 #define LEFT -2.0 #define RIGHT 1.0 #define TOP 1.0 #define BOTTOM -1.0 main(int argc, char *argv[]) { short x, y, count; long double zr, zi, cr, ci; long double rsquared, isquared; for (y = 0; y < SIZE; y++) { for (x = 0; x < SIZE; x++) { zr = 0.0; zi = 0.0; cr = LEFT + x * (RIGHT - LEFT) / SIZE; ci = TOP + y * (BOTTOM - TOP) / SIZE; rsquared = zr * zr; isquared = zi * zi; for (count = 0; rsquared + isquared <= 4.0 && count < MaxIters; count++) { zi = zr * zi * 2; zi += ci; zr = rsquared - isquared; zr += cr; rsquared = zr * zr; isquared = zi * zi; } if (rsquared + isquared <= 4.0) printf("*"); else printf(" "); } printf("\n"); } return 0; }

for (count = 0; rsquared + isquared <= 4.0 && count < MaxIters; count++) { zi = zr * zi * 2; zi += ci; zr = rsquared - isquared; zr += cr; rsquared = zr * zr; isquared = zi * zi; }

**Numbers that aren't multiplied by i, regular numbers, are called real
numbers. Simple enough.**

Complex Z = (0 + 0i) Complex C = (a + bi) for (count = 0; ABS(Z) <= 2.0 && count < MaxIters; count++) Z = Z * Z + C;