How the Scientific Calculator Evaluates Expressions
AnyTool Scientific Calculator parses each expression in the browser with a reusable engine: a tokenizer splits the input into numbers, operators, parentheses, function names and constants; the shunting-yard algorithm reorders those tokens from infix into Reverse Polish Notation so that standard operator precedence and right-associative exponentiation are respected; and a final stack pass computes the result. There is no eval() and no new Function() anywhere — user input is treated strictly as data, so arbitrary code can never run. The same compiled expression can be re-evaluated with a variable map, which is why the engine is shared with graphing and equation-solving tools.
- Tokenizer → shunting-yard → Reverse Polish Notation → stack evaluator
- Honours order of operations and right-associative ^
- No eval() or new Function() — input is parsed, never executed
- Implicit multiplication for forms like 2π, 3(4+1) and (1+2)(3+4)
- Compiled expressions re-evaluate with variables for graphing/solving
