Experiments with MATLAB Mandelbrot Set Roger Jang (張智星) CSIE Dept, National Taiwan University jang@mirlab.org http://mirlab.org/jang Mandelbrot Set • The Fractal Geometry of Nature – By Benoit Mandelbrot, 1982 • Mandelbrot Set – Appeared on the cover of Scientific American in 1985, which is about the time that computer graphical displays were first becoming widely available – Has stimulated deep research topics in mathematics and has also been the basis for an uncountable number of graphics projects, hardware demos, and Web pages 2 Convergence for Iterations of Complex Numbers • Iteration: zk 1 zk2 , k 0,1,... • Consider the region in the complex plane consisting of the initial values for which the iteration remain bounded as k approaches infinity. • Alternatively: z | lim z 0 n n is bounded with zk 1 zk2 , k 0,1,... 3 Definition of the Mandelbrot set • z | lim z 0 n n is bounded with zk 1 zk2 z0 , k 0,1,... – Red: Mandelbrot Set – Black: Region of rich structure 4 Examples • Point inside the set – z0 = .25-.54i generates a cycle of length four – Verification z0 = .25-.54i; z = 0; z=z^2+z0 • Point outside the set – z0 = .22-.54i generates an unbounded trajectory – Manual test z0 = .22-.54i; z = 0; z=z^2+z0 5 Details of the Fringe • Criterion for divergence – As soon as z satisfies abs(z)>2, subsequent iterations essentially square the value of abs(z) and diverge. • Display – The number of iterations required for z to escape the disc of radius 2 provides the basis for showing the detail in the fringe. – We can then use different colors to represent the above iteration count. 6 Implementation Minutes • Code snippet function k = M(z0, maxCount) z = 0; k = 0; while abs(z)<2 && k< maxCount z = z^2+z0; k = k + 1; end • Observations – The value returned by this function is between 1 and maxCount. – If the value is maxCount, then z0 is in the set. – We can use the value as an index into a color map of size maxCount-by-3. 7 Demos • mandelbrot – thumbnail icons of the twelve regions • mandelbrot(r) – r=1~12 starts with r-th interesting regions outside the Mandelbrot set. – Titles of the plots • • • • • • • • • • • • • r=1full r=2mini mandelbrot r=3plaza r=4seahorses r=5west wing r=6dueling dragons r=7buzzsaw r=8nebula r=9vortex1 r=10vortex2 r=11vortex3 r=12geode (deep detail) mandelbrot(center,width,grid,depth,c mapindx) 8 “The Valley of the Seahorses” • Commands – mandelbrot(4) – mandelbrot(-.7700.1300i, 0.1, 1024, 512) • Fun thing to try – Try “spinmap(5, 1)”! -0.08 -0.09 -0.1 -0.11 -0.12 -0.13 -0.14 -0.15 -0.16 -0.17 -0.18 -0.82 -0.81 -0.8 -0.79 -0.78 -0.77 -0.76 -0.75 -0.74 9 -0.73 -0.72 “Buzzsaw” • Commands – mandelbrot(7) – mandelbrot(0.00164372 1971153+0.8224676332 98876i, 4.0e-11, 1024, 2048, 2) • Observations – It’s as small as a the cross-section of a hair – Try “spinmap(5, 1)”! – Self-similarity! -11 2 0.001643721971153 + 0.822467633298876i x 10 1 0 -1 -2 -2 -1 0 1 10 2 -11 x 10 “Vortex” • Commands -12 – mandelbrot(9) – mandelbrot(1.749759145130366460.00000000368513796i, 6.0e-12, 1024, 2048, 2) • Observations – It’s as small as a the cross-section of a hair – Try “spinmap(5, 1)”! 3 -1.7497591451303665 - 0.0000000036851380i x 10 2 1 0 -1 -2 -3 -3 -2 -1 0 1 2 11 3 -12 x 10 “Geode” • Commands – mandelbrot(12) – mandelbrot(0.28692299 709-0.01218247138i, 6.0e-10, 2048, 4096, 1) -10 3 0.28692299709000 - 0.01218247138000i x 10 2 1 • Observations – Try “spinmap(5, 1)”! – Self-similarity! 0 -1 -2 -3 -3 -2 -1 0 1 2 12 3 -10 x 10