1001Ferramentas
🧮 Calculators

Math Expression Evaluator

Calculate math expressions as you type — sum, subtraction, multiplication, division, powers, square root, log, sin, cos, tan and parentheses. Shows the result. Everything in your browser.

Resultado
Funções: sin, cos, tan, asin, acos, atan, log, ln, exp, sqrt, abs, floor, ceil, round, min, max — Constantes: pi, e

Math Expression Evaluator

A math expression evaluator takes a string like 2 + 3 * sin(pi/4) and gives back a number. Behind the scenes it tokenizes the input and turns the infix notation into a syntax tree, usually with the Shunting-yard algorithm (Dijkstra, 1961) or a recursive-descent parser. The precedence is fixed. Parentheses come first, then the exponent ^, then * /, and finally + −. Exponentiation is right-associative, so 2^3^2 = 2^9 = 512 rather than 64. Functions (sin, cos, log, sqrt) and constants (π, e) are all handled. The variant you find in HP calculators is Reverse Polish Notation (RPN/postfix).

Applications and context

Expression evaluators sit under a lot of everyday software. They run the formulas in spreadsheets (Excel, Google Sheets), the math in computer algebra systems (Wolfram Alpha, SymPy, GeoGebra), the designer-written formulas inside game engines, and plenty of scientific automation. One security note: don't reach for raw eval() in JavaScript, because it will run arbitrary code. A dedicated parser like math.js or mathexpr keeps the evaluation sandboxed.

FAQ

Does it work in radians or degrees? The trig functions default to radians (π/2 = 90°). To feed in degrees, multiply by pi/180 first.

Why does 0.1 + 0.2 not equal 0.3? Floating-point arithmetic (IEEE 754) has no exact way to store 0.1, so the sum comes out as 0.30000000000000004. That's a built-in limitation of the format, not a bug in the tool.

Can I use variables? This tool only evaluates plain expressions. If you need variables and assignments, turn to a full CAS such as SymPy or math.js with scope support.

Related Tools

Calculate math expressions by typing

There are moments when you don't want to keep pressing a calculator button by button. You want to write the whole calculation and see the result. This evaluator reads math expressions written out and respects the order of operations and the parentheses, exactly the way you'd do it on paper.

It doesn't stop at the four operations: it takes powers, roots, logarithms and trigonometric functions (sin, cos, tan), which helps with more elaborate calculations in maths, physics or engineering. And it doesn't show only the answer. The step by step comes along with it, so you can check and understand how the expression was evaluated.

The calculation runs in the browser. Type the full expression and the answer appears. It's a calculator that speaks your language, without you hunting around for keys.