Math Calculator API

A free, public REST API for computing percentages, fractions, derivatives, quadratic equations, standard deviation, slope, triangles, and matrices. Returns structured JSON with step-by-step solutions and LaTeX notation.

v1CORS EnabledNo Auth Required

Base URL

https://mathcalculator.org/api/v1

All requests are made via POST to /api/v1/calculate with a JSON body. Machine-readable documentation is available at GET /api/v1/docs.

Request Format

{
  "type": "percentage | fraction | derivative | quadratic | standard-deviation | slope | triangle | matrix",
  "params": { ... }
}

type (string, required) — the calculator to use.

params (object, required) — parameters for the calculation (varies by type).

Response Format

{
  "result": { ... },
  "steps": ["Step 1", "Step 2", ...],
  "latex": "\\frac{25}{100} \\times 200 = 50"
}

result — the computed answer (shape depends on calculator type).

steps — array of human-readable step-by-step explanations.

latex — LaTeX string for rendering the solution.

Percentage Calculator

Five modes: of, is, change, difference, reverse.

Example: What is 25% of 200?

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "percentage", "params": { "a": 25, "b": 200, "mode": "of" } }'
ParamTypeDescription
anumberFirst value
bnumberSecond value
modestring"of" | "is" | "change" | "difference" | "reverse" (default: "of")

Fraction Calculator

Operations: add, subtract, multiply, divide, simplify. Results are always returned in simplest form.

Example: Add 1/3 + 1/6

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "fraction", "params": { "num1": 1, "den1": 3, "num2": 1, "den2": 6, "operation": "add" } }'
ParamTypeDescription
num1, den1integerFirst fraction
num2, den2integerSecond fraction (not needed for simplify)
operationstring"add" | "subtract" | "multiply" | "divide" | "simplify" (default: "add")

Derivative Calculator

Symbolic differentiation powered by mathjs. Supports higher-order derivatives up to 10th order.

Example: Derivative of x^3 + 2*x^2 - 5*x

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "derivative", "params": { "expression": "x^3 + 2*x^2 - 5*x", "variable": "x" } }'
ParamTypeDescription
expressionstringMathematical expression (e.g. "x^2 + 3*x")
variablestringVariable to differentiate with respect to (default: "x")
orderintegerDerivative order, 1-10 (default: 1)

Quadratic Equation Solver

Solves ax² + bx + c = 0. Returns roots (real or complex), discriminant, vertex, and axis of symmetry.

Example: Solve x² - 5x + 6 = 0

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "quadratic", "params": { "a": 1, "b": -5, "c": 6 } }'
ParamTypeDescription
anumberCoefficient of x² (must not be 0)
bnumberCoefficient of x
cnumberConstant term

Standard Deviation Calculator

Calculate mean, variance, and standard deviation for a data set. Supports both population and sample standard deviation.

Example: Population standard deviation of [10, 20, 30, 40, 50]

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "standard-deviation", "params": { "values": "10,20,30,40,50", "type": "population" } }'

Example: Sample standard deviation (array format)

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "standard-deviation", "params": { "values": [85, 90, 78, 92, 88], "type": "sample" } }'
ParamTypeDescription
valuesstring or arrayComma-separated numbers or array (e.g. "10,20,30" or [10,20,30])
typestring"population" | "sample" (default: "population")

Slope Calculator

Calculate slope, y-intercept, distance, and line equation from two points.

Example: Slope between (1, 2) and (4, 8)

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "slope", "params": { "x1": 1, "y1": 2, "x2": 4, "y2": 8 } }'
ParamTypeDescription
x1numberx-coordinate of first point
y1numbery-coordinate of first point
x2numberx-coordinate of second point
y2numbery-coordinate of second point

Triangle Calculator

Calculate area (Heron's formula), perimeter, and angles of a triangle given three side lengths.

Example: Triangle with sides 3, 4, 5

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "triangle", "params": { "a": 3, "b": 4, "c": 5 } }'
ParamTypeDescription
anumberLength of side a
bnumberLength of side b
cnumberLength of side c

Matrix Calculator

Matrix operations: determinant, transpose, or inverse. Supports matrices up to 5x5.

Example: Determinant of a 2x2 matrix

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "matrix", "params": { "matrixA": [[1, 2], [3, 4]], "operation": "determinant" } }'

Example: Inverse of a 2x2 matrix

curl -X POST https://mathcalculator.org/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{ "type": "matrix", "params": { "matrixA": [[4, 7], [2, 6]], "operation": "inverse" } }'
ParamTypeDescription
matrixA2D arrayMatrix as array of arrays (e.g. [[1,2],[3,4]])
operationstring"determinant" | "transpose" | "inverse" (default: "determinant")

Error Handling

Errors return a JSON object with an error field and an appropriate HTTP status code (400 for validation errors).

{ "error": "Parameters \"a\" and \"b\" must be valid numbers." }

© 2026 Math Calculator. Free to use.

mathcalculator.org