Math.js is a math library for JavaScript and for Node.js, the runtime that lets you run JavaScript outside of a browser. It is meant to extend what the language gives you for math out of the box. JavaScript on its own has a small Math object with things like sine and square root, but it works only on ordinary numbers. Math.js adds many more kinds of values and many more functions. The supported value types include regular numbers, big numbers for arbitrary precision, BigInts, complex numbers, fractions, physical units, strings, arrays, and matrices. Functions know how to handle these together, so you can multiply a regular number by a complex number, or do matrix operations and unit conversions in the same expression. A notable feature is the expression parser. Instead of writing JavaScript code, you can pass a string like 12.7 cm to inch or det([-1, 2; 3, 1]) and the library will evaluate it. The README also shows chained operations, where you start with a value and call a sequence of methods on it. The same expression parser can be used as a command-line application. Symbolic computation is supported too, including taking derivatives. Installation is through npm or by downloading a bundle from one of the CDNs listed on the project website. The library runs on any JavaScript engine that supports the ES2020 standard, which covers current versions of Node, Chrome, Firefox, Safari, and Edge. The README also documents the internals for contributors. The architecture is built on a library called typed-function, which lets one function name accept many input types and convert between them, plus a dependency injection setup that lets higher-level functions like prod automatically pick up new types added to lower-level ones like multiply.
Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.