TaHooR
© 2026 · TaHooR · running on arch btw
TaHooR@arch: \~/blog/mathematical-laboratory

I Built a Mathematical Laboratory Because Equations Deserve Better Than a Whiteboard

Mathematics has a marketing problem. Someone writes down a beautiful equation, puts it in a textbook, and then expects me to appreciate it while it sits there doing absolutely nothing.

I wanted to poke the equations. Change a number. Drag a point. Start a simulation. Watch everything go wrong for reasons that are, annoyingly, mathematically correct.

So I made Mathematical Laboratory: a collection of 50 interactive experiments built with HTML, CSS and JavaScript. It covers fractals, chaos, probability, number theory, geometry, calculus and a few subjects that refuse to stay politely inside one category.

The point wasn't to make 50 pretty animations. It was to make the difference between knowing a formula and understanding what it does a little smaller.

01 · Why Build a Mathematical Laboratory?

There is a big difference between reading “small changes in initial conditions can lead to large differences later” and watching two pendulums with almost identical starting angles drift into completely different trajectories.

Or reading that random experiments converge to predictable probabilities, versus actually running the trials and watching the results wobble around before settling down.

I wanted a place to do those experiments without installing a giant mathematical software stack or starting a new project for every equation. Open a page, touch the controls, and immediately get something worth asking questions about.

That also meant keeping the experiments independent. Every model gets its own page and implementation, but the interface and basic interactions feel familiar across the collection.

02 · Fifty Experiments, Several Rabbit Holes

The homepage is a catalogue, not one massive simulation pretending to do everything. The 50 entries are grouped into topics, and every page is an invitation to play with a particular idea.

AreaThings you can investigate
Fractals & chaosMandelbrot, Burning Ship, Newton fractals, strange attractors, cellular automata and the chaos game
ProbabilityMonty Hall, birthdays, random walks, Bayes, Markov chains, percolation and Monte Carlo experiments
Calculus & numerical methodsDerivatives, integration, Taylor series, Runge–Kutta, Fourier transforms and gradient descent
Geometry & linear algebraVoronoi diagrams, Möbius strips, eigenvectors, convex hulls, Delaunay triangulation and geodesics
Number theoryPrime spirals, factorization, prime gaps and the Collatz process

And then there are experiments like mathematical music, the double-slit simulation, N-body gravity and a universe drawn using the golden angle. Apparently I wasn't particularly interested in keeping the syllabus under control.

03 · Fractals: One Rule, Ridiculous Complexity

The Mandelbrot set is the clearest example of how much visual complexity can hide inside a tiny rule. Start with zero, repeatedly square the complex value and add a constant:

z₀ = 0
zₙ₊₁ = zₙ² + c

If the orbit escapes, color the point by
how many iterations it took to escape.

That's the trick. Each pixel represents a different complex number c, and its color depends on what happens when the recurrence runs. The boundary is where the interesting things happen; zoom in and familiar-looking structures keep giving way to more detail.

The original Mandelbrot explorer has its own deep-zoom implementation, including GPU rendering. The broader fractal explorer is a separate, more bounded playground. Those aren't interchangeable claims: the latter caps its zoom, while the dedicated Mandelbrot page is designed to go dramatically deeper.

The Burning Ship fractal adds absolute values to the real and imaginary coordinates before squaring. Newton fractals turn numerical root finding into colored regions of attraction. Similar ingredients, wildly different pictures.

zₙ₊₁ = (|Re(zₙ)| + i|Im(zₙ)|)² + c

A tiny change to an iteration rule can reshape an entire mathematical world. That's a better demonstration than staring at the formula and politely nodding.

04 · Chaos Is Not the Same as Randomness

The double pendulum is one of my favorite examples. Two linked pendulums obey deterministic equations, yet two nearly identical starting configurations can become visibly different as time passes.

The strange-attractor experiment explores the same broader idea from another direction: a trajectory can stay in a bounded region without settling into a simple loop. You get structure without easy long-term prediction.

And with reaction–diffusion, the apparent chaos becomes spots, stripes and moving boundaries. The Gray–Scott model combines diffusion with reactions, making pattern formation something you can influence by changing the parameters.

∂u/∂t = Dᵤ∇²u − uv² + f(1 − u)

Diffusion spreads concentrations.
Reaction and feed terms reshape the pattern.

In all three cases the fun is not just watching motion. It's changing one input and noticing exactly when your intuition stops being useful.

05 · Probability Is Much More Convincing When It Misbehaves

Consider the Monty Hall problem. Three doors, one prize, and a host who knows where the prize is. After the host opens a losing door, switching gives a 2/3 chance of winning under the standard rules, instead of the 1/3 chance from staying.

On paper that result seems suspicious. With repeated simulated games, it becomes much harder to argue with.

Standard Monty Hall setup:

P(win | always stay)   = 1/3
P(win | always switch) = 2/3

The probability section also covers the birthday problem, Galton boards, Buffon's needle, gambler's ruin, random walks, Bayesian updating, Markov chains, percolation and Monte Carlo sampling. Each takes a different route to the same lesson: individual outcomes can be messy even when the underlying statistics are precise.

These are simulated trials, not magic proof machines. A finite run will fluctuate around a theoretical answer. That's part of what makes them worth watching.

06 · Geometry Isn't Always Flat, Straight or Sensible

The Voronoi experiment divides space according to whichever seed point is closest. Move one seed, and its territory changes. Switch the distance metric, and even the meaning of “closest” changes.

