mathjs
Extensive math library for JavaScript and Node.js with big numbers, complex numbers, units, and matrices.
Repository Health
Technical Analysis
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
Akaunting
Invoicing Finance
Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.
Bigcapital
Invoicing Finance
Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.
DataEase
Analytics · Data Engineering · AI Assistants
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.
IT-Tools
Developer Tools
A unified collection of 88 web-based developer utilities — from JSON formatting to subnet calculation — all self-hostable, keyboard-searchable, and offline-ready.
LibreChat
Developer Tools · AI Assistants
Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.
LobeHub
AI Assistants · Productivity · Automation
Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.
Lokus
Note Taking · Knowledge Management
Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.
massCode
Developer Tools · Productivity · Code Editors
A free, local-first developer workspace unifying snippets, notes, HTTP requests, calculations, drawings, and dev tools in one desktop app.
matomo
Analytics
Open-source, privacy-first web and app analytics that puts you in complete control of your data.