Expression Evaluator
Evaluate a math expression with units, functions, constants and small matrices in a restricted mathjs sandbox. Type something like 5 cm + 2 inch to mm, 60 km/h to m/s or det([[1, 2], [3, 4]]) and get the result rounded to your chosen precision. Expressions cannot define variables or functions or reach anything outside the math library, so it is safe for any input. Handy for unit conversions, engineering checks and quick calculations.
Frequently asked questions
What can I type?
Numbers, the operators + - * / ^ and %, mod, factorial(n), parentheses, units such as cm, kg, km/h or degC, the constants pi, e, tau, phi and i, and functions such as sqrt, sin, log, round, mean or det. Implicit multiplication works, so 2 pi and 3 kg are understood. The input can be up to 2000 characters.
How do unit conversions work?
Attach units to numbers and use to or in to convert, as in 3 ft to m or 100 degF to degC. Units combine through arithmetic, so 1 kg * 9.81 m/s^2 gives 9.81 N and 2 cm * 3 cm gives 6 cm^2. Adding incompatible units, such as kg and m, returns an error.
Can I work with matrices and vectors?
Yes, write them with brackets, for example [1, 2, 3] or [[1, 2], [3, 4]], with up to 10 items per row and two levels of nesting. Functions such as det, inv, transpose, trace, dot, cross and norm are available, and element-wise operators such as .* work. Matrix results are shown as an aligned block.
Which features are disabled for safety?
Variables, assignments, function definitions, strings, objects, ranges, indexing and property access are rejected before evaluation. Following the mathjs security guidance, import, createUnit, evaluate, parse, simplify and derivative are disabled, and only an allowlist of math functions can be called. Nothing in the expression can reach JavaScript or the server.
Are trigonometric functions in degrees or radians?
Plain numbers are radians, so sin(pi / 2) is 1. Add the deg unit to work in degrees, as in sin(30 deg) or cos(45 deg). The Scientific Calculator offers a degree mode that treats plain numbers as degrees.
What does the percent sign do?
A percent sign after a number divides it by 100, so 50% is 0.5 and 200 * 15% is 30. After a plus or minus it is taken relative to the left side, so 100 + 10% is 110. Between two numbers, as in 10 % 3, it is the modulo operator and returns the remainder 1. You can also write 10 mod 3.
How are results rounded?
Numbers, unit values and complex parts are rounded to the decimal places you choose, 6 by default and up to 15, with trailing zeros removed. Values too small to show at that precision appear in scientific notation. Division by zero returns Infinity and 0 / 0 is reported as undefined.
Can I enter several expressions at once?
No, the tool evaluates one expression per calculation, and semicolons or extra lines are rejected. Combine the parts with arithmetic or run them one after another. This keeps every result clearly tied to its expression.
Is there a time limit?
Each evaluation runs in an isolated worker with a 3 second time limit, besides the caps on length, nesting depth and matrix size. Combinations and permutations are limited to n up to 10,000. An expression that hits a limit gets a clear message instead of slowing the page.
Does it support complex numbers?
Yes, use i for the imaginary unit, as in (2 + 3i) * (1 - i), and functions such as sqrt(-4) return complex results like 2i. re, im, arg and conj extract parts of a complex result. Results are shown as a + bi.