steventhornton / IteratedExponential

Matlab code for producing a fractal of the cycle lengths of the iterated exponential

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Iterated Exponential Fractal

The iteration where can either diverge or converge to a cycle. This repository provides Matlab code for plotting these cycle lengths in the complex plane. Different colors are used to represent the different cycle lengths. Black typically indicates the divergence, overflow or underflow in the iteration.

This project originally aimed at reproducing the fractal that appears on a poster about the Lambert W function. This poster is available at orcca.on.ca/LambertW/pic/bg/LambertW.jpg and more information about the Lambert W function can be found on Wikipedia or in the Corless, Gonnet, Hare, Jeffrey and Knuth paper from 1993.

Matlab Requirements

  • The Parallel Computing Toolbox must be installed. If you do not have the parallel computing toolbox install you may modify the code slightly by changing any parfor loops to for loops.
  • All contents (files and subfolders) of the src directory must be in your Matlab working directory.

Using the Matlab code

The main function used for producing images is the iteratedExponential function. It is called as

iteratedExponential(workingDir, options);

The workingDir is the location where images will be saved.

When the function is called, it will create the working directory if it does not already exist. A README.txt file will be written containing information about the image produced. The images are named as Image-k.png where k is a positive integer to ensure images are never overwritten.

A matrix of rgb colors can be provided to use as the colormap (see the cmap option). When this option is used, a point in the complex plane with cycle length L will use the L mod m color from the colormap.

Options

Option Name Default Details
margin [-1-1i, 1+1i] Must be a struct with keys:
  • bottom
  • top
  • left
  • right
that indicating the margins for the image.
height 1000 (pixels) The height (in pixels) of the grid to be used. The width is determined from the margin such that each grid point is square.
nPre 500 Number of iterations to run before starting to search for cycles, a larger number will make finding the cycle lengths easier and lead to less false cycles being found.
maxLength 500 The maximum cycle length to search for.
tol 1e-4 Tolerance to use when searching for cycles.
cmap A 5-color colormap that looks nice. A m x 3 vector of values in [0,1] that specify the colors to be used for the image. Each row is an rgb triple.
backgroundColor [0, 0, 0] (black) Set this to a vector with 3 values representing the rgb values (between 0 and 1) to use for the background color. The background is regions where the iteration either diverged, overflowed or underflowed.

Example

workingDir = '~/CoolFractal/';

margin = struct('bottom', -2, ...
                'top',     2, ...
                'left',   -3, ...
                'right',   1);

options = struct('margin', margin, ...
                 'height', 800, ...
                 'nPre',   2000);

iteratedExponential(workingDir, options);

Output image:

Iterated Exponential Fractal.

About

Matlab code for producing a fractal of the cycle lengths of the iterated exponential

License:GNU General Public License v3.0


Languages

Language:MATLAB 100.0%