mathjs

Extensive math library for JavaScript and Node.js with big numbers, complex numbers, units, and matrices.

Library
npm
v15.2.0
15,078 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
66 /100 Good
Development Activity 64
Maintenance 24
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 88
Code Quality 85
Innovation 82
Learning Curve 80

Math.js is a comprehensive math library for JavaScript and Node.js that goes far beyond the built-in Math object. It supports numbers, BigNumbers, bigints, complex numbers, fractions, units, strings, arrays, and matrices, all interoperable through a typed-function and dependency-injection architecture that lets custom data types plug into existing operators. On top of the numeric core it ships a flexible expression parser capable of symbolic computation and chained operations, so consumers can evaluate string expressions like unit conversions or determinants directly.

Because every function is generated from small, composable factory functions, applications can import the full library or hand-pick a lightweight subset (e.g. plain-number-only variants) to control bundle size. It runs identically in Node.js and any ES2020-compatible browser, and includes a CLI for quick expression evaluation from the terminal.

What You Get

  • A drop-in superset of JavaScript’s Math library with extensive numeric type support (BigNumber, bigint, Complex, Fraction, Unit, Matrix)
  • A string expression parser supporting symbolic computation, unit conversions, and chained operations
  • Extensible typed functions and dependency injection so new data types integrate with existing operators
  • Tree-shakeable factory functions for building lightweight, number-only bundles
  • A command-line interface for evaluating expressions without writing JavaScript
  • TypeScript type definitions maintained alongside the JavaScript source

Common Use Cases

  • Scientific and engineering calculators that need big numbers, complex numbers, or unit-aware arithmetic
  • Spreadsheet-like applications evaluating user-entered formulas via the expression parser
  • Symbolic computation such as computing derivatives of algebraic expressions
  • Matrix and linear algebra operations in data-processing or visualization tools
  • Unit conversion utilities embedded in web or Node.js applications

Under The Hood

Architecture - Mathjs is built around two ideas: typed functions (via the companion typed-function library) that dispatch operators like multiply across numbers, BigNumbers, complex numbers, fractions, and units, and dependency injection, where higher-level functions such as prod are generated by wiring together the specific lower-level function implementations they need (e.g. a lightweight number-only multiply versus the full multi-type version). math.create() builds a mathjs instance from a chosen set of factory functions in src/factoriesAny.js or src/factoriesNumber.js, and math.import() lets consumers extend an instance with new functions at runtime, which is also how the expression parser gains access to user-defined functions.

Tech Stack - The library is written in ES modules (plain .js with .js extensions, no bundler-only syntax) and is 98% JavaScript with a small TypeScript definitions layer under types/. It depends on focused single-purpose packages for each numeric type: decimal.js for BigNumbers, complex.js for complex numbers, fraction.js for rational numbers, plus typed-function for the dispatch system and seedrandom/tiny-emitter for supporting utilities. Babel and a custom gulpfile-driven build produce ESM, CommonJS, and browser-bundle outputs into lib/.

Code Quality - The test/unit-tests tree mirrors src/function category-by-category (arithmetic, matrix, probability, etc.), and there are separate suites for TypeScript type definitions (test/typescript-tests), generated tree-shaken entry points (test/generated-code-tests), and Node-specific CLI behavior (test/node-tests). Contribution docs require every new function to include History-tagged source documentation, embedded docs for the website, unit tests, and TypeScript definitions added in multiple places, indicating a disciplined, checklist-driven contribution process backed by ESLint/Prettier via npm run lint/format.

API Design - The top-level API mirrors the built-in Math object for familiarity (round, sqrt, pow), while evaluate() and chain() provide two additional ergonomic entry points for string-based expressions and fluent method chaining respectively. Getting started requires a single npm install mathjs and one import statement, with no configuration; the tradeoff is a large default bundle unless consumers opt into the tree-shakeable factory-function API, which requires more advanced knowledge of the dependency graph.

Used by 14 apps in this directory

PHP
82%
Other

Akaunting

Invoicing Finance

10,149

Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.

View details
98
Repo Health
73
Technical
63
Dependency
Built with
PHP 82%
Blade 13%
Updated 5 days ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,916

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
90
Repo Health
77
Technical
61
Dependency
Built with
TypeScript 97%
Updated 6 days ago
Java
70%
GPL 3.0

DataEase

AI Assistants · Analytics · Data Engineering

24,558

Open-source BI tool with drag-and-drop dashboards, 20+ data source connectors, and AI-powered natural language queries — a self-hosted alternative to Tableau.

View details
94
Repo Health
71
Technical
65
Dependency
Built with
Java 70%
Vue 29%
Updated 4 days ago
Vue
50%
GPL 3.0

IT-Tools

Developer Tools

40,702

A unified collection of 88 web-based developer utilities — from JSON formatting to subnet calculation — all self-hostable, keyboard-searchable, and offline-ready.

View details
61
Repo Health
74
Technical
63
Dependency
Built with
Vue 50%
TypeScript 48%
Updated 5 days ago
TypeScript
82%
MIT

LibreChat

AI Assistants · Developer Tools

45,009

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 82%
JavaScript 17%
Updated 4 days ago
TypeScript
99%
Other

LobeHub

AI Assistants · Automation · Productivity

82,864

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
TypeScript 99%
Updated 4 days ago
JavaScript
55%
Other

Lokus

Knowledge Management · Note Taking

802

Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.

View details
78
Repo Health
75
Technical
65
Dependency
Built with
JavaScript 55%
HTML 21%
Rust 12%
Updated 1 months ago
TypeScript
80%
AGPL 3.0

massCode

Code Editors · Developer Tools · Productivity

7,003

A free, local-first developer workspace unifying snippets, notes, HTTP requests, calculations, drawings, and dev tools in one desktop app.

View details
87
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 80%
Vue 19%
Updated 5 days ago
PHP
78%
GPL 3.0

matomo

Analytics

21,905

Open-source, privacy-first web and app analytics that puts you in complete control of your data.

View details
95
Repo Health
82
Technical
62
Dependency
Built with
PHP 78%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers