Julia Sets
Published
- 3 min read
Julia sets are a type of fractal that are closely related to the Mandelbrot set . Both sets are generated using complex numbers and iterating over a mathematical function.
The Mandelbrot set is defined as the set of complex numbers c for which the function , with z starting at 0, does not diverge when iterated. In other words, if the absolute value of f(z) remains less than or equal to 2 for all iterations, then c is considered to be a member of the Mandelbrot set.
Julia sets, on the other hand, are defined for a fixed value of c, and the set of all complex numbers z for which the iteration of remains bounded. Julia sets are an example of a chaotic system, where a slight change to inputs of the system lead to huge difference in the output.
To generate a Julia set, you can create a grid of complex numbers and then iterate the function for each point in the grid. The points that remain bounded after a certain number of iterations are considered to be part of the Julia set. The number of iterations required for a point to be considered part of the set can be represented as a color on a 2-D plot. Points that are not part of the set are typically colored black.
Julia sets come in an infinite variety of shapes, depending on the value of c used in the function. One of the interesting properties of Julia set is that, the boundary of the Mandelbrot set is the set of all Julia sets.
In practice, Julia sets are generated using computer programs and can be rendered in a variety of styles to create beautiful and intricate images. These images can be used to study the properties of the set and to explore the complex nature of the mathematical function used to generate them.
Overall Julia Sets are fascinating mathematical objects that demonstrate the complexity and beauty that can arise from simple mathematical equations.
The following code plots the sets defined by AKA Normal Julia Sets. Select one of the predefined starting points from the drop down then click start/stop animation. This code is also available on GitHub
See the Pen Untitled by sherif-gamal (@sgamal) on CodePen.
The code is essentially the same, however, we define a fixed point c:
let c = {a: -0.4, b: 0.6};
which can be changed using the drop down menu. This value c is used in the following function to determine the values z for which the function diverges:
function belongsToJulia(z, r) {
let i
for (i = 0; i < maxIter; i++) {
const nextA = z.a * z.a - z.b * z.b + c.a;
const nextB = 2 * z.a * z.b + c.b;
z.a = nextA;
z.b = nextB;
const ab = Math.sqrt(z.a * z.a + z.b * z.b);
if (ab > 2) return i - Math.log2(Math.log2(ab));
}
return i;
}
If you click the animate button a new value of will be generated every 500ms and the new julia set will be plotted.