About Chaos Game & IFS Fractals
The Chaos Game is a beautifully simple algorithm for generating self-similar fractals: start at a random point, repeatedly jump a fixed fraction of the distance towards a randomly chosen vertex or transformation, and plot every intermediate point. Despite its randomness, the algorithm converges to a deterministic attractor — an iterated function system (IFS) fractal — because the contractive affine transformations compress phase space faster than the random jumps can explore it. The Sierpinski triangle emerges from just three vertices with a jump ratio of 1/2, while the Barnsley fern uses four affine transformations that mimic the self-similar branching of a real fern frond.
This simulation lets you choose from several classic IFS attractors — Sierpinski triangle, Barnsley fern, dragon curve, and others — adjust the probability weights for each transformation, and watch millions of points gradually reveal the fractal structure. You can also define custom affine transformations to build your own attractor.
Frequently Asked Questions
What is an iterated function system (IFS)?
An IFS is a finite set of contractive affine mappings {f₁, f₂, ..., fₙ} each of the form f(x) = Ax + b, where A is a 2×2 matrix and b is a translation vector. By Banach's contraction theorem, the IFS has a unique attractor — a compact set A such that A = ∪fᵢ(A). Repeated random application of the maps converges to this attractor regardless of the starting point, which is why the Chaos Game always produces the same fractal.
Why does the Sierpinski triangle appear from the Chaos Game?
The three transformations of the Sierpinski IFS each scale the plane by 1/2 towards one of the three vertices. The attractor of these three contractions is exactly the Sierpinski triangle — a fractal with Hausdorff dimension log(3)/log(2) ≈ 1.585. The Chaos Game reaches this attractor because after enough iterations, the starting point becomes irrelevant and all visited points lie on the attractor.
What are affine transformations?
An affine transformation maps a point (x, y) to (ax + by + e, cx + dy + f), combining linear operations (scaling, rotation, shear) with translation. Each IFS transformation has six free parameters. In the Barnsley fern, one transformation (applied 85% of the time) represents the main stem elongation, while three others handle the left leaflet, right leaflet, and stem base — together producing a remarkably realistic fern shape.
What is the Hausdorff dimension of a fractal?
The Hausdorff dimension generalises the notion of dimension to non-integer values. For self-similar fractals, it equals log(N)/log(1/r) where N is the number of self-similar pieces and r is the scaling ratio. The Sierpinski triangle (N=3, r=1/2) has Hausdorff dimension ≈1.585; the Cantor set (N=2, r=1/3) has dimension ≈0.631; the Koch curve (N=4, r=1/3) has dimension ≈1.261. Fractals with dimension between 1 and 2 can be thought of as "more than a line but less than a plane."
What is the connection between IFS fractals and data compression?
Fractal image compression (developed by Michael Barnsley and Alan Sloan in the 1990s) stores images as IFS parameters rather than pixel data. Since an IFS can describe detailed self-similar structures with very few numbers, compression ratios of 10:1 to 50:1 were achievable. However, the encoding step (finding the right IFS for an arbitrary image) is computationally expensive, and JPEG/WebP compression generally outperforms fractal methods in practice.
Can the Chaos Game generate 3D fractals?
Yes — the IFS framework extends naturally to any number of dimensions. 3D versions include the Menger sponge (27 contractions removing the centre cube, dimension ≈2.727) and the 3D Sierpinski tetrahedron (4 contractions, dimension = log(4)/log(2) = 2). The Chaos Game in 3D works identically: pick a random transformation from the IFS, jump a fraction towards the result, and plot the point.
What is the dragon curve?
The dragon curve is an IFS fractal generated by repeatedly folding a strip of paper in half in the same direction and unfolding it at 90°. Its IFS consists of two transformations that each rotate by 45° and scale by 1/√2. The dragon curve has Hausdorff dimension 2 — it fills a bounded region of the plane — yet its boundary has dimension log(4)/log(1+√2) ≈ 1.524.
Why are fractals found in nature?
Natural fractal-like structures arise from growth processes with self-similar rules: a fern frond grows sub-fronds that grow sub-sub-fronds by the same hormonal signalling mechanism; a tree branches by the same rule at each scale; a coastline is eroded at every length scale by the same physical processes. The IFS formalises these recursive rules mathematically. However, natural fractals are only self-similar over a limited range of scales (typically 2–4 orders of magnitude), unlike mathematical fractals which are self-similar at all scales.
What are the probability weights in the Chaos Game?
Each IFS transformation fᵢ is assigned a probability pᵢ with Σpᵢ = 1. Choosing unequal probabilities determines which parts of the attractor are densely visited. For the Barnsley fern, the stem transformation uses p = 0.85 and the base uses p = 0.01, which matches the relative "area" each transformation contributes to the attractor. Changing probabilities does not change the attractor shape, only the density of points on each part.
What is the difference between a fractal and a self-similar shape?
All fractals are self-similar in some sense, but not all self-similar shapes are fractals. A square can be divided into four smaller squares (self-similar with ratio 1/2), but its dimension is exactly 2 — the same as expected for a 2D shape. A fractal has a non-integer Hausdorff dimension that differs from its topological dimension. The Sierpinski triangle is topologically 1-dimensional (it has no interior), yet its Hausdorff dimension is ≈1.585.