BrainyCalc Docs — Mathematics
Docs / Mathematics
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
Safely evaluates an arithmetic expression string. Supports +, −, *, /, %, ^, and parentheses.
arithmetic
ParameterTypeRequiredDescription
expressionstringrequiredArithmetic 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.
percentages
ParameterTypeRequiredDescription
modeenumrequiredpercentage_of · what_percent_is · percentage_change · percentage_difference
anumberrequiredFirst number
bnumberrequiredSecond 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.
statistics
ParameterTypeRequiredDescription
numbersnumber[]requiredNon-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.
algebra
ParameterTypeRequiredDescription
anumberrequiredCoefficient a (must not be zero)
bnumberrequiredCoefficient b
cnumberrequiredCoefficient 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.
number theory
ParameterTypeRequiredDescription
anumberrequiredFirst integer
bnumberrequiredSecond 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.
number theory
ParameterTypeRequiredDescription
numbernumberrequiredPositive 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.
arithmetic
ParameterTypeRequiredDescription
basenumberrequiredBase value
exponentnumberrequiredExponent or root index
modeenumoptionalpower (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.
combinatorics
ParameterTypeRequiredDescription
nnumberrequiredTotal set size
rnumberoptionalSub-selection size (required for nPr and nCr)
modeenumoptionalnCr (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.
fractions
ParameterTypeRequiredDescription
numeratornumberrequiredNumerator
denominatornumberrequiredDenominator (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.
geometry
ParameterTypeRequiredDescription
shapeenumrequiredcircle · rectangle · triangle · sphere · cylinder
dimensionsobjectrequiredShape-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.
trigonometry
ParameterTypeRequiredDescription
funcenumrequiredsin · cos · tan · asin · acos · atan
angleValuenumberrequiredAngle value (or input for inverse functions)
unitenumoptionaldeg (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).
algebra
ParameterTypeRequiredDescription
valuenumberrequiredPositive number to take the log of
basenumberoptionalLogarithm base (default 10). Pass e or 2.71828... for natural log.
Request / Response
{ "value": 1000, "base": 10 }

{ "value": 1000, "base": 10, "result": 3 }

© 2025 BrainyCalc. Trusted computation for AI.