The Möbius strip explores a surface with one continuous side and one boundary. Hyperbolic geometry uses the Poincaré disk to represent an infinite geometry inside a finite circle. Geodesics compare routes on a sphere, where the locally shortest path is not generally a straight-looking line on a flat map.

There's more computational geometry here too: convex hulls, Delaunay triangulation, Bézier curves, sphere projections and a traveling-salesman route explorer.

Sometimes the most useful mathematical question is simply: “What happens if I drag this point over there?”

The traveling-salesman demo is deliberately an approximation: nearest-neighbor followed by 2-opt improvements, not an exact solver that guarantees the shortest possible tour. That distinction matters.

07 · Calculus and Numerical Methods, Without the Handwaving

For calculus, I wanted to see approximations fail as well as succeed. The numerical-methods race compares Euler, midpoint and fourth-order Runge–Kutta on the same differential equation:

y′ = y,  y(0) = 1

Exact solution: y(t) = eᵗ

Compare:
  Euler
  Midpoint
  RK4

Change the step size and watch the error change. Taylor series show how derivatives near one point can approximate a function. Integration experiments compare rectangles, trapezoids and Simpson's rule. Gradient descent turns “move against the gradient” into a path you can follow.

Fourier epicycles reconstruct a drawing by adding rotating circles. The Fourier transform experiment decomposes a sampled signal into frequency components. Mathematical music builds waveforms from harmonics, showing that a relatively small mathematical description can change what a sound would be like.

Under the hood, these are finite numerical models, with real limits on sampling, precision, step sizes and supported expressions. Those limitations aren't bugs in mathematics; they're part of doing mathematics with a computer.

08 · How the Laboratory Is Built

Despite the number of demos, this is a static web project. The repository documents no installation and no build step for normal browsing: open the homepage, or serve the folder locally if you prefer HTTP.

mathematical-laboratory/
├── index.html
├── experiments.js
├── shared.css
├── shared/
│   ├── lab.js
│   └── math.js
├── 01-mandelbrot/
│   ├── index.html
│   ├── style.css
│   ├── script.js
│   └── README.md
├── 02-burning-ship/
├── ...
└── 50-mathematical-universe/

The catalogue lives in experiments.js. Individual experiment folders own their simulation model, parameters, presets and explanations. The shared laboratory module provides canvas and control primitives, while the shared math module collects reusable numerical helpers.

That separation matters: one demo doesn't need to import another demo's physics or mathematical assumptions just to draw a point on the screen.

# from the project directory
python -m http.server 8000

# then open http://localhost:8000

09 · The Controls Are Part of the Explanation

Every experiment gives you a short concept explanation, a formula and something to try. Controls sit beside the visualization on desktop and move below it on smaller screens. You can manipulate relevant points and shapes with a mouse or touch.

For dynamic simulations, there are Pause, Step and Reset controls. Presets give useful starting configurations; Restart keeps your current parameters. View controls handle scale, line weight and the reference grid. Save PNG and Fullscreen let you keep the interesting accidents.

There are deliberate quality-of-life details too: normal scrolling doesn't accidentally pan a graph, reduced-motion preferences start new animations paused, and sound only starts after an explicit action.

A laboratory is only useful if experimenting feels natural instead of like you're fighting the interface.

10 · Making Sure Fifty Demos Don't Turn Into Fifty Bugs

There are documented checks for mathematical reference calculations, expression parsing, model independence, presets, parameters and project links. A separate browser check covers desktop and narrow viewport sizes, control extremes and selected screenshots.

node --test tests/math.test.js tests/projects.test.js
node tests/browser-check.js

The browser check is optional, uses Microsoft Edge on Windows and doesn't require npm dependencies. These commands are the documented verification workflow; I'm not claiming a fresh test run or a performance benchmark here.

There's also an honest numerical scope: finite iterations for fractals, softened fixed-step N-body gravity, approximate route optimization, sampled integrals and trial counts that can only estimate probabilities. Putting numbers on a screen doesn't make their assumptions disappear.

11 · What I Took Away From This

The first lesson is that mathematical understanding gets better when you can vary the inputs. You stop memorizing what the answer is supposed to look like and start developing a feel for why it looks that way.

The second is that visualization forces you to confront implementation details. A beautiful formula might need discretization, numerical safeguards, finite precision, iteration limits and a reasonably sensible user interface before it becomes a usable experiment.

The third is that a collection of small independent experiments can be more useful than one giant, complicated application. Each page has a question, a model and some room to play.

Also, it turns out that doing mathematics with sliders is an excellent way to lose track of an afternoon.

12 · The Completely Unbiased Coolness Report

The following results have not been reviewed by any respectable journal.

$ ./evaluate-life-choices

[✓] 50 interactive experiments
[✓] fractals that refuse to stop fractaling
[✓] pendulums demonstrating chaos
[✓] probabilities arguing with intuition
[✓] geometry being geometrically suspicious
[✓] numerical methods making errors visibly
[✓] zero mandatory build steps

[?] should probably study actual coursework

verdict: mathematics is significantly less boring
confidence: visually compelling
exit code: 0

13 · Source and How to Explore It

Start with the project's index.html catalogue. Pick a topic, open the experiment, read its formula, then change one control at a time. The README in each experiment folder explains the model and a few useful things to try.

Nothing here is a replacement for a proof or a high-precision scientific solver. It's a place to make abstract ideas concrete, notice patterns, and ask better questions.


I built the Mathematical Laboratory because I wanted equations to do something instead of just sitting in a notebook looking important.

Fifty experiments later, I think they got the message.