# Fractals/Iterations in the complex plane/stripeAC
## introduction

"Average colorings are a family of coloring functions that use the decimal part of the smooth iteration count to interpolate between average sums."
Here stripes are lines perpendicular to the iteration bands ( level sets of escape time). These " radial strands ... follows the external rays which are of great importance in the theoretical study of M and in holomorphic dynamics." (A Cheritat)
" is basically a cheap way to calculate an angle. TIA is averaging the angle over all iterations to get a smooth result. So there is some initialization and some calculations per iteration to do the sum. It has to store the sum at the previous iteration before adding the next one so you can interpolate between them to get a continuous function between iteration bands (in the same way that continuous potential is usually interpolated). This interpolation is done after the iterations bail out." (xenodreambuie - author of Jux)
" ... it probably shows curves close to external rays, but nevertheless you do not have an explicit relation between the number returned by SAC and the true external argument." Wolf Jung

## name

* SAM = Stripe Average Method
* SAC = Stripe Average Coloring
* radial strands

## history

A new coloring called the Stripe Average was introduced by Jussi Härkönen in 2007. It is based on the behavior of the Triangle Inequality Average coloring.

## examples
### Images

fractalforums stripe-average-mandelbrot-2 by Zephitmaal
* Mandelbrot set in gray, image and source code ( processing and c)
* Mandelbrot set zoom ( wake 1/3 ) with c source code
* Basilica Julia set
* disconnected Julia set : Imploded cauliflower

### video

* youtube: Mandelbrot Coloring Algorithms by sfract

## algorithm

For every point c of rectangle from parameter plane do:
* Calculate the orbit of the point z0. The result is series of complex numbers {z0,z1,z2,...}
* Apply function t to this series to get a new series of real numbers: { t0=t(z0), t1=t(z1), t2=t(z2), ...}.
* Take the average A ( = arithmetic mean) of this series of real numbers
* map real number A to a color ( coloring function)

### orbit

Truncated orbit:
${\mathcal {O}}_{n}(z)=\{z,z_{1},z_{2},\ldots z_{n}\}$
Skipped orbit is a subset of truncated orbit:
* skip a first k+1 of items from the sequence
* do not use some first k+1 items to compute average
${\mathcal {O}}_{n,k}(z)=\{z_{n-k},z_{n-k+1},\ldots z_{n}\}$

### addend function

The addend function t
* maps complex number $z$ to real number $t_{n}$
* is continuous on the elements of elements in skipped orbit
    $t_{n}=t(z_{n})={\frac {sin(s*arg(z_{n}))}{2}}+{\frac {1}{2}}$
    $t\ \colon \mathbb {C} \to \mathbb {R}$
where :
* s is a stripe density

### average
#### full

Average of full truncated orbit:
* compute average from all points of the truncated orbit
    $A_{n}=A({\mathcal {O}}_{n})={\frac {1}{n}}\sum _{i=0}^{n}t_{i}={\frac {t_{0}+t_{1}+\cdots +t_{n}}{n}}$
If one compute average of all points ( from i=1 to i=n) then:
* stripes will be visible ( good)
* level sets of escape time will be also visible (bad, discontinuity )
The solution is :
* the interpolation
* skipped truncated orbit

#### skipped

Average of skipped orbit:
* skip first (k+1) items from computing average
    $A_{n,k}={\frac {1}{n-k}}\sum _{i=n-k}^{n}t_{i}={\frac {t_{n-k}+t_{n-k+1}+\cdots +t_{n}}{n-k}}$
note that:
$k<n$
$n-k=k+1$
It removes some discontinuities but not level sets of escape time

#### interpolated

Level sets of escape time are still visible ( discontinuity). One can remove them using interpolation.
interpolation:
* between 2 values
* using:
** linear function = linear interpolation
** splines = spline interpolation
** polynomial
steps:
* Construct a smooth iteration count u = real number ( see equation 3.11 from page 21 in J Harkonen thesis)
* take it's fractional part d
$u_{n}=u(z_{n})=n+1+{\frac {1}{ln(2)}}ln{\frac {ln(ER)}{ln(abs(z_{n}))}}$
    $d_{n}=\operatorname {frac} (u_{n})\ =\ u_{n}-\lfloor u_{n}\rfloor \ for\ u_{n}\geq 0$
Decimal (frational) part d is:
* zero at boundary of previous level set $B_{n-1}$
* converges to 1 in the neighborhood of next level set boundary $B_{n}$
"Thus it can be used as the interpolation coefficient."

##### linear

To compute linear average $A^{l}$ interpolate between two values:
* one obtained from the "full" series ( truncated and skipped) = Avg = $A_{n}$
* one obtained from the average of all t elements except the last one = prevAvg = $A_{n-1}$
see equation 4.2 from page 28 in J Harkonen thesis
or in GLSL code by Syntopia:
Here is important fragment of GLSL code by Syntopia:

##### spline

Compute spline average $A^{s}$ using Catmull-Rom splines:
Polynomials $H_{i}(d)$:
${\begin{array}{lcl}H_{0}={\tfrac {1}{2}}(-d^{2}+d^{3})\\H_{1}={\tfrac {1}{2}}(d+4d^{2}-3d^{3})\\H_{2}={\tfrac {1}{2}}(2-5d^{2}+3d^{3})\\H_{3}={\tfrac {1}{2}}(-d+2d^{2}-d^{3})\end{array}}$
then
$A^{s}=H_{0}A_{n}+H_{1}A_{n-1}+H_{2}A_{n-2}+H_{3}A_{n-3}$
see equation 4.3 from page 28 in J Harkonen thesis

## Code

* java script by 2013 Douglas Haber
* dailyfractalart explorer and description of js code
* M set by Jeremy Ashkenas

### C

* M_LN2 is defined in math.h

### Ultra Fractal

Ultra Fractal
* uf
* jh.ucl

### Processing
## Programs

* fractview - blog - -branching-and-expsmooth, code
* fractalmaker
* deep-fractal by munrocket in java script

# References

* ↑ Jussi Harkonen : On Fractal Coloring Techniques
* ↑ A Cheritat wiki : Mandelbrot_set - Radial_strands
* ↑ fractalforums : triangle-inequality-average-coloring
* ↑ fractalforum : master's-thesis-on-fractal-coloring-techniques
* ↑ fractalforums : stripe-average-coloring
* ↑ wikipedia : Interpolation
* ↑ wijkipedia : Fractional part
* ↑ stackoverflow question: how-to-use-m-ln2-from-math-h ?
* ↑ M_LN2