/****************************************************************************
 * This formula file or any formula file derived from it cannot be used for
 * commercial purposes or to create hard copy output without the explicit
 * consent of the original author.
 ****************************************************************************/

fractal {

   // Establish the mapping between complex coordinates
   // and display coordinates

   mapping {
      (0.31533115746653378000,
       3.24187647481276380000,
       0.44919805118017075000,
       3.37821380937724540000) => (943,960)
   }






   formula {
     
      z = current;
      zold = [0, 0];

      $xmax = 0;
      $xmin = 0;
      $xtot = 0;
      $ymax = 0;
      $ymin = 0;
      $ytot = 0;
      $omax = 0;
      $omin = 0;
      $otot = 0;
     
      $stop = 0;
      $tolerance = 1e-5;

      while($stop == 0 && $count < 10)
      {
         if(abs(real(z) - real(zold)) <= $tolerance &&
            abs(imag(z) - imag(zold)) <= $tolerance)
         {
            $stop = 1;
         }
         else
         {
            f_z  = log(sin(z));
            fp_z = -cos(z) / tan(z);

            zold = z;
            z    = z - fp_z / f_z;

            $o = old_deg(conj(zold));
            $x = real(z);
            $y = imag(z);

            $xtot = $xtot + $x;
            $ytot = $ytot + $y;
            $otot = $otot + $o;

            $xmax = max($xmax, $x);
            $xmin = min($xmin, $x);

            $ymax = max($ymax, $y);
            $ymin = min($ymin, $y);

            $omax = max($omax, $o);
            $omin = min($omin, $o);
         }
      }

      $red   = 0;
      $green = 0;
      $blue  = 0;

      if($count > 0)
      {
      
         $red   = (($xtot / $count) - $xmin) / ($xmax - $xmin) * 255;
         $green = (($otot / $count) - $omin) / ($omax - $omin) * 255;
         $blue  = (($ytot / $count) - $ymin) / ($ymax - $ymin) * 255;
      }

      if(fmod($count, 2) == 0) { set_color($red, $green, $blue); }
      else                     { set_color($blue, $green, $red); }
   }
}



























