User:Fanf/maths

From WikiProjectMed
Jump to navigation Jump to search

Incrementally calculating means and standard deviations.

There used to be some equations here that were not completely correct. Please see my corrected working on incremental calculation of weighted mean and variance on my work home page.

Mandelbrot Set

Distance estimation

Boettcher map and Douady-Hubbard potential

First some basic notation to make the formulae less cluttered.

To generate a Julia set, c is a fixed parameter and z varies across the complex plane. For the Mandelbrot set, c varies across the plane and z starts its iteration at 0. In both cases we iterate until z escapes to infinity, in which case it is outside the set, or remains bounded, in which case it is inside. Because we are most interested in the behaviour of z as it is iterated, we usually leave the parameter c implicit.

The simplest Julia set, when , is just the unit circle. In this case we can write down a direct formula for :

There is something called a Böttcher map which transforms the exterior of Julia set into the exterior of other connected Julia sets and back again. It's like a Riemann map, but it operates on the complement of the set.

The definition of the map is as follows. Observe that is the identity function.

Adrien Douady and John Hubbard showed that the Böttcher map is a conformal mapping from the exterior of the Mandelbrot set M to the exterior of the unit disk, and therefore the Mandelbrot set is connected.

The Böttcher map allows us to treat the exterior of the set as an electrostatic field. Imagine an infinitely long crinkly cylinder whose cross-section is the set. If you electrically charge the cylinder it creates a field in the surrounding space. The Böttcher map tells you how the simple circular equipotential curves and radial field lines of the Julia set correspond to those surrounding the Mandelbrot set and the other connected Julia sets.

This is a powerful tool for understanding the Mandelbrot set. The binary decomposition makes a lot of the field structure visible, since the boundaries between the black and white areas are formed from segments of field lines and equipotential curves. If you express the angle of a field line as a binary fraction of a whole turn, you get the sequence of black and white segments that the field line crosses in the binary decomposition. Field lines with rational angles correspond to pinch points on the Mandelbrot set.

For our purposes we are less interested in field lines and more interested in the Douady-Hubbard potential function. We use the Böttcher map to warp the space around the set into its simplest form. This allows us to use the standard formula for the electrostatic potential around an infinite wire, which is the log of the distance from the wire. The base of the logarithm is related to how highly charged the wire is; we can choose it for our convenience.

Since we don't have time to count to infinity, in practice we define a bail-out radius R and stop iterating points that get further than that from the origin. The iteration count n is used for the flat blocky level-set colouring scheme.

The way to get a smooth colouring is to ask what fractional iteration value would make the point land exactly on the bail-out radius.

We can use the potential function to formalize this idea. If R is large, varying it will not make much difference to the potential we calculate for a point. So to derive we assume that we get the same result from the two expressions for the potential in the first line below. (I think this is what causes the small errors and discontinuities discussed by Linas.)

The final term in that equation is a constant, since R is a fixed parameter of our implementation. We might as well throw it away since it does not add any useful information.

And thus we get the equation to use for smoothly colouring of the exterior of the Mandelbrot set.

Iteration Intuition

After writing the above, 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, .)

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

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

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

Recall that

Hence the equations in also apply to ,

When is close to the set, is slightly greater than one (plus crinkles), so is a small positive number, and 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,

Thinking about what happens when we finish iterating,

So lies between two numbers with a difference of one,

When is subtracted from , 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:

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.