If you haven’t used Matlab before, I recommend you spend half-an-hour going through the first few sections of the Matlab Primer to familiarize yourself with the basis syntax. In particular, you should learn how to enter and manipulate matrices (with real or complex entries) and generate basic plots.
To test your understanding, can you — without using any loops — generate a 10-by-10 matrix whose -th entry is ? How about one whose -th entry is ? And, finally, one whose -th entry is if and if ? (Hint: Consider .) Now plot a 10-by-10 grid so that the box at position is one color if and another color if . You’ll want to use the “image” command or something similar. If you want to choose the colors, look up the “colormap” command.
As our first nontrivial Matlab activity, we’ll generate pictures of Mandelbrot sets. The classical Mandelbrot set is defined as follows. For complex numbers and , define . For , we define . We define the -orbit of to be the set . The Mandelbrot set is defined to be the set of complex numbers for which the -orbit of is bounded. In other words, is the set of such that does not tend to infinity as grows.
Let be a small number, say to start with. To generate a picture of the Mandelbrot set (with resolution ) we want to build a matrix such that if and if . For simplicity, you can assume that if . I suggest you start by building a 101-by-101 matrix whose -th entry is , and a zero matrix of the same size. With this setup, the recursion is simply Z=Z.^2+C. (In Matlab, Z.^2 squares each entry of the matrix Z.) After you can generate a picture, try playing with the resolution parameter and the range of values in to get a “nicer” picture. In particular, try making the entries of symmetric about instead of lying in the first quadrant. (Nicer is subjective, of course.)
Now, generate yourself a personal Mandelbrot set by replacing by or some other interesting function of your choice involving a parameter . Make a nice picture of your personal Mandelbrot set. Submit printout of the picture, together with the Matlab code you used to generated it, as part of HW 1. Here’s mine, drawn with symmetrically around :