Scientific Expression Calculator
Type a full math expression — parentheses, powers, roots, trig, logs, factorials, and constants — and get the answer instantly, with a reusable history of past calculations.
Interactive Client Prototype Sandbox
Disclaimer: This free tool is provided “as is,” without warranties of any kind, and is for general informational purposes only — not professional, legal, financial, medical, tax, or engineering advice. Results may contain errors; verify anything important independently and use at your own risk. We accept no liability for any loss or damage arising from its use. See our Terms of Use for details.
Step-by-Step Guide
Type a full mathematical expression in the input field and press Enter or click the evaluate button. You can use standard arithmetic operators (+, −, ×, ÷, ^), parentheses for grouping, the % operator for modulo, and the ! postfix for factorial (e.g. 5!). Mathematical functions are written in the form name(argument): sin(45), cos(pi/3), tan(30), sqrt(144), ln(e), log(100), abs(-7), round(3.7), floor(3.9), ceil(3.1). The constants pi and e are available. Toggle DEG/RAD to control whether trigonometric functions interpret angles in degrees or radians.
Using the history and the 'ans' token
Every expression you evaluate is added to a scrollable history list at the bottom. Click any past expression to copy it back to the input field. Type 'ans' in any expression to reference the result of the most recent calculation — for example, after computing 36, entering 'sqrt(ans)' returns 6. This makes it easy to chain calculations without retyping intermediate results.
Why this is safer than eval()
Many web calculators use JavaScript's eval() to evaluate expressions, which is dangerous: a user could type 'fetch("https://...")(...)' and execute arbitrary network requests. This calculator uses a custom parsing engine that recognizes only mathematical operators, functions, and constants — arbitrary JavaScript cannot be injected.
(3 + 4)^2 / sqrt(2): the numerator is 7^2 = 49, divided by √2 ≈ 1.41421, giving ≈ 34.6482. sin(30) in DEG mode returns exactly 0.5 (sin 30° = 1/2). 10! (10 factorial) returns 3,628,800. log(1000) returns 3 (log base 10).
Who it's for
Students, engineers, developers, and anyone needing more than a chat box can compute.
Core Features
- Evaluates +, −, ×, ÷, ^, % and postfix factorial with correct operator precedence.
- Functions (sin, cos, tan, ln, log, sqrt, abs, round…) and constants (pi, e), with degree/radian toggle.
- Scrollable history — click any past entry to reuse it; an 'ans' token reuses the last result.
- Runs on a safe in-house parser — never uses JavaScript eval().
🛡️ No tracking — your inputs, keys, and details never leave this client sandbox.
What operators and functions are supported?
Arithmetic: +, −, *, /, ^ (power), % (modulo), ! (factorial). Functions: sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, sqrt, cbrt, ln (natural log), log (base 10), log2, abs, round, floor, ceil, sign. Constants: pi (π ≈ 3.14159) and e (Euler's number ≈ 2.71828). The DEG/RAD toggle affects sin, cos, tan, asin, acos, and atan — all other functions are unaffected.
Why does sin(90) return 1 but sin(pi/2) return 1 also?
In DEG mode, the calculator converts degrees to radians before calling the trig function: sin(90°) = sin(90 × π/180) = sin(π/2) = 1. In RAD mode, the argument is used directly: sin(pi/2) = sin(1.5708) ≈ 1. Both return 1 because 90° and π/2 radians represent the same angle. Make sure you are in the correct mode for your inputs — mixing degrees and radians is a common source of errors.
What is the difference between log and ln?
ln is the natural logarithm — log base e (Euler's number, ≈ 2.71828). ln(e) = 1, ln(1) = 0. log in this calculator is log base 10 — log(10) = 1, log(100) = 2, log(1000) = 3. In many mathematical contexts 'log' without a base specified means the natural logarithm; in engineering and everyday contexts it often means base 10. This calculator uses the engineering convention: log = base 10, ln = natural.
What is operator precedence?
Operator precedence determines the order of operations. This calculator follows standard mathematical precedence: factorial and functions first, then exponentiation (right-to-left), then unary minus, then multiplication and division (left-to-right), then addition and subtraction (left-to-right). Parentheses always override precedence. So 2 + 3 × 4 = 14 (not 20), and (2 + 3) × 4 = 20.
A real scenario: the expression that breaks every other calculator
You need to evaluate (3 + 4)^2 / sqrt(2) — the square of a sum divided by a square root. A standard phone calculator requires five button sequences, remembering intermediate results, and careful entry order. A search engine returns the wrong answer if you type it as-is because it interprets '^' differently. A chat box gives you a number but no visible intermediate steps. Typing it into a spreadsheet requires a cell formula with SQRT() and careful parenthesization. A dedicated expression parser accepts the expression exactly as you wrote it and returns the correct result (≈34.65) immediately, without coercing you into an interface designed for something else.
How expression parsing works
Evaluating a typed expression like '3 + 4 × 2' correctly — giving 11, not 14 — requires respecting operator precedence without relying on JavaScript's eval(), which would execute arbitrary code. This tool uses a parser based on Dijkstra's shunting-yard algorithm (1961), which processes operators in precedence order using two stacks. The infix expression is converted to Reverse Polish Notation (postfix), where '3 4 2 × +' is unambiguous: multiply 4 and 2 first, then add 3. Postfix evaluation is a simple stack operation with no precedence ambiguity. Functions like sin() and sqrt() are treated as high-precedence prefix operators.
The degrees vs. radians problem
The single most common error in scientific calculator use is mixing angle units. In DEG mode, sin(90) returns 1. In RAD mode, sin(90) returns approximately 0.894 — because 90 radians is nearly 14.3 full revolutions, not the quarter-circle that 90 degrees represents. The conversion is radians = degrees × π/180. The DEG/RAD toggle in this tool applies to sin, cos, tan, asin, acos, and atan; all other functions (sqrt, log, ln, etc.) are unaffected.
What this tool cannot do
This calculator evaluates expressions to a single numerical result. It does not perform symbolic algebra — it cannot simplify 'x^2 + 2x + 1' to '(x+1)^2', solve for unknowns, or differentiate/integrate expressions. It does not support variables (other than the 'ans' token referencing the last result) or user-defined functions. For those capabilities, a computer algebra system like Wolfram Alpha or a dedicated CAS tool is the right instrument.