Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!

# Mandelbrot One-Liner

By: simonjtyler on Dec 1st, 2011  |  syntax: None  |  size: 0.87 KB  |  views: 231  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. (* http://blog.wolfram.com/2011/12/01/the-2011-mathematica-one-liner-competition/ *)
2. (* Stephan Leibbrandt's Mandelbrot one-liner *)
3.
4.
5. (* Escape times for Mandelbrot set *)
6.
7. data = Compile[{}, Block[{i, x, p},
8.      Table[i = 0; x = 0. I; p = r + I c;
9.       While[Abs@x <= Sqrt[2] && i < 9^3, x = x^2 + p; ++i];
10.       i, {c, -1, 1, .01}, {r, -2, 1, .01}]]][];
11.
12.
13. (* Examine behaviour of scaling function tanh *)
14.
15. Manipulate[Plot[Tanh[Power[x/c, (i)^-1]], {x, .1, 9^3},
16.   PlotRange -> {0, 1}], {c, 1, 729}, {i, 1, 10}]
17.
18.
19. (* Note that image interprets a 2d array of numbers as a grayscale data. *)
20. (* Numbers outside of [0,1] are truncated. As a simple example, play with *)
21.
22. Image[Table[i*j/100, {i, 10}, {j, 10}]]
23.
24.
25. (* Produce a range of Mandelbrot images *)
26.
27. Table[{i, c, Image[Tanh[Power[data/9.0^c, (i)^-1]],
28.   ImageSize -> Small]}, {i, 2, 10}, {c, 1, 3}]
clone this paste RAW Paste Data
Top