Algorithms and pure mathematics are domains where the gap between textbook description and genuine understanding can be enormous. A shortest-path algorithm is defined by a few lines of pseudocode, but understanding why it works — why the heuristic is admissible, what happens when the heuristic overestimates, how the open set evolves as the search proceeds — requires watching it run. Similarly, the central limit theorem is stated in a single line, but the rate of convergence to normality and the way non-Gaussian tails persist at finite sample sizes only becomes intuitive through repetition and direct observation. The eight simulations in this spotlight address that gap.
I. A* Pathfinding
A* is the standard pathfinding algorithm in robotics, game development and navigation systems. It combines Dijkstra's exhaustive shortest-path search with a heuristic function that guides the search toward the goal, trading computational effort for directedness:
f(n) = g(n) + h(n)
where:
g(n) : actual cost from start to node n
h(n) : heuristic estimate of cost from n to goal
Admissibility condition: h(n) ≤ true cost from n to goal
⇒ A* is guaranteed to find the optimal path
Common heuristics for grid graphs:
Manhattan: h = |dx| + |dy| (4-connectivity)
Chebyshev: h = max(|dx|, |dy|) (8-connectivity)
Euclidean: h = √(dx² + dy²) (any connectivity)
The simulation runs on a grid where walls can be drawn by clicking and dragging. The algorithm executes step by step, colouring cells by their current f, g and h values. The open set (nodes under consideration) and closed set (nodes already processed) are distinguished by different colours, and the final shortest path is traced in bright green. A heuristic weight slider demonstrates weighted A* (f = g + wh): weight 1 gives optimal A*, weight 0 degrades to Dijkstra, and weight greater than 1 gives suboptimal but faster search. This last feature — the explicit demonstration of the optimality-speed tradeoff — is the one that consistently surprises students who assumed that ‘better heuristic always better’.
A* Pathfinding — Heuristic Comparison, Weighted Search
Draw walls, place start and goal, and watch the open/closed sets evolve step by step. Switch between Manhattan, Chebyshev and Euclidean heuristics and observe how the search frontier changes shape.
II. Bezier Curves
Bezier curves underpin every vector graphics tool, font renderer, animation system and SVG implementation in existence. They are defined by the de Casteljau algorithm, which constructs the curve through repeated linear interpolation:
de Casteljau algorithm for degree n curve with control points P0...Pn:
Pi(0) = Pi
Pi(r) = (1-t) Pi(r-1) + t Pi+1(r-1)
Curve point at parameter t: B(t) = P0(n)
Bernstein polynomial form:
B(t) = Σi=0n C(n,i) ti (1-t)n-i Pi
Properties:
Lies within convex hull of control points
Interpolates endpoints P0 and Pn
Tangent at P0 is along (P1 - P0)
The simulation renders the de Casteljau construction dynamically as the parameter t sweeps from 0 to 1. At each step, the intermediate line segments are drawn in colour, showing exactly which linear combinations produce the curve point. Control points are draggable, and the curve updates instantly. A degree selector lets users switch between quadratic (3 control points), cubic (4), quartic (5) and higher-degree curves. The convex hull of the control polygon is displayed as a faint boundary, making the convex hull property directly visible: the curve never escapes it, regardless of how the control points are arranged.
Bezier Curves — de Casteljau Construction
Drag control points and watch the de Casteljau intermediate segments animate in real time. Compare quadratic, cubic and higher-degree curves and observe how the convex hull constrains the curve.
III. Bayesian Inference
Bayesian inference is the mathematically consistent framework for updating beliefs in response to evidence. Bayes' theorem in its simplest form:
P(H | D) = P(D | H) × P(H) / P(D)
posterior = likelihood × prior / evidence
For a continuous parameter θ with conjugate priors:
Beta-Binomial (proportion estimation):
Prior: θ ~ Beta(α, β)
Likelihood: k successes in n trials
Posterior: θ ~ Beta(α + k, β + n - k)
Normal-Normal (mean estimation, known variance):
Prior: μ ~ N(μ0, σ0²)
Likelihood: x¯ from n observations
Posterior: μ ~ N(μn, σn²)
where σn-2 = σ0-2 + n/σ²
The simulation offers two modes. In coin-flip mode, users set a prior Beta distribution on the bias probability and observe how the posterior updates each time a new flip result arrives — either by clicking (manual observation) or by running an automated sequence. The prior, likelihood and posterior are plotted simultaneously on the same axis, making Bayes' theorem a visible geometric operation rather than an abstract formula. In Gaussian mode, users estimate the mean of a normal distribution with known variance, watching the posterior narrow as more observations accumulate and verifying that the posterior mean is a precision-weighted average of the prior mean and the sample mean.
📊Bayesian Inference — Beta-Binomial and Normal-Normal
Set a prior, add evidence one observation at a time, and watch the posterior distribution update interactively. Observe how the prior is overwhelmed by data as sample size grows.
IV. Central Limit Theorem
The central limit theorem (CLT) is perhaps the most important result in statistics. It says that the sum of a large number of independent random variables, regardless of their individual distribution, converges to a Gaussian. More precisely, for IID variables with mean μ and variance σ²:
Sn = (X1 + ... + Xn - nμ) / (σ√n) → N(0, 1) as n → ∞
Rate of convergence: Berry-Esseen theorem
|P(Sn ≤ x) - Φ(x)| ≤ C ρ / (σ³ √n)
where ρ = E[|X - μ|³] (third absolute moment)
Slower convergence for heavy-tailed or skewed distributions.
The simulation lets users choose from six parent distributions: uniform, exponential, Cauchy (which explicitly violates the CLT conditions due to undefined variance), Bernoulli, bimodal mixture, and Pareto with adjustable tail index. The user sets the sample size n, draws repeated samples, and watches the histogram of sample means build up. The theoretical normal approximation is overlaid, and a Q-Q plot shows how close the empirical distribution is to Gaussian. The Cauchy distribution mode is the most instructive: the sample mean never converges, and the Q-Q plot diverges further from the diagonal as sample size grows, making the importance of the finite-variance condition viscerally clear.
Central Limit Theorem — Six Parent Distributions, Q-Q Plot
Watch the sampling distribution of the mean converge to Gaussian for any well-behaved distribution. Try the Cauchy mode to see what happens when the variance is undefined.
V. Boolean Network
Stuart Kauffman's NK Boolean network model is one of the canonical models of complex systems and has been applied to gene regulatory networks, neural circuits and social influence dynamics. Each of N nodes has a binary state and receives inputs from K randomly chosen other nodes, updating via a random Boolean function:
Kauffman NK model:
N nodes, each with binary state si ∈ {0, 1}
K random inputs per node
2K entries in each node's random truth table
Phase boundary (annealed approximation):
Kc = 1 / (2 p(1-p))
where p = probability of output = 1
K < Kc : ordered phase (attractors small, perturbations die)
K = Kc : critical phase (attractors ~ √N, Hamming distance ~ 1)
K > Kc : chaotic phase (attractors exponential, perturbations amplify)
The simulation displays the N nodes as a circular network, with each node coloured by its current binary state. Attractor cycles are detected automatically and highlighted: the network always falls into a repeating cycle from any initial condition, and the simulation shows both the transient approach to the attractor and the attractor cycle length. The critical connectivity K = 2 is pre-selected as the default because it sits at the phase boundary for p = 0.5: perturbation experiments at this connectivity show neither immediate extinction (ordered phase) nor explosive spreading (chaotic phase), but instead the marginal, long-range propagation that Kauffman proposed as a signature of biological regulatory networks.
Boolean Network — Kauffman NK, Phase Diagram
Explore the order-chaos boundary at K = 2, measure attractor cycle lengths, and run single-node perturbation experiments to probe the sensitivity of the network at different connectivities.
VI. B-Tree
The B-tree is the dominant data structure for database indexing and file systems, used inside every major relational database and operating system. It generalises the binary search tree to allow nodes with many children, keeping the tree height small even for billions of records:
B-tree of order m:
Each internal node has between ⌈m/2⌉ and m children
Each leaf node has between ⌈m/2⌉ - 1 and m - 1 keys
All leaves are at the same depth h
Height bound:
h ≤ log⌈m/2⌉( (n+1)/2 )
For n = 106 records, m = 100:
h ≤ log50(500001) ≈ 3.4 ⇒ h = 4 at most
This is why B-trees are used for disk-based storage:
4 disk reads to locate any record among 1 million.
The simulation animates insertions, deletions and searches in a B-tree with user-configurable order. Each operation is stepped through visually: insertions trigger node splits animated as divisions, deletions trigger merges or redistribution highlighted with colour transitions, and searches trace the path from root to leaf with each comparison shown. The tree rebalances automatically and the height is displayed continuously, making it possible to observe directly that the height grows only logarithmically as records are inserted — the fundamental property that makes B-trees practical for database indices.
🌳B-Tree — Animated Insert, Delete, Search
Insert and delete keys and watch node splits and merges animate step by step. Observe that tree height grows only logarithmically regardless of insertion order.
VII. Bloom Filter
A Bloom filter is a probabilistic data structure that answers set-membership queries with no false negatives and a bounded false-positive rate, using a fraction of the memory that an exact structure would require:
Bloom filter with m bits, k hash functions, n elements inserted:
False positive probability:
P(fp) ≈ (1 - e-kn/m)k
Optimal number of hash functions:
kopt = (m/n) ln 2 ≈ 0.693 (m/n)
Optimal bits per element for target false-positive rate p:
m/n = -log2(p) / ln 2 ≈ -1.44 log2(p)
Example: 1% false-positive rate requires ~9.6 bits/element
0.1% requires ~14.4 bits/element
The simulation displays the bit array as a row of coloured cells. Each insertion hashes the key with k independent hash functions and sets the corresponding bits. Query operations trace the same hash positions, and a false positive is triggered whenever all queried bits happen to be set by previous insertions of different keys. The false-positive rate measured experimentally converges to the theoretical formula as more elements are inserted, and a live plot of measured versus predicted false-positive rate confirms the accuracy of the approximation. The trade-off between m, k, n and the false-positive rate is fully adjustable, making the filter design problem directly explorable.
Bloom Filter — False Positive Rate, Hash Functions
Insert keys and query the filter, watching false positives accumulate. Adjust the number of hash functions and bit array size to find the optimal configuration for a target false-positive rate.
VIII. Complex Functions
Complex analysis is one of the most beautiful areas of mathematics, and domain colouring makes its key objects directly visible. A complex function f(z) assigns a complex number to each point in the complex plane; domain colouring maps the output to a colour:
Domain colouring scheme:
Hue: arg(f(z)) mapped to [0, 2π] (angle)
Brightness: |f(z)| encoded by a periodic function of log|f(z)|
Zeros of f: points where |f(z)| = 0 (black)
Poles of f: points where |f(z)| → ∞ (white)
Branch cuts: discontinuities in hue
Examples:
f(z) = z² : hue winds twice around origin
f(z) = 1/z : pole at origin (white point), hue winds backwards
f(z) = ez : horizontal periodicity, no zeros or poles in ℂ
f(z) = Γ(z) : poles at 0, -1, -2, ... (white points), beautiful spirals
The simulation computes domain colourings on the GPU via a WebGL fragment shader, evaluating the selected function at every pixel simultaneously and mapping the result to the HSL colour space. Functions available include elementary functions (polynomials, rational functions, exponential, logarithm, trigonometric), special functions (Gamma, Riemann zeta, Jacobi elliptic), and a custom expression parser that accepts arbitrary complex function syntax. Dragging the viewport pans and the scroll wheel zooms, maintaining real-time rendering throughout.
The Riemann zeta function is the most visually striking option. The famous non-trivial zeros on the critical line Re(s) = 1/2 appear as black points at heights matching the known values (14.13, 21.02, 25.01, ...), and the self-similar structure of the function away from the critical strip can be observed directly. No other commonly available tool allows a non-specialist to explore the zeta function at this level of visual immediacy.
Complex Functions — Domain Colouring, GPU Shaders
Explore the Riemann zeta function, Gamma function, and custom complex expressions via GPU-accelerated domain colouring. Zeros appear as black points, poles as white, and branch cuts as hue discontinuities.
Why Algorithms and Mathematics?
The question sometimes arises: why include purely abstract algorithms and mathematics in a platform that began with physics simulations? The answer is that the boundary between abstract mathematics and physical reality is not where it appears. A* pathfinding is used in every self-driving vehicle. Bloom filters handle billions of queries per day in distributed databases that serve science as much as commerce. Bezier curves render every vector graphic in every scientific paper and slide deck. The central limit theorem underlies every error bar in every physics measurement. Complex functions are the mathematical backbone of quantum mechanics. Boolean networks are applied models of gene regulation.
The full algorithms category and mathematics category contain the complete collections. All eight simulations highlighted here are available in English, Ukrainian and Polish.