/** ![[This 5 Megapixel image](https://upload.wikimedia.org/wikipedia/commons/2/21/Mandel_zoom_00_mandelbrot_set.jpg) (click for full resolution) provided via Wikipedia does not statisfy our thirst for resolution. Image courtesy of Wolfgang Beyer.](https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Mandel_zoom_00_mandelbrot_set.jpg/220px-Mandel_zoom_00_mandelbrot_set.jpg) # A High-Resultion Visualization of the Mandelbrotset Using a Quadtree Grid. For a given complex number $c$ one can define the sequence of numbers $z_{n}$ indexed with n as, $$z_{n+1}=z_n^2+c,$$ starting from $z_0=c$. It can be shown that the sequence diverges in an absolute sense if $z_nz_n^* > 2$. The mandelbrot set can be visualized using color coding for the amount of iterations it takes to get $z_n$ such that $z_nz_n^* \geq 2$. Furthermore, there are sequenses that do not diverge (eg. the sequence corresponding to $c=-1$). Therefore we choose to stop checking for divergence after $n_{max}=2000$ iterations. On this page we have a look at the scaling of the number of grid cells required to make a smooth looking image of the set. We will produce an image at the maximum resolution of 16384 x 16384 pixels (=268 Megapixels), or 14 levels of quadtree refinement. A link will be provided to the result of a 16 Gigapixel redering, using 17 levels of refinement. Notice that this (uncompressed) PPM image will be approx. 800 Megabytes in size. Outputting directly to a more sensible format causes crashes when using the inbuild converter. For the most part we use a similar methods as presented on to the [zoom-in-of-the-Mandelbrot-set page](mandelbrot.c). */ #include "grid/quadtree.h" #include "utils.h" void costumcmap (double cmap[NCMAP][3]){ for (int i = 0; i < NCMAP; i++){ cmap[i][0]=sq(sin((double)i*M_PI/64.)); cmap[i][1]=sq(sin(((double)i+20.)*M_PI/64.)); cmap[i][2]=sq(sin(((double)i+40.)*M_PI/64.)); } cmap[NCMAP-1][0]=0; cmap[NCMAP-1][1]=0; cmap[NCMAP-1][2]=0; } double xz=-0.75; double yz=0; scalar cc[],m[],c[]; double jmax=2000.; int maxlevel = 14; int minlevel = 3; double f=1.4; /** We define a function that calculates how many iterations it takes before the aforementioned sequence diverges. If it does not diverge within *jmax* iterations, it will return *jmax*. Also we track the total number of iterations made for each snapshot. */ double determine_iterations(double x,double y){ double j=0.; double xx=xz+(x/f); double yy=yz+(y/f); double a=xx; double b=yy; double c; double ab=(sq(a)+sq(b)); while (j