| CARVIEW |
Select Language
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Wed, 05 Nov 2025 13:32:25 GMT
access-control-allow-origin: *
etag: W/"690b51e9-2efd"
expires: Mon, 29 Dec 2025 12:14:45 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 3352:1F53DD:8C3111:9D6799:69526E5D
accept-ranges: bytes
age: 0
date: Mon, 29 Dec 2025 12:35:13 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210028-BOM
x-cache: HIT
x-cache-hits: 0
x-timer: S1767011713.221754,VS0,VE201
vary: Accept-Encoding
x-fastly-request-id: 88a2aa602b8268181be64b420ee6d3a08c1bbfb6
content-length: 3673
math.js | an extensive math library for JavaScript and Node.js
An extensive math library for JavaScript and Node.js #
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices. Powerful and easy to use.
Features #
- Supports numbers, big numbers, bigint, complex numbers, fractions, units, strings, arrays, and matrices.
- Is compatible with JavaScript’s built-in Math library.
- Contains a flexible expression parser.
- Does symbolic computation.
- Comes with a large set of built-in functions and constants.
- Can be used as a command line application as well.
- Runs on any JavaScript engine.
- Is easily extensible.
- Open source.
Example #
Here some example code demonstrating how to use the library. Click here to fiddle around.
// functions and constants
math.round(math.e, 3) // 2.718
math.atan2(3, -3) / math.pi // 0.75
math.log(10000, 10) // 4
math.sqrt(-4) // 2i
math.derivative('x^2 + x', 'x') // 2*x+1
math.pow([[-1, 2], [3, 1]], 2)
// [[7, 0], [0, 7]]
// expressions
math.evaluate('1.2 * (2 + 4.5)') // 7.8
math.evaluate('12.7 cm to inch') // 5 inch
math.evaluate('sin(45 deg) ^ 2') // 0.5
math.evaluate('9 / 3 + 2i') // 3 + 2i
math.evaluate('det([-1, 2; 3, 1])') // -7
// chaining
math.chain(3)
.add(4)
.multiply(2)
.done() // 14
Demo #
Try the expression parser below.
See Math Notepad for a full application.
loading...
Shortcut keys:
- Press S to set focus to the input field
- Press Ctrl+F11 to toggle full screen
- Press Tab to autocomplete (repeat to cycle choices)
- Enter "clear" to clear history