As the logistic function the mandelbrot set depends on one variable, although a complex variable with its imaginary and real part:


The important part is the orbit stability or if it stays bounded, that can be obtained by iterating a predetermined number with, e.g., a C function. The orbit is unstable if tends to infinity, the c function will ignore an orbit if surpasses a known limit:


The condition sets the Mandelbrot boundary,The iteration counts can be used into an RGB color map, the image and its colors obtained with the c function emphasizes the boundary and its depth showing how many times the magnitude(|z|) keeps inside the chosen limit. Now comes the last step, making the plot.


#include < stdio.h >
#include < math.h >
#include < stdlib.h >


#define M 20

A structure and a local function:

struct complex
	double re, im;
}x, c;

double module(struct complex x)
	return sqrt(**;

An the main function:

int main(int argc, char** argv)
	double xx;
	int n, count;
	struct complex;

	FILE *fout;
	fout=fopen("Mandelbrot.dat", "w");

The final part you have to itinerate the function adding up how many times falls inside the limit condition - the “for ” or a “while” structure will do the job -, using a rectangle with steps of 0.005. As an example:

Re c in delim{[}{-2;0,5}{]} , Im c in delim{[}{-1;1}{]}

The file will be generated using:

fprintf(fout, "%gt %g %dn",,, count);

The linux user will open the file by typing in his terminal:

Plot [-2:0.5][-1:1] 'mandelbrot.dat' u 1:2:3 w image