Javascript mathematics

May 25, 2016 — August 2, 2022

computers are awful
javascript
photon choreography

Libraries for browser-based mathematics, e.g. for browser-based machine learning.

I am not longer active in this area, and my information is definitely somewhat stale. You might want to check google for the latest. In particular I suspect that hardcore use cases for math in the browser now use webassembly or other fast(er) technologies, rather than attempting to use this horrible language to do numerics as many of the below options do.

Figure 1

1 probabilistic calculators

Guestimate and squiggle are two probabilistic calculators that can be used to estimate the uncertainty in a calculation, and are implemented in javascript.

2 Arquero

uwdata/arquero: Query processing and transformation of array-backed data tables.

3 Simple statistics

See simple-statistics.

4 ml-matrix

ml-matrix (source) is used in some recent things. The API looks clean and sufficient for many classic ML tasks

5 math.js

math.js supports some useful matrix operations, and seems popular.

6 math.gl

math.gl

Welcome to math.gl! math.gl is JavaScript math library focused on geospatial and 3D use cases, designed as a composable, modular toolbox. math.gl provides a core module with classic vector and matrix classes, and a suite of optional modules implementing various aspects of geospatial and 3D math.

While the math.gl is highly optimized for use with the WebGL and WebGPU APIs, math.gl itself has no WebGL dependencies.

Backed by Uber, this may survive longer than some other options.

7 glMatrix

glMatrix (source) is a 3d-rendering-oriented library.

8 ML.js

The LORIA ML.js tools lalolib/ mlweb (source).

MLweb is an open-source project that aims at bringing machine learning capabilities to web pages and web applications. See the official website for more information.

MLweb includes the following three components:

  • ML.js: a javascript library for machine learning
  • LALOLib: a javascript library for scientific computing (linear algebra, statistics, optimization)
  • LALOLab: an online Matlab-like development environment (try it at http://mlweb.loria.fr/lalolab/)

They implement impressive functionality and even includes native support for worker threads and concurrency. However… it is lacking modern web wrappings such as npm packaging etc, so is not convenient to use from e.g. webpack. The source code repository is not anywhere obvious so I’m not sure how current the code is.

9 Pyodide

Python from the browser, including mathematical libraries.

HT Emma Krantz.

10 jStat

jStat is a statistical library written in JavaScript that allows you to perform advanced statistical operations without the need of a dedicated statistical language (e.g. MATLAB or R). Includes a tidy linear algebra library, but could be better optimised.

11 lmfit

lmfit is a javaScript (emscripten) port of lmfit, a “self-contained C library for Levenberg-Marquardt least-squares minimization and curve fitting”

Currently only linear curve fitting is implemented.

12 linalg

linalg uses native arrays because of their speed.

I needed a performance focused linear algebra module for visualizing data in 10+ dimensions, and implementing machine learning algorithms. I quickly learned that naive solutions to linear algebra operations can produce numerical errors so significant they are utterly useless for anything other than casual playtime. After that, I prioritized correctness over performance.

Untouched since released and small community, which is sad because the code looks solid.

13 Incoming