Skip to content

Math Expression Evaluator

Evaluate arbitrary math expressions with variables, functions, and operator precedence. Multi-line support.

Math Expression Evaluator tool

Loading...

Example

Input: (3 + 5) * 2^3 / 4

Result: 16

Parentheses first (3 + 5 = 8), then the exponent (2^3 = 8), then left to right: 8 * 8 = 64 and 64 / 4 = 16.

Example Expressions and Results

ExpressionResult
2 + 3 * 414
(2 + 3) * 420
2 ^ 3 ^ 2512
-2 ^ 2-4
10 / 42.5
7 % 31
5!120
sqrt(-4)2i
sin(pi / 6)0.5
sin(30 deg)0.5
log(100, 10)2
log(e)1
0.1 + 0.20.3
nthRoot(27, 3)3

Results from this evaluator. Note that log(x) is the natural log.

  1. Type a math expression using standard operators (+, -, *, /, ^, %) and functions (sin, cos, sqrt, etc.).
  2. Define variables by typing assignments like x = 5, then use them in expressions.
  3. Enter multiple expressions on separate lines to evaluate them all at once.
  4. Click Evaluate or press Ctrl+Enter (Cmd+Enter on Mac) to compute the results.
  5. View the result for each line displayed alongside the expression.
  6. Click the copy button to copy any result.

Typing Math Expressions: Rules and Tips

This evaluator works out math expressions that you type, following the normal order of operations. Enter (3 + 5) * 2^3 / 4 and it returns 16. You can put several expressions on separate lines, store values in variables, and use functions such as sqrt, sin, log and factorial.

Variables let you build a calculation in steps. Type r = 3 on one line and area = pi * r^2 on the next, and the second line returns 28.274333882308. Variables stay available for later evaluations until you press Clear All. Each line gets its own result, and a typo on one line shows an error there without stopping the rest. Press Evaluate or Ctrl+Enter (Cmd+Enter on a Mac) to run everything. New results appear at the top of the list.

A few rules catch people out. Trig functions use radians, so sin(30) is the sine of 30 radians. Write sin(30 deg) or sin(pi / 6) to get 0.5. On its own, log(x) is the natural log. Use log10(x) or log(x, 10) for base 10. Powers group from the right, so 2^3^2 is 2^9 = 512. The minus sign in -2^2 applies after the power, which gives -4. Results are rounded to 14 significant digits. That hides floating point noise, so 0.1 + 0.2 shows 0.3. Some inputs return special results. The square root of a negative number comes back as a complex number, so sqrt(-4) is 2i.

The evaluator is built on mathjs, a widely used open-source math library. For equations of the form ax^2 + bx + c = 0, the Quadratic Equation Solver gives roots and a graph. For logs in any base, the Logarithm Calculator lists them side by side.

Frequently Asked Questions

You can use + - * / ^ and % (modulo), plus ! for factorials. Functions include sqrt, nthRoot, abs, round, floor, ceil, sin, cos, tan and their inverses, log, log2 and log10. The constants pi and e are built in. Click any example expression under the input to add it and see the syntax.
Assign a value with an equals sign, such as x = 5, on its own line. Any later line can use x, such as x * 3. Variables carry over to later evaluations too, so you can keep building on them. Clear All wipes the input, the results and every stored variable.
Trig functions work in radians by default, and sin(30) is the sine of 30 radians, about -0.988. For degrees, add the unit: sin(30 deg) returns 0.5. You can also convert yourself, since 30 degrees is pi / 6 radians.
Powers are worked out before the minus sign in front, so -2^2 means -(2^2) = -4. Write (-2)^2 to square negative 2 and get 4. This matches the standard order of operations used in math books and most calculators.
Yes, basic unit math works because the evaluator is built on mathjs. Type 12 cm to inch and it returns 4.7244094488189 inch. You can also mix units in a sum, such as 1 m + 20 cm. For everyday conversions with every unit listed at once, a dedicated converter is quicker.

Related Tools

Percentage Calculator

Calculate percentages, percentage change, difference, increase, and decrease instantly.

Math and Numbers

Logarithm Calculator

Calculate logarithms with any base including natural log (ln), log base 10, and log base 2.

Math and Numbers

Exponent and Power Calculator

Calculate powers, exponents, and exponential expressions with support for any base and exponent.

Math and Numbers

Number Base Converter

Convert numbers between binary, octal, decimal, hexadecimal, and any custom base.

Math and Numbers

Quadratic Equation Solver

Solve ax^2 + bx + c = 0. Shows discriminant, real or complex roots, vertex, and parabola graph.

Math and Numbers