.@ Tony Finch – blog


After writing my previous entry, I noticed that the final equation is in fact just the negated log of the Douady-Hubbard potential (assuming n is practically infinite). (In the following I will use the binary logarithm throughout, lg x = log2 x.)

- lg 𝜙c(z) - lg lg rn lg 2n = lg 2n - lg lg rn = n - lg lg rn

I didn’t really understand this so I sought a more intuitive explanation.

Observe that when z is large, fc(z) is very close to f0(z). So in the following we can treat the crinkly component c as insignificant.

zn = fcn (z) z 2n lg lg zn lg lg z 2n = lg 2n lg z = lg 2n + lg lg z = n + lg lg z

So the double log gives us a sort of measure of distance in terms of the number of iterations needed to get from z to zn.

n = log2 2n = log2 logz z 2n = lg lg z 2n lg z = lg lg z 2n - lg lg z lg lg zn - lg lg z

Recall that

z = r e iθ zp = rp e piθ

Hence the equations in z also apply to r = |z|,

- lg lg z n - lg lg zn - lg lg r n - lg lg rn

When z is close to the set, r is slightly greater than one (plus crinkles), so lg r is a small positive number, and lg lg r is a large negative number. Hence the negation to turn it into the equivalent of an iteration count.

The equation above also relates back to the definition of the electrostatic potential and our simplifying approximation, that is,

𝜙c(z) lg r

Thinking about what happens when we finish iterating,

r n > R > r n-1 r n r n-1 2 R2 > rn > R

So lg lg rn lies between two numbers with a difference of one,

lg lg R2 = 1 + lg lg R

When lg lg rn is subtracted from n, it contributes a fractional part and a fixed offset determined by the bail-out radius.

Finally, on a practical note I find that a better function for colouring pixels is to take the log again:

m = lg ( n - lg lg rn )

The extra log gives the value a more uniform gradient so it cycles through the colours evenly, and it gets much closer to the set before it flies off to infinity so less of the picture suffers from aliasing. Even better, it retains these properties as you zoom in.