Expression Solver

Evaluate a mathematical expression.

About the Expression Solver

Type any mathematical expression and see it evaluated, including functions and nested parentheses.

How to use it

  1. Type the expression.
  2. Use sqrt(), sin(), cos(), tan(), log() as needed.
  3. Powers use **.

The formula

An expression solver evaluates in the order mathematics agrees on, not the order you typed. That order is usually taught as PEMDAS or BODMAS.

Parentheses → Exponents → Multiplication and Division → Addition and Subtraction

The critical detail is that the last two lines are pairs, not four separate ranks. Multiplication and division share a level and are evaluated left to right; so do addition and subtraction. This is why 8 ÷ 2 × 4 is 16 and not 1 — you work left to right, rather than doing all multiplication before any division.

Powers use ** here, so 2**10 is 1024. Functions such as sqrt(), sin(), cos(), tan() and log() take their argument in brackets, and those brackets count as parentheses for ordering purposes.

Worked examples

ExpressionEvaluated asResult
(5+3)*sqrt(16)/28 × 4 ÷ 216
8/2*4(8 ÷ 2) × 4, left to right16
2+3*4**22 + (3 × 16)50
(2+3)*4**25 × 1680

The last two rows differ by one pair of brackets and by 30. Exponents bind tighter than multiplication, which binds tighter than addition — so 3*4**2 squares the 4 first, never the 12. When an expression is long enough that you have to think about this, add the brackets. They cost nothing and they remove the ambiguity permanently.

Common mistakes

Terms explained

Operator precedence
The rules deciding which operation happens first. PEMDAS and BODMAS are two names for the same order.
Operand
A value an operator acts on. In 3 + 4, both numbers are operands.
Left associativity
Operators of equal precedence evaluating left to right. Applies to the two mixed pairs, and is why 8/2*4 is unambiguous once you know the rule.
Exponent
A power, written ** here. 2**10 is 1024.
Nested parentheses
Brackets inside brackets. The innermost pair is always resolved first.
Radian
The angle unit these trigonometric functions expect. π radians is 180°.

Common questions

What order are operations evaluated in?
Parentheses, then exponents, then multiplication and division together left to right, then addition and subtraction together left to right.
Why is 8/2*4 equal to 16 and not 1?
Because multiplication and division share a precedence level and are worked left to right. The division happens first because it comes first, giving 4 × 4.
How do I raise a number to a power?
Use **, as in 2**10 for 1024. The caret is not accepted here, since in several languages it means something else entirely.
Are trigonometric functions in degrees or radians?
Radians. To work in degrees, convert first by multiplying by π and dividing by 180 — sin(30 * 3.14159 / 180) gives 0.5.
What functions can I use?
sqrt(), sin(), cos(), tan() and log(), each taking its argument in brackets. Combine them freely with the usual operators.
What does log() do here?
Natural logarithm, base e, as in most programming environments. For base 10, divide by log(10).
Why did my expression return an error?
Most often unbalanced brackets or an omitted multiplication sign. Count your brackets, and check for anything written as 2(3+4) rather than 2*(3+4).
Does PEMDAS differ from BODMAS?
Only in wording. Brackets and parentheses are the same thing, and orders and exponents are the same thing. The evaluation order is identical.

Related calculators

← All 51 calculators