
Mandelbrot One-Liner
By:
simonjtyler on
Dec 1st, 2011 | syntax:
None | size: 0.87 KB | hits: 137 | expires: Never
(* http://blog.wolfram.com/2011/12/01/the-2011-mathematica-one-liner-competition/ *)
(* Stephan Leibbrandt's Mandelbrot one-liner *)
(* Escape times for Mandelbrot set *)
data = Compile[{}, Block[{i, x, p},
Table[i = 0; x = 0. I; p = r + I c;
While[Abs@x <= Sqrt[2] && i < 9^3, x = x^2 + p; ++i];
i, {c, -1, 1, .01}, {r, -2, 1, .01}]]][];
(* Examine behaviour of scaling function tanh *)
Manipulate[Plot[Tanh[Power[x/c, (i)^-1]], {x, .1, 9^3},
PlotRange -> {0, 1}], {c, 1, 729}, {i, 1, 10}]
(* Note that image interprets a 2d array of numbers as a grayscale data. *)
(* Numbers outside of [0,1] are truncated. As a simple example, play with *)
Image[Table[i*j/100, {i, 10}, {j, 10}]]
(* Produce a range of Mandelbrot images *)
Table[{i, c, Image[Tanh[Power[data/9.0^c, (i)^-1]],
ImageSize -> Small]}, {i, 2, 10}, {c, 1, 3}]