Math Expression Calculator — evaluate any formula online
Enter a mathematical expression using +, -, *, /, ^, %, parentheses, and functions like sqrt, sin, cos, log. Results appear instantly as you type. No external libraries — the parser runs entirely in your browser with no data sent to a server.
How it works
Supported operations and functions
The calculator handles the four basic arithmetic operators (+, -, *, /) plus exponentiation (^) and modulo (%). You can nest parentheses to any depth.
Built-in functions cover the most common mathematical needs: sqrt(x) and cbrt(x) for square and cube roots; abs(x) for absolute value; sin(x), cos(x), tan(x) for trigonometry in degrees; log(x) for the natural logarithm, log2(x) and log10(x) for base-2 and base-10 logarithms; and floor(x), ceil(x), round(x) for rounding. The constants pi and e are available by name.
Practical uses for expression evaluation
Quick calculation chains are where expression evaluators shine. Instead of punching numbers into a phone calculator one step at a time — and possibly forgetting an intermediate result — you can type the whole chain as a single expression and see the answer at once.
Engineering and science tasks such as unit conversions, stress calculations, or statistical formulas often require combinations of square roots, powers, and logarithms. Typing the full formula here gives you a traceable record of what you computed, unlike a sequence of button presses on a physical calculator.
Order of operations
The parser follows standard mathematical precedence: parentheses first, then exponentiation (right-associative), then multiplication/division/modulo (left-to-right), then addition and subtraction (left-to-right). This matches the BODMAS/PEMDAS rules taught in school.
Unary minus is supported (e.g., -3^2 evaluates as -(3^2) = -9, which matches conventional mathematical notation). If you need (-3)^2 = 9, add explicit parentheses. When in doubt, use parentheses liberally — they never hurt readability.
Frequently asked questions
›Why are trig functions in degrees rather than radians?
Degrees are more intuitive for everyday use — most people think of angles as 0 to 360, not 0 to 2π. The parser converts internally, so sin(90) = 1 as expected. If you need radians, multiply by pi/180: sin(1.5708) gives the same result as sin(90).
›What is the difference between log and log10?
log(x) computes the natural logarithm (base e ≈ 2.718). log10(x) uses base 10, which is what most people mean when they write 'log' in a non-calculus context. log2(x) uses base 2, common in information theory and computer science.
›Does ^ mean exponentiation or XOR?
In this calculator ^ always means exponentiation (power), not bitwise XOR. So 2^10 = 1024. For bitwise operations you would need a different tool.
›Can I use spaces in expressions?
Yes. Spaces are ignored by the parser, so '2 ^ 10 + sqrt( 16 )' is equivalent to '2^10+sqrt(16)'. Add spaces wherever they improve readability.
›What happens if I divide by zero?
The calculator catches division by zero and displays an error message rather than showing Infinity or NaN. Fix the expression and try again.
›How many decimal places does the result show?
Up to 10 significant decimal places, formatted with your locale's number style. Very small floating-point rounding errors (like 0.9999999999 instead of 1) are a normal consequence of binary floating-point arithmetic.
›Is this safer than using eval() in JavaScript?
Yes. This tool uses a hand-written recursive descent parser that only recognises the listed operators and functions. It never calls eval() or any equivalent, so arbitrary code cannot be injected or executed.
›Does my expression leave my browser?
No. The parser runs entirely in your browser. Nothing you type is sent to a server or logged anywhere.
Related tools
Last updated: