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
- Type the expression.
- Use sqrt(), sin(), cos(), tan(), log() as needed.
- 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
| Expression | Evaluated as | Result |
|---|---|---|
| (5+3)*sqrt(16)/2 | 8 × 4 ÷ 2 | 16 |
| 8/2*4 | (8 ÷ 2) × 4, left to right | 16 |
| 2+3*4**2 | 2 + (3 × 16) | 50 |
| (2+3)*4**2 | 5 × 16 | 80 |
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
- Believing multiplication always precedes division. They share a precedence level and run left to right. 8 ÷ 2 × 4 is 16. The M coming before the D in PEMDAS is an accident of the mnemonic, not a rule.
- Omitting the multiplication sign. 2(3+4) is standard on paper and not accepted by most parsers. Write 2*(3+4) explicitly.
- Assuming the calculator works in degrees. Trigonometric functions here take radians, as in most programming languages. For degrees, multiply by π and divide by 180 first.
- Unbalanced brackets. Every opening bracket needs a closing one. A long expression that errors is usually missing exactly one at the end — count them before rewriting anything.
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.