# Super-easy Collatz snowman fractal

January 02 2014

5

It is a relatively recent innovation that complex-number computations can be done in the evalhf environment. When combined with plots:-densityplot, this makes escape-time fractals in the complex domain very easy to plot. This fractal is based on the Collatz problem. This Wikipedia article has a high-resolution picture of this fractal. I've switched the real and imaginary axes and reversed the direction of the real axis purely for asthetic reasons.

 Collatz:= proc(b,a)  #Axes switched local z:= -a+b*I, k;  #real part negated      for k to 31 while abs(Im(z)) < 1 do           z:= (1+4*z-(1+2*z)*cos(Pi*z))/4      end do;      k #escape time end proc: #Test evalhf'ability: evalhf(Collatz(0,1)); plotsetup(      jpeg, plotoutput= "C:/Users/Carl/desktop/Collatz.jpg",      plotoptions="height= 1024, width= 1024, quality= 95" );   CodeTools:-Usage(      plots:-densityplot(           Collatz,           -1..1, # imaginary range           -0.5..4.5, #negative of real range           colorstyle= HUE, grid= [1024, 1024], style= patchnogrid,           labels= [Im,-Re], labelfont= [TIMES, BOLD, 14],          axes= boxed,           caption= cat("      Happy New Year ",                                   StringTools:-FormatTime("%Y")),           captionfont= [HELVETICA, BOLDOBLIQUE, 18]      ) ); memory used=24.08MiB, alloc change=24.00MiB, cpu time=7.78s, real time=7.79s