Skip to content

Julia Set and Mandelbrot Set

Julia Set

Julia Set formula

Z_{n+1} = {Z_{n}}^2 + C

Julia Set formula explanation

Both Z and C are complex numbers.

How is Z_1 chosen? For each pixel on the canvas, we convert its coordinate to the appropriate range and use it as Z_1.

How is C chosen? It's really arbitrary, but some selections of C give particularly exquisite results.

After acquiring Z_1 and C, we iteratively calculate Z_{n} with a preset maximum iteration count. When or before the max iteration count is reached, Z either diverges or converges. Divergence or convergence is determined by whether the magnitude of Z goes beyond a predefined radius R. R is chosen with the following criteria:

R^2 - R >= \vert C \vert

To paint an image with this info, use this rule: if a point converges, paint it black; if a point diverges, paint it with some other color, tinted according to how fast it diverges.

Due to the limits of CPU performance and real-time requirements, the iteration count of this Julia Set implementation is very limited. As a result, some points that should diverge given a high enough iteration count are not diverging here. This causes some fine details to be missing; for example, the "Leaves" preset doesn't show the leaves pattern.

Mandelbrot Set

The Mandelbrot set is only slightly different from the Julia set. It uses a different criterion for choosing Z_1 and C. Instead of using a point's coordinate as Z_1 and an arbitrary C, the Mandelbrot set uses the point's coordinate as C and always uses Z_1 = 0 + 0 * \vec{i}.

That means we can actually reuse most of the code!

References