hi i am a novice to c++ and have been doodling with borland graphics interface with dev 4.9.9.1
below is a programme i have written which calculates the mandelbrot set (all complex number c such that |z(k)| remained bounded subject to endless iteration z(n+1)=(z(n))^2+c, z(0)=c)).
the problem with it is that when the graphics is generated, it looks like the mandelbrot set, but a grossly inaccurate representation. my guess is the limited number of significant figures c++ truncates for each calculation. any idea on increasing the number of significant figures? (something like what Window's calculator is capable of) thanks 4 the assistance!Code:#include <iostream.h> #include <stdlib.h> #include <winbgim.h> int main(){ initwindow(800,600); for(int x=0; x<=800; x++) { for(int y=0; y<=600; y++) { long double x_re = -2.0 + x*0.005; long double y_im = 1.5 - y*0.005; long double x_0 = x_re, y_0 = y_im; short terminating=0, i=0; do{ x_0=(x_0*x_0-y_0*y_0+x_re); y_0=(2.0*x_0*y_0+y_im); terminating++; if(x_0*x_0+y_0*y_0>4.0){ i=1; break; } }while(terminating<1000); if(i) continue; else putpixel(x,y,1); } } while(!kbhit()); closegraph(); return 0; }



LinkBack URL
About LinkBacks


