Fractal Dimension: Tutorial
By: Stephen C. Ferguson
Based on an algorithm by Professor Holger Jaenisch
Last modified: 10-01-98, 9:14 PM

When Mandelbrot introduced the concept of "fractal" in 1977, he also introduced the term fractal dimension, a concept of dimension he based on a definition given by Hausdorff in 1919.

The algorithm in this tutorial is used to obtain an approximation of the fractal dimension.

Kerry Mitchell, has posted some comments about the algorithm to the FractInt newsletter and has converted it to use with FractInt.

The following are images that were created by approximating the fractal dimension of both the X and the Y coordinates at each point during the iteration. Fractal Dimension (FD) should represent a measurement of a degree of chaotic turbulence. A straight line should have a FD of 0, and a total random line should have the highest FD. The algorithm has a resulting FD that ranges from a value of 0 to a value that approaches 2.

 


Click image for a larger view.
This histogram shows that by using the algorithm, a fractal dimension of between 1.2 and 1.45 was obtained for the Mandelbrot formula z=z^2+c.






This is from a formula based on the Newton method of convergence.

 
This is another Newton method, but the FD is scaled to magnify the detail.




As a formula is iterated, the values of x and y in the complex plane are saved into temporary arrays called v->pXTemp[n], and v->pYTemp[n]. Initially these arrays are dimensioned to the size of the maximum iterations.

The function used to obtain each X and Y data point at iteration step is as follows:

// Note: v->xtot and v->ytot are the X and Y data points

void accumulate(CDATA *v)
{
  v->pXTemp[v->iteration] = v->xtot;
  v->pYTemp[v->iteration] = v->ytot;
}


After the iteration has completed, or bailed out, the following parameters are obtained:

Parameter Description

Parameter Name

Maximum Iterations

maxit

Average X

v->x_mean

Average Y

v->y_mean

X range minimum

v->rmin

X range maximum

v->rmax

Y range minimum

v->imin

Y range maximum

v->imax

X standard deviation

v->x_std

Y standard deviation

v->y_std

Result: X Fractal Dimension

dFDx

Result: Y Fractal Dimension

dFDy


Formula analysis:

v->x_mean = sum_of_the_X_values_ / maximum_iterations

v->y_mean = sum_of_the_Y_values_ / maximum_iterations

v->x_std = square_root_of_((sum_of_(v->pXTemp[n] - v->x_mean))^2)

v->y_std = square_root_of_((sum_of_(v->pYTemp[n] - v->y_mean))^2)

denominator = log( maxit )

Calculate fractal dimension of X

Numerator = -log(fabs( v->rmax-v->rmin) / ( v->x_std*maxit ));

dFDx = 2.0 - 1/(0.5 + (numerator / denominator));

Calculate fractal dimension of Y

Numerator = -log(fabs( v->imax-v->imin) / ( v->y_std*maxit ));

dFDy = 2.0 - 1/(0.5 + (numerator / denominator));


/////////////////////////////////


#define zerotol 1e-20
#define dMAX 1e20

void post_fractal_dimension(CDATA *v)
{
  maxit = (double) v->iteration-1;
  if (maxit < 1)
  {
    dFDx = 0;
    dFDy = 0;
    return;
  }

  // Initialize the mean with zero


  v->x_mean = 0;
  v->y_mean = 0;


  // Initialize the range with the first value
  v->rmin = v->pXTemp[0]; // x range min
  v->rmax = v->pXTemp[0]; // x range max
  v->imin = v->pYTemp[0]; // y range min
  v->imax = v->pYTemp[0]; // y range max
  for (i2 = 0 ; i2<maxit ; i2++)
  {
    // Get sum x and y
    v->x_mean += v->pXTemp[i2];
    v->y_mean += v->pYTemp[i2];

    // Get min x
    if (v->pXTemp[i2] < v->rmin)
    v->rmin = v->pXTemp[i2];

    // Get max x
    if (v->pXTemp[i2] > v->rmax)
    v->rmax = v->pXTemp[i2];


    // Get min y
    if (v->pYTemp[i2] < v->imin)
    v->imin = v->pYTemp[i2];

    // Get max y
    if (v->pYTemp[i2] > v->imax)
    v->imax = v->pYTemp[i2];
  }


  v->x_mean /= maxit;
  v->y_mean /= maxit;


  v->x_std = 0;
  v->y_std = 0;

  for (i2 = 0 ; i2<maxit ; i2++)
  {
    xtmp = v->pXTemp[i2] - v->x_mean;
    ytmp = v->pYTemp[i2] - v->y_mean;
    v->x_std += xtmp*xtmp;
    v->y_std += ytmp*ytmp;
  }


  if (fabs(v->rmax - v->rmin) < zerotol)
  {
    v->rmax = zerotol;
    v->rmin = 0;
  }


  if (fabs(v->imax - v->imin) < zerotol)
  {
    v->imax = zerotol;
    v->imin = 0;
  }

  if (fabs(v->rmax - v->rmin) > dMAX)
  {
    v->rmax = dMAX;
    v->rmin = 0;
  }

  if (fabs(v->imax - v->imin) > dMAX)
  {
    v->imax = dMAX;
    v->imin = 0;
  }


  if (fabs(v->x_std) < zerotol)
  v->x_std = zerotol;


  if (fabs(v->y_std) < zerotol)
  v->y_std = zerotol;

  if (fabs(v->x_std) > dMAX)
  v->x_std = dMAX;

  if (fabs(v->y_std) > dMAX)
  v->y_std = dMAX;

  v->x_std = sqrt(v->x_std);
  v->y_std = sqrt(v->y_std);

  denominator = log( maxit ) + zerotol;

  // Real
  numerator = fabs( v->rmax-v->rmin) / ( v->x_std*maxit );
  if (numerator == 1)
  numerator = 1 + zerotol;
  dFDx = -log( numerator )/denominator;
  dFDx += 0.5;
  dFDx = 1/(dFDx + zerotol);
  dFDx = (2.0 - dFDx);


  // Imaginary
  numerator = fabs( v->imax - v->imin ) / ( v->y_std * maxit ) ;

  if (numerator == 1)
  numerator = 1 + zerotol;
  dFDy = -log(numerator)/denominator;
  dFDy += 0.5;
  dFDy = 1/(dFDy + zerotol);
  dFDy = (2.0 - dFDy);

  v->xtot = dFDx;
  v->ytot = dFDy;
}

 

 

This page was created on 9/26/98

back to Iterations et Flarium24