Math Expression Evaluator
Evaluate arbitrary math expressions with variables, functions, and operator precedence. Multi-line support.
Math Expression Evaluator tool
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
| Expression | Result |
|---|---|
| 2 + 3 * 4 | 14 |
| (2 + 3) * 4 | 20 |
| 2 ^ 3 ^ 2 | 512 |
| -2 ^ 2 | -4 |
| 10 / 4 | 2.5 |
| 7 % 3 | 1 |
| 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.2 | 0.3 |
| nthRoot(27, 3) | 3 |
Results from this evaluator. Note that log(x) is the natural log.
- Type a math expression using standard operators (+, -, *, /, ^, %) and functions (sin, cos, sqrt, etc.).
- Define variables by typing assignments like x = 5, then use them in expressions.
- Enter multiple expressions on separate lines to evaluate them all at once.
- Click Evaluate or press Ctrl+Enter (Cmd+Enter on Mac) to compute the results.
- View the result for each line displayed alongside the expression.
- 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
Related Tools
Percentage Calculator
Calculate percentages, percentage change, difference, increase, and decrease instantly.
Math and NumbersLogarithm Calculator
Calculate logarithms with any base including natural log (ln), log base 10, and log base 2.
Math and NumbersExponent and Power Calculator
Calculate powers, exponents, and exponential expressions with support for any base and exponent.
Math and Numbers