fractal 
{
  mapping {
      (4.52444246429543820000,
       2.02777777777777770000,
       4.92641271255661990000,
       2.49790356394129940000) => (320, 240)
   }

















  formula 
  {
    $const2PI = 6.28318;
    $constPI  = 3.14159;

    c     = current;

    c = c - sin(cos(c-sin(c)));

    LSum  = current;
    LSum1 = [1, 0];
    $maxit = 20;

    $LVal_x = 0;
    $LVal_y = 0;

    K     = [0.133, 0];  // Constant
    P     = K;           // Population

    temp = 0;
    
    //while ($count < $maxit && sum_of_squares(LSum1 - LSum) > 1e-24)
    while ($count < $maxit && abs(real(LSum)) > 1e-24)
    {        
      LSum1 = LSum;
      temp = [fmod($count, 4), 0];

      if (real(temp) == 0)
      {
        K = [(real(c)),0];
      }       

      if (real(temp) == 1)
      {
        K = [(real(c)),0];
      }       

      if (real(temp) == 2)
      {
        K = imag(c);
      }     

      if (real(temp) == 3)
      {
        K = imag(c);
      }       

      //P = K*P-K*P*P;
      //LSum = LSum * (K-2*K*P);  // the derivative

      P = K*P-K*P*P-K*P*P*P;
      LSum = LSum * (K-2*K*P-3*K*P*P);  // the derivative

      if ($count > 0)
      {
        if (abs($LVal_x) < 10.1)
        {
          $LVal_x = $LVal_x + log(abs(real(LSum)));
        }

        if (abs($LVal_y) < 10.1)
        {
          $LVal_y = $LVal_y + log(abs(imag(LSum)));
        }
      }
    }
    
    $xtot = log(abs($LVal_x/$count+1));
    $ytot = log(abs($LVal_y/$count+1));

    // "Start" Color variables should be in range from 0 to 255
    $red_Start = 220;
    $grn_Start = 220;
    $blu_Start = 220;

    // "Step" Color variables should be in range from 0 to about 2
    $red_Step = 1.0;
    $grn_Step = 1.0;
    $blu_Step = 1.0;

    // Sine function Coloring algorithm starts here
    $r = sqrt($xtot);
    $g = sqrt($ytot);
    $b = ($r+$g)*0.5;
    $b = sqrt($g*$g+$r*$r)*0.707;  // make it a bit of gray scale

    $t1 =  cos($const2PI*$r);
    $t2 =  cos($const2PI*$g);
    $t3 =  cos($const2PI*$b);

    $t1 = $t1*127+127;
    $t2 = $t2*127+127;
    $t3 = $t3*127+127;

    $t1 = $t1*$red_Step+$red_Start;
    $t2 = $t2*$grn_Step+$grn_Start;
    $t3 = $t3*$blu_Step+$blu_Start;

    $t1 = $t1/360;
    $t2 = $t2/360;
    $t3 = $t3/360;

    $r =  -sin($constPI*$t1);
    $g =  -sin($constPI*$t2);
    $b =  -sin($constPI*$t3);

    $red = ($r*128) + 127;
    $grn = ($g*128) + 127;
    $blu = ($b*128) + 127;

    //  the new coloring function

    if ($xtot == 0 && $ytot == 0)
    {
      set_color ( 000, 000, 000 );
    }
    else
    {
      set_color ( $red, $grn, $blu );
    }


  }
}





















