Scientific Calculator
A full scientific calculator. Type an expression or use the keypad — trigonometry, logarithms, powers, roots, factorials and memory are all supported.
How to use the Scientific Calculator
- 1Type an expression such as 2 * (3 + 4)^2 and press Enter, or use the keypad.
- 2Switch between degrees and radians for trigonometric functions.
- 3Use the memory keys to store and recall a running value.
- 4Click any line in the history to bring it back into the input.
How it works
The expression is parsed properly rather than evaluated as code. It is tokenised into numbers, operators and function names, converted to postfix notation with the shunting-yard algorithm — which handles operator precedence and right-associative powers correctly — and then evaluated from that stack.
That matters for safety as much as correctness. Passing user input to eval() would let arbitrary JavaScript run in the page; a dedicated parser can only ever produce a number or a clear error message.
Invalid input is reported precisely: unbalanced parentheses, an unknown function name, a missing operand, or a mathematically undefined result such as the logarithm of a negative number each get their own message rather than a generic failure.
Worked example
Evaluating a compound expression
- Type sin(30) with the mode set to degrees → 0.5
- Type 2^10 → 1024
- Type log(1000) + sqrt(144) → 3 + 12
Result: 15. Each result is added to the history, and can be clicked to reuse.