An open-source spin-off project aimed at exploring mathematics — ranging from trigonometric functions in two-dimensional spaces to topology, fractal geometry, and many more features to come. The project is under active development; if you'd like to help, contributions are very welcome.
It is a single, coherent mathematical exploration engine: every workspace
below shares one math core (lexer → parser → AST → evaluator, complex numbers,
symbolic calculus, and an AST→GLSL compiler). No two engines, no eval.
🔗 Live demo: mathematics-simulator.vercel.app — deployed on Vercel, continuously deployed from the
mainbranch. No local backend; the whole app runs in the browser.
The top navigation switches between ten workspaces:
- 2D: plot
y = f(x), multiple expressions with color + visibility, pan/zoom, live trace off(x)andf'(x). - Sliders: any undefined variable becomes a slider;
min/max/stepaccept expressions (so a slider can be limited to a set, e.g.{0, 2, …, n−1}); per-slider animation (loop / ping-pong). - Analysis tools: draggable locator, tangent line with symbolic derivative, shaded definite integral (Simpson's rule).
- 3D: explicit surfaces
z = f(x, y)and implicit surfacesF(x, y, z) = 0(marching tetrahedra), multiple surfaces at once, bounding box + numbered axes, probe point showingf,∂f/∂x,∂f/∂y,‖∇f‖, orbit camera + view presets.
- Mandelbrot, Julia (pick-from-Mandelbrot), Burning Ship, Tricorn, Celtic, Buffalo, Newton.
- Generalised exponent
z^p + c(incl. decimals), smooth coloring, 6 palettes. - Deep zoom via emulated double precision (double-single, df64).
- Custom
f(z,c)and Complexf(z)domain coloring — your typed expression is compiled through the shared parser into a GPU shader. - Parameter animation, PNG + config JSON export.
- Gates X, Y, Z, H, S, S†, T, T† and Rx/Ry/Rz rotations.
- Drive pulses (Rabi Ω, detuning Δ, phase φ, duration t) with a live preview of the effective rotation axis + ghost arc before applying.
- State trajectory, arrow animation,
|ψ⟩/ θ,φ readout, and measurement probability bars in the X/Y/Z bases.
- Tesseract, 5-cell, 16-cell, 24-cell, and parametric surfaces
(u,v) → ℝ⁴(Clifford torus, Hopf fibration, …) typed with the shared parser. - Rotation in all six 4-space planes, perspective projection
d/(d−w), and the 4th dimension mapped to color. Auto double-rotation.
- Everyday objects grouped by genus (ball, egg, plate, bowl, vase, cup…; donut, mug, teacup, ring, bagel, CD…).
- Continuous morph between same-genus shapes (mug ↔ donut, cup ↔ ball) — the
panel verifies homeomorphism via genus / Euler characteristic
χ = 2 − 2g. - Grab & deform: pull the surface, inflate, twist, random deform — all topology-preserving. Spin in space, wireframe, color modes.
- Type an autonomous system
ẋ = f(x,y),ẏ = g(x,y)(or pick a preset: rotation, damped oscillator, saddle, Van der Pol, pendulum, spiral sink). - Vector field, pan/zoom navigable plane, and equilibria colored by stability (stable/unstable node, spiral, saddle, center — from the Jacobian spectrum).
- Trajectory animation: click a start point and a particle flows along the field (RK4) to its end point — the equilibrium / singularity it converges to. Play/pause + speed.
One view, one Model toggle, three physical models sharing the same orbit
camera and render loop (all physics runs outside React, in refs; the shared
parser + ODE solver are reused — no second engine, no eval):
- Mathematical Field
x′ = F(x)— typedx/dt, dy/dt, dz/dtoverx, y, z, parsed through the sameDynamicalSystemused by the 2D phase-plane view. Rendered as sampled vector arrows on a grid plus a handful of particle-probe streamlines, integrated via the shared ODE registry. - Newtonian gravity — N-body with velocity-Verlet / RK4, collisions/merging,
energy & momentum diagnostics. Exact (
Φ = -GM/r, safely floored nearr=0) and softened-Plummer models sit behind one shared force/potential seam and are switchable per-scenario; diagnostics are taggedexact/numerical/proxy(honest about what the nonphysicalgravitationalStrengthknob does to conservation). The space-time deformation surface is explicitly a potential proxy, not the Einstein metric. - General Relativity — real geodesics of an analytic metric,
d²xᵘ/dτ² + Γᵘ₍αβ₎ uᵃ uᵝ = 0, integrated by the shared ODE solver. Metrics: Minkowski (flat baseline), Schwarzschild and Kerr (rotating, spina, non-diagonal Boyer-Lindquist metric) — one shared engine derives the inverse metric, Christoffel symbols and Riemann/Ricci/Einstein curvature from the metric alone, nothing model-specific hardcoded. Every metric shows its provenance; the 3D trace is captioned as a coordinate-position plot, not a literal spacetime embedding.
Click to spawn — every model shares the same body-preset picker (Particle, Planet, Star, Black Hole, Singularity, with procedural planet palettes): click the canvas to place a celestial marker. In Newtonian gravity it's a real N-body with mass; in Mathematical Field and General Relativity it's a visual marker only, advected by the field / integrated along a geodesic from the clicked point — the preset never leaks mass or softening into that physics.
- Select an object (expression, matrix, vector, topological surface, dynamical
system, ODE, probability distribution, dataset, time series) and get a typed
report: structure/AST, classification, domain, calculus (
f',f'',∇, Hessian,∇²), roots & critical points; matrix rank/det/eigenstructure/ decompositions/conditioning/subspaces + 2×2 geometric action. - Every value is tagged exact / symbolic / numerical / estimated / inferred, with compare mode, capability chips, navigable related objects, and honest assumptions/limits. Registry-driven — new domains plug in without touching the engine.
- A document of cells (markdown / parameter / expression / analysis) whose outputs are derived deterministically from the source; parameters propagate through a dependency graph and downstream analyses recompute.
- Undo/redo, snapshots, localStorage autosave, import/export as
.mathsim.json(declarative, schema-validated, noeval), and a bundled example gallery spanning calculus, linear algebra, optimization, dynamics, ODEs, PDEs, probability, number theory, complex analysis, and units.
- Bilingual (English / Español) manual explaining every workspace and its underlying mathematics, with formulas typeset by KaTeX.
Beyond the visual workspaces, the math core (src/mathlab/) is a serious
scientific-computing environment. Every domain shares the same object →
analysis → Inspector → visualization → experiment architecture, so you move
naturally between symbolic math, numerical math, and simulation.
| Domain | Highlights |
|---|---|
| Linear algebra | LU / QR / Cholesky decompositions, SVD (UΣVᵀ), eigen (Jacobi + QR iteration), least squares, nullspace, condition number, 2D/3D geometric visualization |
| Dynamical systems | Continuous flows & discrete maps, equilibria (Newton), Jacobian stability (Hartman–Grobman), phase space, nullclines, bifurcation & chaos (Lyapunov, orbits) |
| ODEs | Euler, Heun, RK2, RK4, adaptive RKF45; systems & IVPs; error metadata, parameter sweeps, method comparison |
| PDEs | 1D heat, 1D wave, 2D Laplace/Poisson via finite differences; CFL/stability-aware |
| Optimization | Golden-section, gradient descent, damped Newton; trajectories, Hessian classification, convergence analysis |
| Probability / Statistics | 6 distributions (Bernoulli → Poisson), seeded sampling, Monte Carlo, descriptive stats, Dataset object, regression |
| Number theory | bigint-exact gcd/lcm/extended-Euclid, Miller–Rabin primality, Pollard ρ factorization, φ, μ, Collatz |
| Complex analysis | Domain coloring, grid mapping (z², eˣ, 1/z, log z), Cauchy–Riemann, special functions (Gamma, erf) |
| Scientific computing | Units & dimensional analysis, constants registry, uncertainty propagation, unified numerical-method registry |
The correctness-critical layer, unit-tested (1313 tests), all consuming one AST:
core/—lexer→parser→ast, realeval(whitelisted functions, nevereval/Function),simplify,print,complexGlsl(AST → GLSL), structurederrors, seededrng, central tolerances, a unified numerical-method registry, and the sharedTimeSeriesobject.calculus/— symbolic differentiation, Taylor, gradient/Hessian/Jacobian/Laplacian.analysis/+numeric/— roots (bisection/Newton), integration (Simpson + adaptive), limits.linear/— matrix ops, LU/QR/Cholesky/SVD, eigenvalues/eigenvectors (symmetric Jacobi + general QR), least squares, subspaces, conditioning.ode/— Euler/Heun/RK2/RK4 + adaptive RKF45 with metadata.dynamics/— systems, equilibria, Jacobian stability (continuous & discrete), trajectories.dynamics3d/— N-body gravity and arbitrary 3D vector fieldsx′ = F(x)(streamlines via the shared solver).relativity/— generic differential geometry from a metric alone (inverse metric, Christoffel, Riemann/Ricci/Einstein), geodesic integration via the shared ODE solver, and analytic Minkowski / Schwarzschild / Kerr models with provenance, including frame-dragging (zero-angular-momentum test particles).optimization/— golden-section, gradient descent, Newton, critical-point classify.probability/+statistics/— distributions + seeded sampling + Monte Carlo; dataset, descriptives, regression.numberTheory/— exact bigint arithmetic, primality, factorization, φ, μ, Collatz.units/— dimensional quantities, conversion, constants, uncertainty.complex/— first-class complex scalars,Node → Complexeval, Cauchy–Riemann.pde/— 1D heat & wave, 2D Laplace/Poisson (finite differences).special/— Gamma, log-Gamma, erf.
The inspector/ (registry-driven analysis engine), experiment/ (notebook
document model + safe serialization), and a lightweight search/ index sit
above the kernel. The same parsed AST feeds the calculator, the fractal
shaders, and every analysis — that is the core design principle: one
engine, no duplicates, no eval.
- React 19 + TypeScript (strict) + Vite 7
- TailwindCSS v4
- WebGL for fractals, 3D surfaces, the Bloch sphere, and 4D rendering
- zustand for state
- KaTeX for typeset math (lazy-loaded)
- Vitest for tests
- Deployed on Vercel
src/
mathlab/ shared math core: core, calculus, analysis, numeric, linear, ode,
dynamics, dynamics3d, relativity, optimization, probability,
statistics, numberTheory, units, complex, pde, special, symbolic
inspector/ registry-driven inspection engine (types, capabilities, inspect/*)
experiment/ notebook document model, execution engine, safe serialization
search/ lightweight cross-workspace search index
fractals/ fractal registry + types
webgl/ WebGL renderer + AST→GLSL custom-shader builder
graph/ graphing state + slider config
bloch/ qubit math + state fourd/ 4D vectors, polytopes, surfaces
topo/ topology surfaces + mesh + morph
components/ React UI per workspace (graph, bloch, fourd, topo, dynamics,
dynamics3d, inspector, notebook, docs, …)
App.tsx top-level workspace switcher
git clone https://github.com/Max-arango/Mathematics-Simulator.git
cd Mathematics-Simulator
npm install
npm run dev # http://localhost:5173Other scripts:
npm run build # type-check + production build (outputs to dist/)
npm run preview # preview the production build
npm test # run the test suite (Vitest)Requires a modern browser with WebGL.
The app is a fully static single-page application (no backend) and is deployed
on Vercel with continuous deployment from main:
- Build command:
npm run build - Output directory:
dist
Any push to main triggers a new deployment.
The project is under development and help is welcome — new fractals, surfaces, calculator tools, or fixes. A good contribution:
- Keeps the shared math core shared (no duplicate parsers/engines).
- Adds a test for non-trivial math (
npm testmust stay green). - Uses no
eval/new Function— everything goes through the parser/AST.
Fork, branch, and open a pull request.
Released under the MIT License.