Theoretical Paper
- Computer Organization
- Data Structure
- Digital Electronics
- Object Oriented Programming
- Discrete Mathematics
- Graph Theory
- Operating Systems
- Software Engineering
- Computer Graphics
- Database Management System
- Operation Research
- Computer Networking
- Image Processing
- Internet Technologies
- Micro Processor
- E-Commerce & ERP
Practical Paper
Industrial Training
Mendelbrot Set
Mendelbrot Set
According to traditional geometry, the line is still a one-dimensional figure, but intuitively we feel that it must now be two-dimensional. If this is the case, then when did the transition take place? How complex must a line be before it ceases to be a one-dimensional object and becomes two-dimensional. During the period from 1875 to 1925, mathematicians wrestled with this problems. It was the mathematician Felix Hausdorff who conceived the idea of fractional dimensions. According to this concept, the integer dimensions do not provide an adequate description of the nature of geometric figures. Instead, a whole spectrum of fractional dimensions that are non-integers is needed, so that the dimension of a particular line might be, for example, 1,46789. Hausdorff set up some criteria for determining how to specify the dimension of various geometric figures. They don't concern us here, for we are interested in the figures having fractional dimensions rather than the nature of the dimension itself.
An expression to define a figure having fractional dimensions can often be quite simple, but creating the figure itself requires iterative computations, sometimes many thousands of them. Lacking computers to do such computations, only a few figures were produced through painful tedious hand calculations and plotting. Thus the field of investigation remained static for many years, until the power of modern computers could be brought to bear on the subject. In recent years, Dr. Benoit Mandelbrot has conducted extensive investigations into these figures, and it is he who coined the term "fractal" to define a geometric figure whose Hausdorff-Besicovitch dimension exceeds its topological dimension.
We can generate fractals by using some function which may be a coordinates of a point or a complex number. Some transformation is applied to this function and the same transformation is applied to the result and so forth. This we can do infinite number of times. But it is observed that interesting results have been achieved before 1000 iterations.
Here is the Mendelbrot Set through which you can draw an interesting figure:
We have the iterated function:
zn+1 = zn2 + k
where k is a complex number.
k = a + bi
Here, Mendelbrot set is the set of all values of k for which if z0 is 0, z remains finite, irrespective of number of iterations. To plot this function we represent the value of k, with the x axis showing the value of a and the y axis showing the value of b. We then perform a number ( say 1000 ) iterations of the equation and if the result does not blow up we assume that the value of k is part of the Mandelbrot set and color it black. If the point does blow up, we color it with different colors to indicate how many iterations were required before blow up occurred.
Here is a program that displays the figure of Mendelbrot Set:
#include <graphics.h>
const int maxcol = 639 ;
const int maxrow = 479 ;
const int max_colors = 8 ;
int max_iterations = 512 ;
int max_size = 4 ;
float q[350] ;
main( )
{
float pmax = 1.75, pmin = -1.75, qmax = 1.5, qmin = -1.5 ;
float p, deltap, deltaq, x, y, xsquare, ysquare ;
int color, row, col, gd = DETECT, gm ;
initgraph ( &gd, &gm, "c:\\tc\\bgi" ) ;
deltap = ( pmax - pmin ) / ( maxcol - 1 ) ;
deltaq = ( qmax - qmin ) / ( maxrow - 1 ) ;
for ( row = 0 ; row <= maxrow ; row++ )
q[row] = qmin + row * deltaq ;
for ( col = 0 ; col <= maxcol ; col++ )
{
p = pmin + col * deltap ;
for ( row = 0 ; row <= maxrow ; row++ )
{
x = y = 0.0 ;
color = 0 ;
for ( color = 0 ; color < max_iterations ; color++ )
{
xsquare = x * x ;
ysquare = y * y ;
if ( ( xsquare + ysquare ) > max_size )
break ;
y = 2 * x * y + q[row] ;
x = xsquare - ysquare + p ;
}
putpixel ( col, row, color % max_colors ) ;
}
}
getch( ) ;
closegraph( ) ;
restorecrtmode( ) ;
}
Here most of the time is spent in calculating the values of the parts of the drawing that are colorless and do not contain any useful information. Also most of the calculation time is spent within the inner loop. Thus, to minimize calculation time, the calculations that takes place within the loop must be minimized. To achieve this, code has been optimized and the values of q and p have been calculated outside the loop so they are not recalculated at every pass.