mathjs
Extensive mathematics library for JavaScript and Node.js — expression parsing, symbolic algebra, matrix operations, units, and statistics.
mathjs
General JSExtensive mathematics library for JavaScript and Node.js — expression parsing, symbolic algebra, matrix operations, units, and statistics.
Fit
Bundle (gzip)
196.8 kB
729.1 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
JavaScript's native Math object covers basic trigonometry but lacks fractions, complex numbers, matrix operations, unit conversions, expression parsing, and symbolic computation needed for scientific and financial applications.
What It Does
Math.js evaluates mathematical expressions from strings (useful for formula builders and spreadsheet-like features), performs symbolic differentiation, handles fractions and complex numbers without floating-point loss, supports matrix/tensor operations, and converts between physical units.
Installation
npm install mathjsUsage Example
import { evaluate, derivative, unit, matrix } from 'mathjs';
// Evaluate expressions from user input
evaluate('sqrt(16) + 2^3'); // 12
evaluate('sin(pi / 4)'); // 0.7071...
// Symbolic differentiation
derivative('x^2 + 3*x', 'x').toString(); // '2 * x + 3'
// Unit conversion
unit('5 km').toNumber('mile'); // 3.107...
// Matrix operations
matrix([[1, 2], [3, 4]]);
evaluate('inv([1, 2; 3, 4])');Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.