Platform Numbers
Wave 31 Simulations
Newton's Fractal
Newton's root-finding method applied to zn−1 in the complex plane. Each pixel is coloured by which root it converges to and how fast.
Open →Sand Pile Model
Bak–Tang–Wiesenfeld self-organised criticality. Drop grains until cells topple; avalanches of all sizes appear with no parameter tuning.
Open →Complex Functions
Domain colouring of f(z): hue = arg f(z), brightness = |f(z)|. Visualise poles, zeros, and branch cuts for 12 classic functions.
Open →🌀 Newton's Fractal
The Algorithm
Newton's method finds roots of f(z) = 0 by iterating:
zn+1 = zn − f(zn) / f′(zn)
For the polynomial f(z) = zk−1, the roots are the k-th roots of unity: e2πin/k for n = 0, 1, …, k−1. The fractal arises because the boundaries between basins of attraction — the sets of starting points that converge to each root — are infinitely detailed.
Per-Pixel Rendering
Each of the 600×600 canvas pixels maps to a point z in the complex plane. The inner loop runs Newton steps until either the distance to the nearest root drops below a tolerance ε, or the maximum iteration count is reached. The convergence speed (iteration count when tolerance is met) modulates the brightness, producing the shaded gradient that makes the image three-dimensional in feel.
- Hue — determined by which root was reached (one of k distinct colours from ROOT_HUES).
-
Brightness —
0.15 + 0.6 × (1 − iters/maxIter), so fast convergence is bright. - Non-convergence — points that exhaust iterations are rendered near-black.
Complex Arithmetic
All arithmetic is done in real/imaginary component pairs.
cmul(ar,ai,br,bi) returns
[ar·br−ai·bi, ar·bi+ai·br]. zn is computed by repeated cmul rather than
De Moivre (keeping the code branchless for any integer exponent). The
division f(z)/f′(z) uses cdiv with the standard
conjugate-over-magnitude² formula.
What to Try
- Switch from z³−1 to z⁸−1 — the number of fractal petals grows with the degree.
- Drag the ε slider to near-zero — thin basins appear near triple-point junctions.
- Zoom into a basin boundary — fractal self-similarity is visible at every scale.
- Lower max iterations — you’ll lose detail but the broad coloured regions remain.
⏳ Sand Pile Model
Bak–Tang–Wiesenfeld (1987)
The BTW sand pile is the canonical model of self-organised criticality (SOC). An integer height hi,j is stored at each cell of an N×N grid. Adding a grain to any cell may trigger a cascade of topplings according to the rule:
if h[i,j] ≥ K: h[i,j] −= K; each of 4 neighbours: h += 1
Grains that leave the boundary vanish (open boundary), so the total grain count is conserved on average. The system self-organises to a critical state without any tuning of K, and the distribution of avalanche sizes P(s) follows a power law P(s) ~ s−τ with τ ≈ 1.2.
Implementation
The grid is a flat Int32Array(N×N). The stabilise
loop uses a BFS queue approach: cells that are critical at the start
of a drop are seeded into the queue, then processed one by one. Newly
critical neighbours are appended. Avalanche size is the total number
of topple events. Colours are assigned per integer height (0=black,
1=dark green, 2=yellow-green, 3=amber, ≥K=red-orange) and written
directly to a ImageData buffer.
What to Try
- Run with a centre drop until the pile saturates — concentric rings form, then break into fractal-like patterns.
- Switch to random drop to fill the grid uniformly and watch continuous micro-avalanches.
- Use click mode to manually pour 20 grains anywhere — trigger your own targeted avalanche.
- Watch the log-log histogram below the canvas develop a straight-line slope — the power law in action.
- Change K from 4 to 2 or 8 and observe how the critical threshold alters the saturation pattern.
🎨 Complex Functions
Domain Colouring
Domain colouring is a technique for visualising complex-valued functions f : ℂ → ℂ on a 2D canvas. For every point z = x + iy in the viewing window, we compute f(z) = u + iv and map the result to a colour:
- Hue = (arg f(z) + π)/(2π) × 360°, so the full rainbow cycles once around each zero.
- Brightness = 0.35 + 0.4×((log|f(z)|) mod 1), producing concentric magnitude isocontour rings at |f| = ek.
- Saturation = 85%, kept constant to preserve legibility.
Complex Arithmetic in JS
All arithmetic is done analytically in (real, imag) pairs — no complex number objects are allocated to keep the inner loop fast:
- exp z = ex(cos y + i sin y)
- sin z = sin(x)cosh(y) + i cos(x)sinh(y)
- cos z = cos(x)cosh(y) − i sin(x)sinh(y)
- tan z = sin(z)/cos(z) via component division
- sinh z = sinh(x)cos(y) + i cosh(x)sin(y)
- Möbius = (z−1)/(z+1) — a conformal automorphism of the Riemann sphere
Twelve functions ship in total. Switching function triggers a debounced re-render of all 360 000 pixels; a “Rendering…” overlay is shown during the ~30 ms computation.
What to Try
- z² — two sectors, each colour appears twice; single zero at origin.
- 1/z — identical to z² layout but inverted (a single pole at origin).
- sin z — infinitely many zeros along the real axis, π apart; periodic column structure.
- exp z — no poles or zeros anywhere; brightness increases to the right (Re z grows).
- tan z — poles at z = π/2 + kπ; double-wound color wheel at each.
- Möbius — maps the plane conformally; observe how lines map to circles.
- Enable Re/Im grid to see how f(z) deforms the Cartesian coordinate lines.
- Zoom in on a pole or zero — the winding number of the colour around it equals the order.
Technical Highlights
-
Newton's Fractal —
newtonStep(zr, zi, n)computes zn by repeatedcmul(no trig, no log, integer exponent only); the 600×600 image renders in <100 ms on a modern browser. AscheduleRender()debounce (30 ms) prevents rapid re-renders during drag/scroll. The legend rebuilds automatically when the degree changes. -
Sand Pile — BFS stabilise with a single flat
Uint8Arrayin-queue bitfield avoids re-queuing cells. The avalanche log is aMap<size, count>updated after every drop group, rendered as a log-log line chart on a second canvas below the grid. -
Complex Functions — custom
hslToRgbreplaces CSS calculation in the hot pixel loop (avoids string parsing). Scroll-to-zoom preserves the cursor position in complex-plane coordinates (same technique as Newton's Fractal). Touch pinch-zoom is supported. -
All Wave 31 simulations ship with full EN + UK pages and are
registered in
simulations.json.
Tags
Newton's Method Fractals Basins of Attraction Sand Pile Self-Organised Criticality Power Law Complex Analysis Domain Coloring Conformal Mapping Wave 31
Wave 32 Preview
Three simulations are being designed for Wave 32:
- Diffusion-Limited Aggregation — particles perform random walks and stick on contact; the resulting DLA cluster has a fractal dimension ~1.71.
- Phase Portrait — interactive phase-plane analysis for 2D autonomous ODEs; visualise nullclines, fixed points, limit cycles and basins of attraction for Lotka-Volterra, van der Pol and custom systems.
- Turing Patterns — Alan Turing’s reaction-diffusion mechanism for morphogenesis; two morphogen species with different diffusivities spontaneously form spots, stripes, and labyrinths.
All Wave 32 simulations will ship with EN + UK pages on launch day.