Expression calculator
Evaluate an arithmetic expression exactly, with functions like sqrt, ln, sin and factorial.
- Version 1
- Checked against 4 published values
- Free, no sign-up
Result: Exact fractions
| Result The value of the expression. |
512 exact |
|---|---|
| Interpretation The expression as parsed, with explicit parentheses. |
((1 / 3) + (1 / 6)) * (2 ^ 10) |
Rounding: Half even, 20 significant digits. Calculator math/expression@1.
How it is calculated
Standard operator precedence: ^ (right-associative) > unary minus > * / > + -Evaluates expressions such as (1/3 + 1/6) * 2^10 or sqrt(2) * sin(45) with no floating-point error: rational arithmetic is exact, and irrational results (roots, logarithms, trig) are computed with certified interval arithmetic and rounded correctly. The interpretation output shows how the expression was read, with every implied parenthesis written out.
- Implicit multiplication (2pi, 3(4)) is not accepted; write 2*pi.
- log(x) alone is ambiguous between ln and log10, so it needs a base: log(x, 10).
- Results must be below 1e100 in magnitude; smaller than 1e-100 is reported as 0.
References
- Order of operations
- A. Ziv, Fast evaluation of elementary mathematical functions with correctly rounded last bit, ACM TOMS 17(3), 1991 (rounding with growing precision)
Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.
Use it from your code
curl https://api.curatedapi.com/v1/calc/math/expression \
-H "Authorization: Bearer $CURATEDAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"expression": "(1/3 + 1/6) * 2^10"
}'
The same call in Python
import os
import requests
payload = {
"expression": "(1/3 + 1/6) * 2^10",
}
response = requests.post(
"https://api.curatedapi.com/v1/calc/math/expression",
headers={"Authorization": f"Bearer {os.environ['CURATEDAPI_KEY']}"},
json=payload,
timeout=10,
)
print(response.json()["result"])
The same call in JavaScript
const payload = {
"expression": "(1/3 + 1/6) * 2^10",
};
const response = await fetch("https://api.curatedapi.com/v1/calc/math/expression", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CURATEDAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
console.log((await response.json()).result);
MCP tool calc_math_expression at https://mcp.curatedapi.com.
Inputs, outputs and errors in the API reference.
Put it on your website
<div data-curatedapi-widget="math/expression" data-key="capi_public_…"></div>
<script src="https://widgets.curatedapi.com/v1/widget.js" async></script>
Use a public key registered for your site. Calculations are billed like API calls. How widgets work.
Related calculators
- Fraction calculator
- Percentage calculator
- Rounding calculator
- Scientific calculator
- Statistics calculator
Add this calculator to your website
Paste two lines into your page and your visitors get this calculator. Each use counts as one call on your plan, the same as the API.
Free for up to 1,000 uses a month. 50,000 uses a month cost $9.00 on the Starter plan.