Math & Statistics Calculator API for AI Agents
Pricing
from $2.00 / 1,000 calculation runs
Math & Statistics Calculator API for AI Agents
Exact arithmetic and statistics for AI agents and apps. Evaluate math expressions safely and get count, sum, mean, median, mode, variance and standard deviation for a list of numbers, so your LLM stops guessing the numbers.
Pricing
from $2.00 / 1,000 calculation runs
Rating
0.0
(0)
Developer
Chun-Yung Yong Lo
Maintained by CommunityActor stats
0
Bookmarked
1
Total users
0
Monthly active users
an hour ago
Last modified
Categories
Features
Share
Stop letting your LLM guess numbers. This Actor evaluates math expressions safely and computes basic statistics for a list of numbers, deterministically, in one call. It works as a normal Apify Actor (API, schedules, integrations) and also as an MCP server so AI agents can call it as a tool.
What it does
- Expression evaluation: arithmetic (
+ - * / // % **), parentheses, constants (pi,e,tau) and functions (sqrt,sin,cos,tan,asin,acos,atan,log,log10,log2,exp,floor,ceil,abs,round,min,max,sum,factorial,gcd,radians,degrees,mean,median,stdev,variance). Expressions are parsed into a syntax tree and only a whitelist of numeric operations is executed. Pythonevalis never used. - Statistics: count, sum, mean, median, mode, min, max, range, sample variance and standard deviation, population variance and standard deviation.
- Floating point noise is rounded away (
0.1 + 0.2gives0.3), configurable withdecimals.
Input example
{"expressions": ["(12.5 * 4) + sqrt(144)"],"numbers": [2, 4, 4, 4, 5, 5, 7, 9],"statistics": ["mean", "median", "mode", "pstdev"],"decimals": 10}
Provide expressions, numbers, or both. statistics is optional (default: all).
Output example
[{"type": "expression", "expression": "(12.5 * 4) + sqrt(144)", "result": 62},{"type": "statistics", "mean": 5, "median": 4.5, "mode": [4], "pstdev": 2}]
mode is always a list because a data set can have several modes. variance and stdev are null when fewer than two numbers are given.
Pricing
US$0.002 per run (event: Calculation run), regardless of how many expressions or numbers are in the run.
Limits
- Up to 1000 expressions per run, each up to 1000 characters.
- Up to 100,000 numbers per run.
- Integer bases and exponents in
**are capped at 10,000;factorialaccepts 0-1000; results larger than 1e300 are rejected. - Use
**for powers.^is rejected to avoid silent XOR mistakes. - Only numbers are supported (no strings, variables or complex numbers).
- Invalid input (unknown function, division by zero, non-numeric result) stops the run with a clear error message.
- Results are IEEE double precision, not arbitrary-precision decimals (except integer arithmetic, which is exact).
Credits
This Actor is built on the Python standard library (ast, math and statistics modules), distributed under the Python Software Foundation License. It does not wrap a third-party open-source project.