Math 171 - Alexiades
                  Lab 12
                Fractals
See Julia Set for background.

Note: You can enter complex numbers in Matlab using i like: 0.3-0.4i or as 0.3-0.4*i

A. julia1.m code:  
  Implement the "escape-time algorithm" in a matlab script "julia1.m".
  Set all parameters in the code. Good default values are: M=200; W=2; R=2; maxIT=20; Ncolors=64;
  and to start with: c = −1−0.25i
  The code should:
  1. Construct x-grid and y-grid (y=x) in the square window [−W , W]×[−W , W].
    Initialize the colors array: IT=zeros(M+1,M+1);
  2. Pick each grid point (xix , yjy) , for ix=1:M+1 and for jy=1:M+1,   as starting z (complex number): z = xix + yjyi ;
  3. Iterate ( for n=0:maxIT ) the quadratic z = z*z + c; for this z until the orbit "escapes" outside the circle of radius R.
    When it does, record the index n into the IT array: IT( jy, ix ) = n ;   and break the iteration loop.
  4. Scale IT from 0 to Ncolors: IT = Ncolors * ( 1 − IT / maxIT );
  5. Plot the IT array: pcolors( IT ), shading('flat')

Play around with the program trying different parameter values to see the effect,
e.g.   M = 50 or 200 or 400 ,   R = 1 or 3 ,   maxIT = 50
Different fractal shapes appear for different c . Some interesting ones are:
c = −1,   c = 0.4+0.3i ,   c = 0.8i ,   c = 0+i ("dendrite") ,   c = −0.123+0.745i ("Douadi rabbit").

B. julia2.m code:
  a. Copy your (debugged) "julia1.m" to new file "julia2.m" and modify it into a
    Matlab function with two input arguments: M , c . Test and debug with various inputs.
  b. Then make it more flexible, so as one can call it with 2 or 1 or 0 arguments
    [use  "if( nargin ) < 1"   and   "if( nargin ) < 2" and insert defaults for appropriate parameters in each case].
    Test and debug with 2 input arguments: (M,c), with 1 argument: (M), and with no arguments.
  c. Insert short comments explaining what is being done.

C. Prepare for submission:
1. Copy your "julia2.m" code to "julia.m"
2. Edit the "julia.m" file to clean it up.
3. At the top insert % Name , Date , Lab12
4. Then insert the c value that generated your favored pattern: % my favored c = ????
5. Insert separator: %======================================
6. Run it with your favored c and M=200
7. Publish it on Matlab: e.g. if c = −1−0.3i :   publish( 'julia(200, -1-0.3i)' , 'pdf' )
8. Check the resulting "julia.pdf" to make sure it contains what it should (favored c , code and plot).

Submit "julia.pdf" on Canvas.