# Smooth iteration count for the Mandelbrot set

The exterior of the Mandelbrot set is usually colored by using the number of iterations. As the number of iterations is a discrete quantity, this leads to the occurrence of banding in the coloring. In this article, I will derive a formula for a fractional iteration count. This is by no means novel; plenty of derivations can be found on the internet. However, I found most derivations to be fairly hard to follow, and hope that my explanation may be helpful to at least some people.

## Mandelbrot formula

To check if a point is in the Mandelbrot set, we iterate $z_{k+1}=z_{k}+c$

If $lim_{k→∞}∣z_{k}∣=∞$, the set is outside the Mandelbrot set, otherwise, it is in the Mandelbrot set. In practice, we just iterate a fixed number of times, and check that $∣z_{k}∣$ stays within an *escape radius* $R$. It can be shown that when $∣z_{k}∣>2$ for some $k$, then $lim_{k→∞}∣z_{k}∣=∞$. So, in a sense, $R=2$ is big enough. However, when we color the fractal based on the number of iterations, the escape radius matters, so in this article I'll use a general escape radius $R$.

I will use the following conventions: the magnitude of the iterand $z_{k}$ is denoted by $r_{k}=∣z_{k}∣$. The first $n$ such that $r_{n}>R$ for a given $z_{0}$ is called the *iteration count* for the point $z_{0}$.

While the iterands $z_{0},z_{1},...$ (and thus, their magnitudes) depend on the starting point in a continuous way, the iteration count ‘jumps’ to discrete values. Suppose that $epsilon>0$ is a very small number. A starting point for which $r_{n}=R+ϵ$ will have an iteration count of $n$, while a starting point with $r_{n}=R−ϵ$ will have iteration count $n+1$. If we would have some kind of measurement for the amount by which the iterand has escaped the escape radius $R$, we could use this to assign a fractional part of the iteration count. That is, the iterand with $r_{n}=R+ϵ$ would have an iteration count slightly lower than $n$, while the iterand with $r_{n}=R−ϵ$ would have an iteration count slightly higher than $n$.

Ideally, we would like to have a smooth function $f:R→R$ such that $f(k)=∣z_{k}∣$ for $k∈N$, and find the smallest $x_{R}>0$ such that $f(x_{R})=R$. Instead of trying to find such a function, we will try to approximate it locally.

Suppose that $x_{R}$ is the smallest number such that $f(x_{R})=R$. We then have $z_{n+1}=z_{n}+c$. Assuming that $c$ is small with respect to $R$, we get $f(x_{R}+1)≈R_{2}$

Likewise, we find $f(x_{R}+2)=R_{4},f(x_{R}+3)=R_{8}$, or, more generally, $f(n+ϵ)=R_{2_{ϵ}}$. Note that this is a perfectly fine approximation even when $epsilon$ is real. So now we can try to solve $f(x_{R}+ϵ)=R_{2_{ϵ}}=r_{n}$

for $ϵ$. In doing so, we find $ϵ=g_{2}(g_{R}(r_{n}))$. Since $f(n)=r_{n}$, we have $n=x_{R}+ϵ$, so for the fractional iteration count $x_{R}$ we find $x_{R}=n−g_{2}(g_{R}(r_{n}))$

where $R$ is the escape radius, $r_{n}=∣z_{n}∣$, and $n$ is the classical iteration count (i.e. the smallest $n$ such that $∣z_{n}∣>R$).

**Exercise**: a) *Suppose that we instead chose to approximate $f(x)$ at $x=n$ instead of $x=x_{R}$. Show that we would have end up with*:
$x_{R}=n+g_{2}(g_{r_{n}}(R))$

b) *Show that these expressions are the same. Hint: Use $g_{b}(x)=log_{c}(b)log_{c}(x) $ and $g(x1 )=−g(x)$.*

c) *Show that taking if we would take another base instead of $R$ for the inner logarithm, we would still get a smooth coloring, but if we would take another base instead of 2 for the outer logarithm, we would get a non-smooth coloring. Hint: use that $g(xy)=g(x)+g(y)$.*