math.js

2026-03-06

math.js

Math.js is an extensive math library for JavaScript and Node.js

Demonstration - Basic

This code example shows functions and constants, expressions and chained operations.

NotationValue
math.round(math.e, 3)
math.atan2(3, -3)
math.log(10000, 10)
math.sqrt(-4)
math.pow([[-1, 2], [3, 1]], 2)
math.derivative('x^2 + x', 'x')
math.evaluate('12 / (2.3 + 0.7)')
math.evaluate('12.7 cm to inch')
math.evaluate('9 / 3 + 2i')
math.evaluate('det([-1, 2; 3, 1])')
math.chain(3).add(4).multiply(2).done()

Demonstration - Angle configuration

This code example extends the trigonometric functions of math.js with configurable angles: degrees, radians, or gradians.

Angles
Expression
Result