Mathematics

Evaluating Expressions with the Scientific Calculator

The scientific calculator parses a whole expression at once, applying standard operator precedence and a fixed set of functions, which is a genuinely different job than doing one operation on two numbers.

A worked example: sqrt(144) + 5 × 2

Enter the expression sqrt(144) + 5 * 2 with the angle unit set to degrees (it does not matter here, since there is no trig function in this expression) and the scientific calculator returns 22. It gets there by respecting operator precedence: sqrt(144) resolves to 12 first, then 5 * 2 resolves to 10, and only then are the two added — 12 + 10 = 22 — rather than evaluating strictly left to right.

The formula: precedence, functions, and right-associative powers

The evaluator tokenizes the expression, then parses it with power (^) binding tighter than multiplication and division, which in turn bind tighter than addition and subtraction, and power itself is right-associative. That last detail is easy to get wrong by hand: 2^10 evaluates as a single power operation and returns 1024, but a three-level tower like 2^3^2 groups as 2^(3^2) — 2 raised to 9 — rather than (2^3)^2, so it returns 512, not 64.

A worked example: sin(90°) and log(100)

With the angle unit set to degrees, entering sin(90) returns 1 — the sine of a right angle. Switching to a different function entirely, entering log(100) (base-10 logarithm) returns 2, since 10 squared is 100. Neither of these — a trigonometric function or a logarithm — is something the two-operand basic math calculator can compute at all; both require the broader function set the scientific calculator supports.

Why expression parsing matters for multi-step calculations

Real calculations are rarely a single operation. The moment a problem needs several operations combined in one line — a square root added to a product, a value raised to a power and then compared against a trig result — an expression evaluator that enforces consistent operator precedence removes the guesswork of doing each step by hand and combining them yourself. Irrational results like sqrt(2), which the scientific calculator returns as 1.4142135623730951, also show why it carries more decimal precision internally (6 significant decimal places displayed) than the basic math calculator needs for exact-decimal arithmetic.