make circle(t) [2*cos(t), 2*sin(t)];
make id(t)  [t,t];
make variable cx;
make variable cy;
make fn(x,y) [x^2 - y^2 +cx, 2*x*y+cy];
make round(x) .0001* truncate(.5+x*10000);

program iterate (vector #2 first) (expression reps)
 {select "Complex Plane";
   let cx  first(1);
   let cy  first(2);
   point first;
    do 
     d = 0
     n = 0
     x = 0
     y = 0
    until  or(d>4,n>reps)
    returning n
    { let np be fn(x,y) ;
      let x be np(1); 
      let y be np(2);
      let d be x^2+y^2;
      let n be n+1;
      move [x, y];
    } 
 }

program iterpoint (vector #2 first) (expression reps)
 {select "Complex Plane";
   let cx be first(1);
   let cy be first(2);
   point first;
    do 
     d = 0
     n = 0
     x = 0
     y = 0
    until  or(d>4,n>reps)
     returning n
   {  let np be fn(x,y) ;
      let x be np(1); 
      let y be np(2);
      let d be x^2+y^2;
      let n be n+1;
      pendown;     
      point [x, y];
      penup; 
     } 
      
 }



program iterleg (expression cval) 
  {readfloat;
   select "Time Series";
   'precision 14;'
   penup;
   move [0,1];
   pendown; 
     do 
       i = 2
       until  i == 21
       returning cval
     { 
       let xn(i) be xn(i-1)^2+cval;
       entry i 2 xn(i);
       move [xn(i),i];
       let i be i+1;
      }
   updatetable 2;
   readlong;
}

 
 
 
 
