Final Programming Project

As part of your final exam grade in this course, you will be required to write a MATLAB program according to the specifications given below. You will have from now until the final exam's due date to work on this project.

**Program Specifications**

The purpose of your program will be to draw fractals from Iterated Functions Systems. You will be implementing the randomized algorithm as described in section 5.5.3 of our text. The fractal will be the fixed "point" of the IFS F=f_{1} u ... u f_{n}, where each f_{i} is a 2x2 linear function. Your program must read in data in the nx6 format as described in the text (see section 5.4.4). The following may serve as the header/help topic of your file:

% IFSFRAC Draws the fractal defined by an iterated function system % FINAL PROGRAMMING PROJECT: Math 181 (Dynamical Systems) % SUBMITTED BY: (Your Name Here) % % IFSFRAC(M,K) draws the fractal defined by the iterated function % system in the matrix M. K data points are plotted in the image. % M represents n 2x2 linear functions of the form f(x) = Ax+b. % M is an nx6 matrix containing the data for one function per row. % For example, % M = [.5 0 0 .5 0 0 % .5 0 0 .5 .5 0 % .5 0 0 .5 .25 .5] % is the three-function system defining Sierpinski's triangle. % % Example: % ifsfrac(M,5000); function output = fracnew(C,k)In writing your program, you are welcome to cannibalize any previously written or provided code from this course (there are specific places where it may be in your best interest to do so). There are certain features your program must contain:

- Different f
_{i}component functions will cover different areas within the unit square. When "radomly" choosing the next function to apply, the f_{i}should*not*be chosen with equal probability; rather, they should be chosen with probabilities proportional to their areas (or determinants). However, we don't want to completely exclude functions with zero determinants, so these should be assigned some minimum positive probability. The m-file "randp.m" provided with hw#4 may help in "chosing" your next function. - The function should be iterated several (perhaps 20) times prior to plotting points. This way, regardless of the starting point of your iterations, the points plotted will appear to be within the fractal.
- Your function should do at least some elementary error checking.
For example, if the input M is not some nx6 matrix, you should return an error message.
Also, you may want to check that the functions f
_{i}are actually contraction maps, and at least warn the user if they are not. - Your function may output (return) anything you like, or nothing at all. While it should make an internal call to the "plot" function, the return value of the function (indicated above in the variable named "output") could be used for error checking, may return data about the IFS, or may be unused. If you do use it, be sure to indicate in your help topic what it's doing.
- Your code should be well-commented, so that I can follow the basics of it without reading every line of code. Don't go nuts, though. After the help topic, your lines of comment shouldn't exceed your lines of code! Also, use standard code-indenting to indicate the block structure of your code.
- Your program should correctly draw fractals for the data sets contained in
fracdata.m. There are 7 data sets in this file, named
Sier Koch Frac1 Frac2 Frac3 Frac4 Frac5

You may download this file into your MATLAB directory, then load this data into MATLAB's memory by simply typing "fracdata" at the MATLAB command line. - You are welcome to add any additional features or specifications you choose. For example, my function accepts an optional third argument that, when set, prevents the figure from being redrawn. That way, if my picture is not full enough after 5000 points, instead of starting over, I may continue drawing on top of the old plot. For examples of optional arguments, see "vecfield.m" from hw#6. Drawing boxes showing your transforms or color-coding your points are some other ideas. Extra features are encouraged but not required, but will receive extra credit based entirely upon my whim. Any features added should be well-documented in you program's help topic.

**Assignment Specifications**

- You have from now until the due date of the final exam to work on this project.
- Your grade on this project will count as 25% of your final exam grade.
It is to be considered as part of your final exam with regards to class rules.
In particular, you are not to discuss this project
*in any way whatsoever*with any of your classmates, or anyone else except me. It should be entirely your own work. NO EXCEPTIONS! - If you run into problems, I am willing to provide some minor assistance. In this case, it is preferred that you see me in person, as it is harder for me to provide appropriate feedback via e-mail. While I have provided more extensive programming help via e-mail on homeworks, for this project I will provided little more feedback that "the problem is on line 23" if you send me an e-mail help request. This is liable to result in very slow progress working through any problems. I will be somewhat more forthcoming if you see me in person (although, again, not as much as I was with homework). If you do intend to see me regarding a programming problem, please either bring your code on a disk or e-mail it to me ahead of time.
- The project you submit should include a print-out of your code,
and a print-out of each of the 7 fractal images generated from the IFS matrices provided in
fracdata.m.
You should also e-mail me a copy of your code so that I can test it for myself.
Do
*not*submit any diary files or other unrequested material. - For extra credit, devise your own fractal(s). Generate your own IFS data for a neat looking picture. Points will be awarded for pretty pictures. If you make up your own fractal, e-mail me the IFS data for your fractal, and just turn in a printout of the picture.

Email: