fractal 
{
  mapping {
      (2.99324170484520290000,
       3.52954814189189260000,
       3.48143828960155410000,
       3.92794763513513570000) => (320, 240)
   }





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

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

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

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

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

      if (real(temp) == 1)
      {
        K = real(c);
      }       

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

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

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

      //if ($count > 0)
      //{
        //if (abs($LVal) < 0.1)
        //{
          $LVal = $LVal + 1/(1+abs(real(LSum)));
        //}
      //}
    }
    
    $xtot = sqrt(abs($LVal));
    $ytot = $xtot;


    // "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+2*$ytot);
    $g = sqrt($ytot+2*$xtot);
    $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 );
    }


  }
}









