Fractal Patterns: Mandelbrot and Julia Sets

From the world of sequences, we'll look at sequences generated by the iteration z(n+1) = z(n)^2 + c called theccollins@math.utk.eduquadratic map. The starting value z(1) and the fixed value c are both complex numbers and we'll vary them over various ranges and determine the behavior of the resulting sequences. To make things simple the only behavior we will be looking for is whether or not the sequence isbounded, i.e. if it remains close to the origin.0. Complex BackgroundAll the values we'll be using will be complex numbers, like 1+2i. MATLAB handles complex arithmetic with no extra effort. To enter complex numbers just write 1+2i or 1+2*i or 3.023943-i*72.39 If you have problems it may be because you've accidently changed i from its default value, if so, sayclear iand all should be fine.I. Julia SetsFor each value ofcin the quadratic map, there is a Julia set. The Filled Julia Set is the set of allz(1)such that the valuesz(n)stay bounded. To create the set we take starting values in the box [-2,2]x[-2,2] and for each one we iterate until either we leave the box, or we reach the limit on the number of iterations. If we reach the limit, we say the point is in the set (and draw it).Program InfoInput consists of c (complex) and m (integer). m denotes how many subdivisions we use in the range of parameter values. For example if m=4 then we use c = a+bi where a, b each comes from the values {-2, -1, 0, 1, 2}. So we'll use 25 different values for c in this case. To make the cool color images, keep track of how many iterations it takes before the iterates leave the box. We'll then color the image according to these values. For example if m=4, then we need to store 25 values in a 5x5 array:it. So if we number the possible values for a (and b) from 1 to 5, then we can store the result of our calculation using the 2nd value for a and the 4th value for b in the (2,4) spot in the array, byit(2,4) = kwherekis the number of iterations done. Then to view the resulting picture, just useimage(it). (See below about more about color) This is not an impossible program to write, but it does require two for loops and a while loop, so if you are overwhelmed, you can download a version I wrote: julia.m - color filled julia set (right click and save target in directory C:/matlab???/work) This is a function called by either julia(c,m) or julia(c,m,[xmin xmax ymin ymax]) where the first instance uses the range [-2,2]x[-2,2], and the second instance uses the range [xmin,xmax]x[ymin,ymax]mis the number of points to divide the ranges into. Trym = 50to start. It might take to long to compute with largerm. Here's some values forcyou might try: -1.5 + 0.2i -0.1 + 0.75i -0.4 + 0.8i 0.28 + 0.53i -0.11 + 0.86i -1.32 0.48 + 0.48i 1.5i -0.5 + 0.57i -0.4 + 0.4iII. Mandelbrot SetThere is only one Mandelbrot Set. It is the set of allcvalues, so that starting withz(1) = 0, the valuesz(n)remain bounded. The calculation is the same as for the Julia Set, except thatcis taken from some range andz(1)is fixed. This program is just a slight modification of the Julia Set program. Again, if you don't want to write the program, you can get a copy here: mandel.m - color mandelbrot set It is a function called by either mandel(m) or mandel(m,[xmin xmax ymin ymax]) wheremis the number of points to use in each direction and the range is either the default [-2,2]x[-2,2] or as specified. Again, try small values ofmfirst to see how long it takes.III. (Challenge) Other DEsAny function can be used to generate Julia and Mandelbrot sets. Here's some additional functions you can try: 1. z(n+1) = z(n)^2 + c*z(n) 2. z(n+1) = c*exp(z(n)) 3. z(n+1) = c*sin(z(n)) 4. z(n+1) = z(n)^2/(1 + c*z(n)^2)IV. Useful InformationYou can change the colors by using the command colormapcolormapnamewherecolormapnameis one of: hsv hot gray bone copper pink white flag lines colorcube jet prism cool autumn spring winter summer If you want to print out a graph, you can just choose print from the file menu. If you want to save a graph as a jpeg to put on your webpage, type axis off print -djpegyour_filename.jpgOr you can choose export from the file menu. If you want another type of file, usehelp printto get the options.