Javascript mathematics

Libraries for browser-based mathematics, e.g. for browser-based machine learning ranked in descending order of viability:

  • weblas does GPU-accelerated mathematics and is used in hip projects such as keras-js.

  • ndarray also used in keras-js.

  • lalolib/mlweb/

    LALOLib (Linear ALgebra Online Library) is a library entirely written in Javascript to enable and ease mathematical computing within web pages. It is developed as a part of the MLweb project and constitutes the core of LALOLab (an online scientific computing environment). It also provides the basic building blocks for ML.js, a javascript library for machine learning.

    This looks genuinely amazing in terms of 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.

  • math.js

s * linear-algebra (blog post)

Efficient, high-performance linear algebra library for node.js and browsers.

This is a low-level algebra library which supports basic vector and matrix operations, and has been designed with machine learning algorithms in mind.


Simple, expressive, chainable API. Array implementation with performance optimizations. Enhanced floating point precision if needed. Comprehensive unit tests. Works in node.js and browsers. Small: ~1 KB minified and gzipped.

  • sylvester the original, but predates much modern optimisation such as native arrays and asm.js

  • 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.

  • lmfit

    JavaScript (emscripten) port of lmfit library:

    a self-contained C library for Levenberg-Marquardt least-squares minimization and curve fitting

    Currently only linear curve fitting is implemented.

  • 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.

  • numeric looks polished but has been untouched for 2 years

  • jmat is an actively developed complex matrix library, but we would probably prefer speed to complex number support.

  • random variables can be simulated easily using the probability distributions library

  • nerdamer is a symbolic math library for javascript (!)

Warning! Experimental comments system! If is does not work for you, let me know via the contact form.

No comments yet!

GitHub-flavored Markdown & a sane subset of HTML is supported.