math
Five separately published families, all MIT-licensed, all on npm under @johnhenry/*.
| Package | What it is |
|---|---|
@johnhenry/math |
The core library — geometry, linear algebra, complex numbers, intervals, rotors, symbolic evaluation |
@johnhenry/math-plus-* |
21 focused packages for numeric computing: tensors, autograd, WASM kernels, WebGPU/MLX devices, safetensors, dataframes, FFT, signal, image, units |
@johnhenry/math-grapher |
A headless reactive-cell runtime, drivable by an AI agent over MCP |
@johnhenry/iteration |
Sync and async iterator algebra — transducers, itertools parity, bounded concurrency |
@johnhenry/math-prototype-patch |
Opt-in Number.prototype patch adding ComplexNumber’s fluent arithmetic to plain numbers |
Which one do I want?
Section titled “Which one do I want?”Doing mathematics — geometry, complex arithmetic, exact rationals, interval bounds — start with @johnhenry/math.
Doing numeric computing — n-dimensional arrays, gradients, matrix multiplication on the GPU, reading Parquet — start with math-plus-tensor-core and add only the extensions you need. The family is deliberately granular so you don’t ship a WebGPU backend to a project that just wants an FFT. It’s documented here in four clusters:
- Tensors — tensor-core, autograd, expression fusion, WASM kernels, the WebGPU/MLX/CPU devices, safetensors, and the honest answer to “how do I pick a backend?”
- Signal & media — FFT, SciPy’s signal slice, image ops, and every deliberate deviation from NumPy/SciPy conventions in one table
- Data — Arrow dataframes, Parquet with real pushdown, dataset pipelines, and the bigint/null/laziness traps
- Interop & telemetry — the MCP server for agents, the PyPI-side Python bridge, and the training-telemetry stream
Iterating over things — lazily, asynchronously, with backpressure — @johnhenry/iteration is independent of the rest and has zero runtime dependencies.
Letting an agent do the math — two different shapes: math-plus-mcp for stateless symbolic + guarded numeric tool calls, math-grapher for stateful sessions of reactive cells.
Versions
Section titled “Versions”The math packages are early. The math-plus tensor track has reached 0.1.x–0.3.x (tensor-core 0.2.1, tensor-webgpu 0.3.0); most other math-plus packages are still 0.0.x (fft 0.0.4, frame-arrow 0.0.5), and their internal ranges are carets on those versions. Under npm’s pre-1.0 caret rules ^0.0.4 matches only 0.0.4, and ^0.2.1 stops before 0.3.0 — every minor bump is breaking. Pin exact versions until these reach 1.0.
@johnhenry/iteration is the mature one: it has shipped under three names across several years (see its page for the provenance).
@johnhenry/math itself has similar history, several years deeper: it began as a TypeScript port of an ActionScript 3 library called Mallory. See About the port for the ~40 real bugs that port found and fixed along the way.
Source
Section titled “Source”Three repos, each with runnable examples:
math (core + iteration + prototype-patch, examples) ·
math-plus (examples) ·
math-grapher (examples)