API Reference
Mathematics
12 deterministic math tools covering arithmetic, algebra, statistics, geometry, and trigonometry. All tools use the math_* prefix and return verified, reproducible results.
math_evaluate
math_percentage
math_statistics
math_quadratic
math_gcd_lcm
math_prime_factors
math_power_root
math_permutations_combinations
math_simplify_fraction
math_geometry
math_trigonometry
math_logarithm
math_evaluate
Safely evaluates an arithmetic expression string. Supports +, −, *, /, %, ^, and parentheses.
| Parameter | Type | Required | Description |
|---|---|---|---|
expression | string | required | Arithmetic expression, e.g. (12 + 8) * 3 / 2 |
Request / Response
// Request { "expression": "(12 + 8) * 3 / 2" } // Response { "expression": "(12 + 8) * 3 / 2", "result": 30 }
math_percentage
Percentage of, what percent is, percentage change, and percentage difference — four modes in one tool.
| Parameter | Type | Required | Description |
|---|---|---|---|
mode | enum | required | percentage_of · what_percent_is · percentage_change · percentage_difference |
a | number | required | First number |
b | number | required | Second number |
Request / Response
// "What is 15% of 200?" { "mode": "percentage_of", "a": 15, "b": 200 } { "mode": "percentage_of", "inputA": 15, "inputB": 200, "result": 30 }
math_statistics
Descriptive statistics for a dataset: count, sum, mean, median, mode, min, max, range, variance, and standard deviation.
| Parameter | Type | Required | Description |
|---|---|---|---|
numbers | number[] | required | Non-empty array of numbers to analyze |
Request / Response
{ "numbers": [4, 8, 6, 5, 3, 2, 8, 9, 2, 5] } { "count": 10, "sum": 52, "mean": 5.2, "median": 5, "mode": [2, 5, 8], "min": 2, "max": 9, "range": 7, "variance": 5.16, "stdDev": 2.2716 }
math_quadratic
Solves ax² + bx + c = 0. Returns real roots, a single root, or complex conjugate roots depending on the discriminant.
| Parameter | Type | Required | Description |
|---|---|---|---|
a | number | required | Coefficient a (must not be zero) |
b | number | required | Coefficient b |
c | number | required | Coefficient c |
Request / Response
// Solve x² - 5x + 6 = 0 { "a": 1, "b": -5, "c": 6 } { "type": "two_real_roots", "discriminant": 1, "root1": 3, "root2": 2 }
Return types
two_real_roots when discriminant > 0 · one_real_root when = 0 · complex_roots when < 0
math_gcd_lcm
Calculates the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) for two integers.
| Parameter | Type | Required | Description |
|---|---|---|---|
a | number | required | First integer |
b | number | required | Second integer |
Request / Response
{ "a": 48, "b": 18 } { "a": 48, "b": 18, "gcd": 6, "lcm": 144 }
math_prime_factors
Returns the prime factorization of an integer and whether the number itself is prime.
| Parameter | Type | Required | Description |
|---|---|---|---|
number | number | required | Positive integer to factorize |
Request / Response
{ "number": 360 } { "number": 360, "isPrime": false, "factors": [2, 2, 2, 3, 3, 5] }
math_power_root
Computes powers (baseⁿ) or nth roots (ⁿ√base) of a number.
| Parameter | Type | Required | Description |
|---|---|---|---|
base | number | required | Base value |
exponent | number | required | Exponent or root index |
mode | enum | optional | power (default) or root |
Request / Response
// Cube root of 27 { "base": 27, "exponent": 3, "mode": "root" } { "base": 27, "rootIndex": 3, "result": 3 }
math_permutations_combinations
Calculates Factorial (n!), Permutations (nPr), and Combinations (nCr) in a single tool.
| Parameter | Type | Required | Description |
|---|---|---|---|
n | number | required | Total set size |
r | number | optional | Sub-selection size (required for nPr and nCr) |
mode | enum | optional | nCr (default) · nPr · factorial |
Request / Response
// How many ways to choose 3 from 10? { "n": 10, "r": 3, "mode": "nCr" } { "n": 10, "r": 3, "nCr": 120 }
math_simplify_fraction
Reduces a fraction to its lowest terms and converts it to a mixed number and decimal.
| Parameter | Type | Required | Description |
|---|---|---|---|
numerator | number | required | Numerator |
denominator | number | required | Denominator (must not be zero) |
Request / Response
{ "numerator": 18, "denominator": 12 } { "original": "18/12", "simplified": "3/2", "mixedFraction": "1 1/2", "decimal": 1.5 }
math_geometry
Area, perimeter, volume, and surface area for circle, rectangle, triangle, sphere, and cylinder.
| Parameter | Type | Required | Description |
|---|---|---|---|
shape | enum | required | circle · rectangle · triangle · sphere · cylinder |
dimensions | object | required | Shape-specific dimension keys: radius, length, width, height, base |
Request / Response
// Cylinder volume & surface area { "shape": "cylinder", "dimensions": { "radius": 5, "height": 10 } } { "volume": 785.3982, "surfaceArea": 471.2389 }
math_trigonometry
sin, cos, tan, asin, acos, and atan — accepts degrees or radians.
| Parameter | Type | Required | Description |
|---|---|---|---|
func | enum | required | sin · cos · tan · asin · acos · atan |
angleValue | number | required | Angle value (or input for inverse functions) |
unit | enum | optional | deg (default) or rad |
Request / Response
{ "func": "sin", "angleValue": 45, "unit": "deg" } { "func": "sin", "angleValue": 45, "unit": "deg", "result": 0.707107 }
math_logarithm
Computes logarithm of a value in any base, including natural log (base e).
| Parameter | Type | Required | Description |
|---|---|---|---|
value | number | required | Positive number to take the log of |
base | number | optional | Logarithm base (default 10). Pass e or 2.71828... for natural log. |
Request / Response
{ "value": 1000, "base": 10 } { "value": 1000, "base": 10, "result": 3 }