Scientific Calculator
Safe expression evaluator with trigonometry, logarithms, and constants.
About the Scientific Calculator
The scientific calculator evaluates mathematical expressions containing trigonometric, logarithmic, exponential, and root functions alongside the standard arithmetic operators. Unlike a button-driven calculator that builds the expression one keystroke at a time, this tool accepts a free-text expression so you can write the whole calculation the way you would on paper, then evaluate it in a single step.
The evaluator supports the functions you would expect from any scientific environment: sin, cos, tan and their inverse counterparts asin, acos, atan, sqrt and cbrt for roots, ln for natural logarithm, log for base-10 logarithm, exp for e to a power, plus the constants pi and e. The caret symbol ^ is interpreted as exponentiation, matching the convention used by most spreadsheets and graphing calculators. Per ECMA-262 §21, the underlying Math object provides these as native functions, all of which return IEEE 754 doubles.
Security is a primary design consideration. The input is restricted to a strict whitelist of characters before evaluation, and the expression is compiled using a sandboxed Function constructor rather than the global eval. Per ECMA-262 §20.3, Function creates a new function with only the global scope in its outer environment record, which is cleaner than eval running in the local scope. Everything runs locally in your browser; no expression is sent over the network.
How It Works
The calculator performs three passes on your input. First, whitespace is removed and the character set is validated against a whitelist containing digits, the operators + - * / % ^, parentheses, and the lowercase letters used by function names. Any character outside this set causes an immediate error.
Second, syntactic substitutions convert the human-friendly notation into JavaScript notation:
^ -> ** (exponentiation, ECMA-262 §13.5.1)
pi -> (Math.PI) (3.141592653589793)
e -> (Math.E) (2.718281828459045)
sin( -> Math.sin( cos( -> Math.cos( tan( -> Math.tan(
asin( -> Math.asin( acos -> Math.acos( atan -> Math.atan(
sqrt( -> Math.sqrt( cbrt -> Math.cbrt( abs -> Math.abs(
floor( -> Math.floor( ceil -> Math.ceil( round -> Math.round(
log( -> Math.log10( (base-10 logarithm)
ln( -> Math.log( (natural logarithm)
exp( -> Math.exp( (e raised to a power)
Third, the transformed expression is evaluated using a function constructor: Function('return (' + expr + ')'). The result is checked for NaN and Infinity before being displayed, so you never see a misleading output from a malformed expression such as ln(-1) or 1/0.
Trigonometric functions operate in radians, the standard mathematical convention documented by NIST in the Digital Library of Mathematical Functions (DLMF §4.4). To work in degrees, convert manually with sin(deg * pi / 180) or pre-multiply by pi/180. The order of operations follows standard precedence: parentheses, then exponents, then multiplication and division, then addition and subtraction.
Worked Examples
Consider the default expression sin(45) + sqrt(144) - 2^5. The evaluator processes it as follows: sin(45) in radians equals approximately 0.8509035, sqrt(144) equals 12, and 2^5 equals 32. The result is 0.8509 + 12 - 32 = -19.149, displayed with six decimal places of precision.
If you meant degrees rather than radians, rewrite the expression as sin(45 * pi / 180) + sqrt(144) - 2^5. Now sin(45 degrees) equals 0.7071068 (exactly sqrt(2)/2), giving a final result of 0.7071 + 12 - 32 = -19.293. This illustrates why the radians-versus-degrees distinction matters.
For a compound growth calculation, enter 1000 * (1.05)^10 to find the value of $1,000 invested at 5% annual growth for ten years. The caret is correctly interpreted as exponentiation, and the result 1628.8946 confirms the compound interest formula A = P(1+r)^n. For continuous compounding, use 1000 * exp(0.05 * 10) instead, which yields 1648.7213 — the difference between discrete and continuous growth.
When to Use This Tool
Use the scientific calculator when you need to:
- Evaluate trigonometric expressions for engineering, physics, or geometry problems.
- Compute logarithms and exponentials in finance, biology, or signal processing.
- Check intermediate steps of a longer calculation without losing your place.
- Convert between radians and degrees by combining the constants and functions.
- Verify results produced by a graphing calculator or spreadsheet formula.
- Teach the order of operations and function composition in a classroom.
- Prototype a formula before coding it into a program or spreadsheet.
Limitations & Disclaimer
This calculator evaluates a single expression at a time and does not support variable assignment, multi-step programs, symbolic algebra, or matrix operations. Trigonometric inputs are in radians. Results are subject to IEEE 754 floating-point precision limits, and very large or very small numbers may lose accuracy. For symbolic or computer algebra tasks, use a dedicated CAS such as SymPy or Mathematica. See our disclaimer for full details.
Frequently Asked Questions
Are the angles in degrees or radians?
All trigonometric functions operate in radians, the standard mathematical convention documented by NIST DLMF section 4.4. To use degrees, multiply the angle by pi/180 inside the function call, for example sin(30 * pi / 180) computes the sine of 30 degrees and returns 0.5.
Why is the caret interpreted as exponentiation?
Because that matches the convention used by most spreadsheets, graphing calculators, and mathematical typesetting. The calculator replaces ^ with ** before evaluation so the JavaScript engine interprets it correctly per ECMA-262 section 13.5.1, which defines ** as the exponentiation operator.
Can I use the natural constant e?
Yes. The letter e is replaced with Math.E, the base of the natural logarithm (approximately 2.718281828459045). Use exp(x) to compute e raised to the power x, or ln(x) to compute the natural logarithm of x.
How does this differ from a physical scientific calculator?
A physical calculator is button-driven and evaluates step by step. This tool accepts a full expression as text, so you can write the entire calculation before evaluating it. This makes it easier to review and edit complex expressions, and you can copy and paste them into documentation.
Is it safe to enter any expression?
The input is restricted to a strict character whitelist before evaluation, and the expression is compiled in a sandboxed function scope rather than the global eval. This prevents injection of arbitrary code, though you should still avoid pasting expressions from untrusted sources.
What happens with division by zero?
JavaScript returns Infinity or NaN for division by zero, which the calculator detects and reports as an evaluation error rather than displaying a misleading result. The same applies to logarithms of non-positive numbers and arcsine of values outside the range -1 to 1.
Last updated: September 9, 2026 · Author: HT99 Tools Editorial Team