MACHINE Mandelbrot
DEFINITIONS
  "LibraryReals.def";

   mbr(a,b,c,d) == csqr_plus_c(
                   csqr_plus_c(
                   csqr_plus_c(
                   csqr_plus_c(
                   csqr_plus_c(a,b,c,d),c,d),c,d),c,d),c,d);

      ANIMATION_IMG0 == "images/vvsm_empty_box.gif";
      ANIMATION_IMG1 == "images/vvsm_gray_box.gif";
      ANIMATION_FUNCTION == {r,c,i| 
            r:-50..50 & c:-50..50 & 
            i = IF cabs(mbr(0.0,0.0,real(r)/scale,
                                    (real(c)-xoff)/scale))<2.0 THEN 0 ELSE 1 END } ;
CONSTANTS mxi
ABSTRACT_CONSTANTS csqr, csqr_plus_c, cabs
PROPERTIES mxi = 10 &
  csqr = %(a,b).(a:REAL & b:REAL | (a**2 - b**2, 2.0*a*b)) &
  csqr_plus_c = %(a,b,c,d).(a:REAL & b:REAL & c:REAL & d:REAL | (a**2 - b**2 + c, 2.0*a*b + d)) &
  cabs = %(a,b).(a:REAL & b:REAL | RSQRT(a**2 + b**2))
VARIABLES
  scale, xoff
INVARIANT scale:REAL & xoff :REAL
INITIALISATION scale:=30.0 || xoff:=0.0
OPERATIONS
  DoubleScale = BEGIN scale := scale * 2.0 END;
  xOffset = BEGIN xoff := xoff + 0.2 END
END

