Fractals, topology, complex arithmetic and fascinating computer graphics.


 Cleopatra Katrina Freeman
 1 years ago
 Views:
Transcription
1 Chapter 13 Mandelbrot Set Fractals, topology, complex arithmetic and fascinating computer graphics. Benoit Mandelbrot was a Polish/French/American mathematician who has spent most of his career at the IBM Watson Research Center in Yorktown Heights, N.Y. He coined the term fractal and published a very influential book, The Fractal Geometry of Nature, in An image of the now famous Mandelbrot set appeared on the cover of Scientific American in This was about the time that computer graphical displays were becoming widely available. Since then, the Mandelbrot set 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. To get in the mood for the Mandelbrot set, consider the region in the complex plane of trajectories generated by repeated squaring, z k+1 = z 2 k, k = 0, 1,... For which initial values z 0 does this sequence remain bounded as k? It is easy to see that this set is simply the unit disc, z 0 <= 1, shown in figure If z 0 <= 1, the sequence z k remains bounded. But if z 0 > 1, the sequence is unbounded. The boundary of the unit disc is the unit circle, z 0 = 1. There is nothing very difficult or exciting here. The definition is the Mandelbrot set is only slightly more complicated. It involves repeatedly adding in the initial point. The Mandelbrot set is the region in the complex plane consisting of the values z 0 for which the trajectories defined by z k+1 = z 2 k + z 0, k = 0, 1,... remain bounded at k. That s it. That s the entire definition. It s amazing that such a simple definition can produce such fascinating complexity. Copyright c 2011 Cleve Moler Matlab R is a registered trademark of MathWorks, Inc. TM October 2,
2 2 Chapter 13. Mandelbrot Set Figure The unit disc is shown in red. The boundary is simply the unit circle. There is no intricate fringe Figure The Mandelbrot set is shown in red. The fringe just outside the set, shown in black, is a region of rich structure.
3 3 Figure Two trajectories. z0 = i generates a cycle of length four, while nearby z0 = i generates an unbounded trajectory. Figure 13.2 shows the overall geometry of the Mandelbrot set. However, this view does not have the resolution to show the richly detailed structure of the fringe just outside the boundary of the set. In fact, the set has tiny filaments reaching into the fringe region, even though the fringe appears to be solid black in the figure. It has recently been proved that the Mandelbrot set is mathematically connected, but the connected region is sometimes so thin that we cannot resolve it on a graphics screen or even compute it in a reasonable amount of time. To see how the definition works, enter z0 = i z = 0 into Matlab. Then use the uparrow key to repeatedly execute the statement z = z^2 + z0 The first few lines of output are i i i i i... The values eventually settle into a cycle i i i i
4 4 Chapter 13. Mandelbrot Set i... This cycle repeats forever. The trajectory remains bounded. This tells us that the starting value value, z0 = i, is in the Mandelbrot set. The same cycle is shown in the left half of figure On the other hand, start with z0 = i z = 0 and repeatedly execute the statement You will see z = z^2 + z i i i i i... Then, after 24 iterations, i i i e e+002i e e+004i The trajectory is blowing up rapidly. After a few more iterations, the floating point numbers overflow. So this z0 is not in the Mandelbrot set. The same unbounded trajectory is shown in the right half of figure We see that the first value, z0 = i, is in the Mandelbrot set, while the second value, z0 = i, which is nearby, is not. The algorithm doesn t have to wait until z reachs floating point overflow. As soon as z satisfies abs(z) >= 2 subsequent iterations will essential square the value of z and it will behave like 2 2k. Try it yourself. Put these statements on one line. z0 =... z = 0; while abs(z) < 2 z = z^2+z0; disp(z), end
5 5 Use the up arrow and backspace keys to retrieve the statement and change z0 to different values near i. If you have to hit <ctrl>c to break out of an infinite loop, then z0 is in the Mandelbrot set. If the while condition is eventually false and the loop terminates without your help, then z0 is not in the set. The number of iterations required for z to escape the disc of radius 2 provides the basis for showing the detail in the fringe. Let s add an iteration counter to the loop. A quantity we call depth specifies the maximum interation count and thereby determines both the level of detail and the overall computation time. Typical values of depth are several hundred or a few thousand. z0 =... z = 0; k = 0; while abs(z) < 2 && k < depth z = z^2+z0; k = k + 1; end The maximum value of k is depth. If the value of k is less than depth, then z0 is outside the set. Large values of k indicate that z0 is in the fringe, close to the boundary. If k reaches depth then z0 is declared to be inside the Mandelbrot set. Here is a small table of iteration counts s z0 ranges over complex values near i. We have set depth = We see that about half of the values are less than depth; they correspond to points outside of the Mandelbrot set, in the fringe near the boundary. The other half of the values are equal to depth, corresponding to points that are regarded as in the set. If we were to redo the computation with a larger value of depth, the entries that are less than 512 in this table would not change, but some of the entries that are now capped at 512 might increase. The iteration counts can be used as indices into an RGB color map of size depthby3. The first row of this map specifies the color assigned to any points on the z0 grid that lie outside the disc of radius 2. The next few rows provide colors for the points on the z0 grid that generate trajectories that escape quickly. The last row of the map is the color of the points that survive depth iterations and so are in the set.
6 6 Chapter 13. Mandelbrot Set The map used in figure 13.2 emphasizes the set itself and its boundary. The map has 12 rows of white at the beginning, one row of dark red at the end, and black in between. Images that emphasize the structure in the fringe are achieved when the color map varies cyclicly over a few dozen colors. One of the exercises asks you to experiment with color maps. Figure Improving resolution. Array operations. Our script mandelbrot_recap shows how Matlab array arithmetic operates a grid of complex numbers simultaneously and accumulates an array of iteration counters, producing images like those in figure 13.4 The code begins by defining the region in the complex plane to be sampled. A step size of 0.05 gives the coarse resolution shown on the right in the figure. x = 0: 0.05: 0.80; y = x ; The next section of code uses an elegant, but tricky, bit of Matlab indexing known as Tony s Trick. The quantities x and y are onedimensional real arrays of length n, one a column vector and the other a row vector. We want to create a twodimensional nbyn array with elements formed from all possible sums of elements from x and y. z k,j = x k + y j i, i = 1, k, j = 1,..., n This can be done by generating a vector e of length n with all elements equal to one. Then the quantity x(e,:) is a twodimensional array formed by using x, which is the same as x(1,:), n times. Similarly, y(:,e) is a twodimensional arrray containing n copies of the column vector y.
7 7 n = length(x); e = ones(n,1); z0 = x(e,:) + i*y(:,e); If you find it hard to remember Tony s indexing trick, the function meshgrid does the same thing in two steps. [X,Y] = meshgrid(x,y); z0 = X + i*y; Now initialize two more arrays, one for the complex iterates and one for the counts. z = zeros(n,n); c = zeros(n,n); Here is the Mandelbrot iteration repeated depth times. With each iteration we also keep track of the iterates that are still within the circle of radius 2. depth = 32; for k = 1:depth z = z.^2 + z0; c(abs(z) < 2) = k; end We are now finished with z. The actual values of z are not important, only the counts are needed to create the image. Our grid is small enough that we can actually print out the counts c. c The results are c =
8 8 Chapter 13. Mandelbrot Set We see that points in the upper left of the grid, with fairly small initial z0 values, have survived 32 iterations without going outside the circle of radius two, while points in the lower right, with fairly large initial values, have lasted only one or two iterations. The interesting grid points are in between, they are on the fringe. Now comes the final step, making the plot. The image command does the job, even though this is not an image in the usual sense. The count values in c are used as indices into a 32by3 array of RGB color values. In this example, the jet colormap is reversed to give dark red as its first value, pass through shades of green and yellow, and finish with dark blue as its 32nd and final value. image(c) axis image colormap(flipud(jet(depth))) Exercises ask you to increase the resolution by decreasing the step size, thereby producing the other half of figure 13.4, to investigate the effect of changing depth, and to invesigate other color maps. Mandelbrot GUI The exm toolbox function mandelbrot is your starting point for exploration of the Mandelbrot set. With no arguments, the statement mandelbrot provides thumbnail icons of the twelve regions featured in this chapter. The statement mandelbrot(r) with r between 1 and 12 starts with the rth region. The statement mandelbrot(center,width,grid,depth,cmapindx) explores the Mandelbrot set in a square region of the complex plane with the specified center and width, using a gridbygrid grid, an iteration limit of depth, and the color map number cmapindx. The default values of the parameters are center = i width = 3 grid = 512 depth = 256 cmapindx = 1 In other words, mandelbrot(0.5+0i, 3, 512, 256, 1) generates figure 13.2, but with the jets color map. Changing the last argument from 1 to 6 generates the actual figure 13.2 with the fringe color map. On my laptop, these computations each take about half a second. A simple estimate of the execution time is proportional to
9 9 grid^2 * depth So the statement could take mandelbrot(0.5+0i, 3, 2048, 1024, 1) (2048/512) 2 (1024/256) = 64 times as long as the default. However, this is an overestimate and the actual execution time is about 11 seconds. Most of the computational time required to compute the Mandelbrot set is spent updating two arrays z and kz by repeatedly executing the step z = z.^2 + z0; j = (abs(z) < 2); kz(j) = d; This computation can be carried out faster by writing a function mandelbrot_step in C and creating as a Matlab executable or cmex file. Different machines and operating systems require different versions of a mex file, so you should see files with names like mandelbrot_step.mexw32 and mandelbrot_step.glnx64 in the exm toolbox. The mandelbrot gui turns on the Matlab zoom feature. The mouse pointer becomes a small magnifying glass. You can click and release on a point to zoom by a factor of two, or you can click and drag to delineate a new region. The mandelbrot gui provides several uicontrols. Try these as you read along. The listbox at the bottom of the gui allows you to select any of the predefined regions shown in the figures in this chapter. depth. Increase the depth by a factor of 3/2 or 4/3. grid. Refine the grid by a factor of 3/2 or 4/3. The depth and grid size are always a power of two or three times a power of two. Two clicks on the depth or grid button doubles the parameter. color. Cycle through several color maps. jets and hots are cyclic repetitions of short copies of the basic Matlab jet and hot color maps. cmyk cycles through eight basic colors, blue, green, red, cyan, magenta, yellow, gray, and black. fringe is a noncyclic map used for images like figure exit. Close the gui. The Mandelbrot set is self similar. Small regions in the fringe reveal features that are similar to the original set. Figure 13.6, which we have dubbed Mandelbrot
10 10 Chapter 13. Mandelbrot Set Figure The figures in this chapter, and the predefined regions in our mandelbrot program, show these regions in the fringe just outside the Mandelbrot set. Junior, is one example. Figure 13.7, which we call the Plaza, uses our flag colormap to reveal fine detail in red, white and blue. The portion of the boundary of the Mandelbrot set between the two large, nearly circular central regions is known as The Valley of the Seahorses. Figure 13.8 shows the result of zooming in on the peninsula between the two nearly circular regions of the set. The figure can be generated directly with the command mandelbrot( i,0.1,1024,512) We decided to name the image in figure 13.9 the West Wing because it resembles the Xwing fighter that Luke Skywalker flies in Star Wars and because it is located near the leftmost, or far western, portion of the set. The magnification factor is a relatively modest 10 4, so depth does not need to be very large. The command to generate the West Wing is mandelbrot( i,1.5e4,1024,160,1) One of the best known examples of self similarity, the Buzzsaw, is shown in figure It can be generated with mandelbrot( i,...
11 11 4.0e11,1024,2048,2) Taking width = 4.0e11 corresponds to a magnification factor of almost To appreciate the size of this factor, if the original Mandelbrot set fills the screen on your computer, the Buzzsaw is smaller than the individual transistors in your machine s microprocessor. We call figure Nebula because it reminds us of interstellar dust. It is generated by mandelbrot( i,4.88e5,1024,2048,3) The next three images are obtained by carefully zooming on one location. We call them the Vortex, the Microbug, and the Nucleus. mandelbrot( i, e12,1024,2048,2) mandelbrot( i, e13,1024,2048,2) mandelbrot( i, e14,1024,2048,2) The most intricate and colorful image among our examples is figure 13.16, the Geode. It involves a fine grid and a large value of depth and consequently requires a few minutes to compute. mandelbrot( i,6.0e10,2048,4096,1) set. These examples are just a tiny sampling of the structure of the Mandelbrot Further Reading We highly recommend a real time fractal zoomer called XaoS, developed by Thomas Marsh, Jan Hubicka and Zoltan Kovacs, assisted by an international group of volunteers. See If you are expert at using your Web browser and possibly downloading an obscure video codec, take a look at the Wikipedia video Image:Fractalzoom103Mandelbrot_Buzzsaw.ogg It s terrific to watch, but it may be a lot of trouble to get working. Recap %% Mandelbrot Chapter Recap % This is an executable program that illustrates the statements
12 12 Chapter 13. Mandelbrot Set % introduced in the Mandelbrot Chapter of "Experiments in MATLAB". % You can access it with % % mandelbrot_recap % edit mandelbrot_recap % publish mandelbrot_recap % % Related EXM programs % % mandelbrot %% Define the region. x = 0: 0.05: 0.8; y = x ; %% Create the twodimensional complex grid using Tony s indexing trick. n = length(x); e = ones(n,1); z0 = x(e,:) + i*y(:,e); %% Or, do the same thing with meshgrid. [X,Y] = meshgrid(x,y); z0 = X + i*y; %% Initialize the iterates and counts arrays. z = zeros(n,n); c = zeros(n,n); %% Here is the Mandelbrot iteration. depth = 32; for k = 1:depth z = z.^3 + z0; c(abs(z) < 2) = k; end %% Create an image from the counts. c image(c) axis image %% Colors colormap(flipud(jet(depth)))
13 13 Exercises 13.1 Explore. Use the mandelbrot gui to find some interesting regions that, as far as you know, have never been seen before. Give them your own names depth. Modify mandelbrot_recap to reproduce our table of iteration counts for x =.205:.005:.245 and y = .520:.005: First, use depth = 512. Then use larger values of depth and see which table entries change Resolution. Reproduce the image in the right half of figure Big picture. Modify mandelbrot_recap to display the entire Mandelbrot set Color maps. Investigate color maps. Use mandelbrot_recap with a smaller step size and a large value of depth to produce an image. Find how mandelbrot computes the cyclic color maps called jets, hots and sepia. Then use those maps on your image pth power. In either mandelbrot_recap or the mandelbrot gui, change the power in the Mandelbrot iteration to z k+1 = z p k + z 0 for some fixed p 2. If you want to try programming Handle Graphics, add a button to mandelbrot that lets you set p Too much magnification. When the width of the region gets to be smaller than about 10 15, our mandelbrot gui does not work very well. Why? 13.8 Spin the color map. This might not work very well on your computer because it depends on what kind of graphics hardware you have. When you have an interesting region plotted in the figure window, bring up the command window, resize it so that it does not cover the figure window, and enter the command spinmap(10) I won t try to describe what happens you have to see it for yourself. The effect is most dramatic with the seahorses2 region. Enter help spinmap for more details.
14 14 Chapter 13. Mandelbrot Set Figure Region #2, Mandelbrot Junior. The fringe around the Mandelbrot set in self similar. Small versions of the set appear at all levels of magnification. Figure Region #3, Plaza, with the flag color map.
15 15 Figure Region #4. Valley of the Seahorses. Figure Region #5. Our West Wing is located just off the real axis in the thin far western portion of the set, near real(z) =
16 16 Chapter 13. Mandelbrot Set Figure Region #6. Dueling Dragons. Figure Region #7. The Buzzsaw requires a magnification factor of to reveal a tiny copy of the Mandelbrot set.
17 17 Figure Region #8. Nebula. Interstellar dust. Figure Region #9. A vortex, not far from the West Wing. Zoom in on one of the circular microbugs near the left edge.
18 18 Chapter 13. Mandelbrot Set Figure Region #10. A magnification factor reveals a microbug within the vortex. Figure Region #11. The nucleus of the microbug.
19 Figure Region #12. Geode. This colorful image requires a by2048 grid and depth =
Programming from the Ground Up
Programming from the Ground Up Jonathan Bartlett Edited by Dominick Bruno, Jr. Programming from the Ground Up by Jonathan Bartlett Edited by Dominick Bruno, Jr. Copyright 2003 by Jonathan Bartlett Permission
More informationWPF Learner s Guide to Head First C#
Good news! I just approved your request to upgrade your desktop to Windows 2003. There are many projects in Head First C# where you build Windows Store apps that require Windows 8. In this appendix, you'll
More informationELEMENTARY & MIDDLE SCHOOL MATHEMATICS
ELEMENTARY & MIDDLE SCHOOL MATHEMATICS Teaching Developmentally, 5/E 2003 John A.Van de Walle 020538689X Bookstore ISBN Visit www.ablongman.com/replocator to contact your local Allyn & Bacon/Longman
More informationHow to Read MTF Curves
How to Read MTF Curves by H. H. Nasse Carl Zeiss Camera Lens Division December 28 Preface The rules of optics are complex and nasty! This is a nice, honest sentence from an internet discussion about How
More informationIf A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?
Problem 3 If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C? Suggested Questions to ask students about Problem 3 The key to this question
More informationProgramming Your Calculator Casio fx7400g PLUS
Programming Your Calculator Casio fx7400g PLUS Barry Kissane Programming Your Calculator: Casio fx7400g PLUS Published by Shriro Australia Pty Limited 7274 Gibbes Street, Chatswood NSW 2067, Australia
More informationOPRE 6201 : 2. Simplex Method
OPRE 6201 : 2. Simplex Method 1 The Graphical Method: An Example Consider the following linear program: Max 4x 1 +3x 2 Subject to: 2x 1 +3x 2 6 (1) 3x 1 +2x 2 3 (2) 2x 2 5 (3) 2x 1 +x 2 4 (4) x 1, x 2
More informationHow To Make A Scientific Research Poster
How To Make A Scientific Research Poster By: John Elder http://www.makesigns.com How To Make A Scientific Research Poster By John Elder http://www. MakeSigns.com ISBN: 1495212238 Published By MakeSigns.com
More informationAnd so Forth... Copyright J.L. Bezemer 20010406
And so Forth... Copyright J.L. Bezemer 20010406 2 Contents 1 Preface 5 1.1 Copyright........................................... 5 1.2 Introduction.......................................... 5 1.3 About
More informationThe user's guide. CTAnalyser Version 1.13. Contents
CTAnalyser Version 1.13 The user's guide Contents 1. Introduction 3 2. First startup of the program 4 2.1. The licensing of different user profiles 5 2.2. Colicensing of the 3D viewing program ANT and
More informationFACULTY OF SCIENCE SCHOOL OF MATHEMATICS AND STATISTICS FIRST YEAR MAPLE NOTES
FACULTY OF SCIENCE SCHOOL OF MATHEMATICS AND STATISTICS FIRST YEAR MAPLE NOTES 2015 CRICOS Provider Code 00098G c 2015, School of Mathematics and Statistics, UNSW These notes are copyright c the University
More informationPart 1: Jumping into C++... 2 Chapter 1: Introduction and Developer Environment Setup... 4
Part 1: Jumping into C++... 2 Chapter 1: Introduction and Developer Environment Setup... 4 Chapter 2: The Basics of C++... 35 Chapter 3: User Interaction and Saving Information with Variables... 43 Chapter
More informationGuide for Texas Instruments TI83, TI83 Plus, or TI84 Plus Graphing Calculator
Guide for Texas Instruments TI83, TI83 Plus, or TI84 Plus Graphing Calculator This Guide is designed to offer stepbystep instruction for using your TI83, TI83 Plus, or TI84 Plus graphing calculator
More informationWUFI 2D. Calculation Example Step by Step. D. Zirkelbach Th. Schmidt H.M. Künzel M. Kehrer Ch. Bludau
WUFI 2D Calculation Example Step by Step D. Zirkelbach Th. Schmidt H.M. Künzel M. Kehrer Ch. Bludau WUFI 2D Short Introduction PREFACE This introduction will show you how to model a building component
More informationPivot Animator. User guide
1 Pivot Animator User guide 2 Table of Contents Overview...4 Getting Started...5 Interface at a Glance...6 Positioning Figures...8 Figure Controls...11 Animation Frame Controls...13 Saving & Opening Animations...16
More informationSteering User Behavior with Badges
Steering User Behavior with Badges Ashton Anderson Daniel Huttenlocher Jon Kleinberg Jure Leskovec Stanford University Cornell University Cornell University Stanford University ashton@cs.stanford.edu {dph,
More informationIntroduction to Microsoft Publisher : Tools You May Need
Introduction to Microsoft Publisher : Tools You May Need 1. Why use Publisher instead of Word for creating fact sheets, brochures, posters, newsletters, etc.? While both Word and Publisher can create documents
More informationThe role of working spaces in Adobe applications
Technical paper The role of working spaces in Adobe applications Table of contents 1 It s all a numbers game 1 Color models 2 Color spaces 4 Classes of color spaces 4 Design and benefits of RGB workspaces
More informationHot Potatoes version 6
Hot Potatoes version 6 HalfBaked Software Inc., 19982009 p1 Table of Contents Contents 4 General introduction and help 4 What do these programs do? 4 Conditions for using Hot Potatoes 4 Notes for upgraders
More informationRecommendation Systems
Chapter 9 Recommendation Systems There is an extensive class of Web applications that involve predicting user responses to options. Such a facility is called a recommendation system. We shall begin this
More informationINTRODUCTION TO SCILAB
www.scilab.org INTRODUCTION TO SCILAB Consortium scilab Domaine de Voluceau  Rocquencourt  B.P. 10578153 Le Chesnay Cedex France This document has been written by Michaël Baudin from the Scilab Consortium.
More informationThe InStat guide to choosing and interpreting statistical tests
Version 3.0 The InStat guide to choosing and interpreting statistical tests Harvey Motulsky 19902003, GraphPad Software, Inc. All rights reserved. Program design, manual and help screens: Programming:
More informationHow to Think Like a Computer Scientist
How to Think Like a Computer Scientist C Version Allen B. Downey CVersion by Thomas Scheffler Version 1.08 November 25th, 2012 2 Copyright (C) 1999 Allen B. Downey This book is an Open Source Textbook
More informationEquation Editor and MathType: Tips to Make Your Life Easier
Equation Editor and MathType: Tips to Make Your Life Easier Presented by: Bob Mathews Director of Training Design Science, Inc. Email: bobm@dessci.com Welcomee to Equation Editor and MathType: Tips to
More informationHow to Make Your Word 2010 Documents 508Compliant
How to Make Your Word 2010 Documents 508Compliant Centers for Medicare & Medicaid Services Making 508 Easy Continuous Improvement Initiative July 2, 2014 This page intentionally left blank. How to Make
More informationMathematics. Routine Bank
S D C S SAN DIEGO CITY SCHOOLS MIDDLE LEVEL Instruction & Curriculum Mathematics Mathematics Routine Bank Middle Level Routines in Mathematics: Number Sense and Algebraic Thinking page 2 Middle Level Routines
More informationAttention: This material is copyright 19951997 Chris Hecker. All rights reserved.
Attention: This material is copyright 19951997 Chris Hecker. All rights reserved. You have permission to read this article for your own education. You do not have permission to put it on your website
More informationModelling with Implicit Surfaces that Interpolate
Modelling with Implicit Surfaces that Interpolate Greg Turk GVU Center, College of Computing Georgia Institute of Technology James F O Brien EECS, Computer Science Division University of California, Berkeley
More informationA Charging LED B Touchscreen C On/Off button D Speaker E External antenna connector F USB connector G RDSTMC connector H Memory card slot
TomTom ONE XL 1. What s in the box What s in the box a Your TomTom ONE XL A B C D E F G H A Charging LED B Touchscreen C On/Off button D Speaker E External antenna connector F USB connector G RDSTMC connector
More informationSelecting a Subset of Cases in SPSS: The Select Cases Command
Selecting a Subset of Cases in SPSS: The Select Cases Command When analyzing a data file in SPSS, all cases with valid values for the relevant variable(s) are used. If I opened the 1991 U.S. General Social
More information