API Documentation
Complete REST API reference for developers integrating Calcora into their applications.
Getting Started
Calcora provides a REST API for all mathematical operations. The API is available at:
https://calcoralive.netlify.app/api/v1/ For local development or self-hosting:
http://localhost:5000/api/v1/ Installation (Python Package)
pip install calcora Quick Start (Desktop App)
Download the Windows Desktop App which includes a built-in API server.
Differentiation
POST /api/v1/differentiate
Compute the derivative of a mathematical expression with step-by-step explanation.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
expression | string | REQUIRED | Mathematical expression (e.g., "x**2 + 3*x") |
variable | string | optional | Variable to differentiate with respect to (default: "x") |
verbosity | string | optional | Detail level: "concise", "detailed", or "teacher") |
Example Request
curl -X POST https://calcoralive.netlify.app/api/v1/differentiate \
-H "Content-Type: application/json" \
-d '{
"expression": "sin(x)*x**2",
"variable": "x",
"verbosity": "detailed"
}' Example Response
{
"result": "x**2*cos(x) + 2*x*sin(x)",
"steps": [
{
"step": 1,
"rule": "product_rule",
"input": "sin(x)*x**2",
"output": "sin(x)*Derivative(x**2, x) + x**2*Derivative(sin(x), x)",
"explanation": "Apply product rule: d/dx[f·g] = f·g' + g·f'"
}
],
"metadata": {
"operation": "differentiate",
"input_expression": "sin(x)*x**2",
"variable": "x"
}
} Integration
POST /api/v1/integrate
Compute indefinite or definite integrals with step-by-step explanation and graphical visualization.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
expression | string | REQUIRED | Mathematical expression to integrate (e.g., "x**2", "sin(x)") |
variable | string | optional | Variable to integrate with respect to (default: "x") |
lower_limit | number | optional | Lower bound for definite integral |
upper_limit | number | optional | Upper bound for definite integral |
verbosity | string | optional | Detail level: "concise", "detailed", or "teacher" |
generate_graph | boolean | optional | Include graph data for visualization (default: true) |
Example: Indefinite Integral
curl -X POST https://calcoralive.netlify.app/api/v1/integrate \
-H "Content-Type: application/json" \
-d '{
"expression": "x**2",
"variable": "x",
"verbosity": "detailed"
}' Response
{
"result": "x**3/3 + C",
"definite": false,
"steps": [
{
"rule": "power_rule",
"explanation": "Apply power rule: ∫x^n dx = x^(n+1)/(n+1) + C",
"before": "x**2",
"after": "x**3/3"
}
],
"technique": "power_rule",
"can_integrate": true
} Example: Definite Integral
curl -X POST https://calcoralive.netlify.app/api/v1/integrate \
-H "Content-Type: application/json" \
-d '{
"expression": "x**2",
"variable": "x",
"lower_limit": 0,
"upper_limit": 2,
"generate_graph": true
}' Response
{
"result": "8/3",
"definite": true,
"limits": [0, 2],
"steps": [...],
"graph": {
"data": {
"x_values": [-2, -1.99, ..., 3.99, 4],
"integrand_curve": [4, 3.96, ..., 15.92, 16],
"antiderivative_curve": [0, 0.027, ..., 18.67, 21.33],
"area": {
"x": [0, 0.01, ..., 1.99, 2],
"y": [0, 0.0001, ..., 3.96, 4],
"value": 2.666666666666667
}
},
"labels": {
"integrand": "f(x) = x**2",
"antiderivative": "F(x) = ∫ f(x) dx"
},
"limits": {"lower": 0, "upper": 2}
}
} - Power rule for polynomials
- Trigonometric integrals (sin, cos, tan, sec, csc, cot)
- Exponential and logarithmic functions
- Integration by parts
- U-substitution (chain rule)
- Partial fractions for rational functions
- Trigonometric substitution
- Hyperbolic functions
Matrix Operations
POST /api/v1/matrix/determinant
Compute the determinant of a square matrix with step-by-step explanation.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
matrix | array[][] | REQUIRED | 2D array representing the matrix |
verbosity | string | optional | Detail level for steps |
Example Request
curl -X POST https://calcoralive.netlify.app/api/v1/matrix/determinant \
-H "Content-Type: application/json" \
-d '{
"matrix": [[3, 8], [4, 6]],
"verbosity": "detailed"
}' Example Response
{
"operation": "determinant",
"result": -14,
"input_matrix": [[3, 8], [4, 6]],
"steps": [
{
"explanation": "For 2×2 matrix: det = (a*d) - (b*c)",
"calculation": "(3*6) - (8*4) = 18 - 32 = -14"
}
]
} POST /api/v1/matrix/inverse
Compute the inverse of a square matrix (if it exists).
Example Request
curl -X POST https://calcoralive.netlify.app/api/v1/matrix/inverse \
-H "Content-Type: application/json" \
-d '{
"matrix": [[1, 2], [3, 4]]
}' Response
{
"operation": "inverse",
"result": [[-2, 1], [1.5, -0.5]],
"determinant": -2,
"steps": [
{
"explanation": "Calculate determinant: det(A) = -2",
"calculation": "(1*4) - (2*3) = -2"
},
{
"explanation": "Compute adjugate matrix and divide by determinant",
"result": "A^(-1) = (1/det) * adj(A)"
}
]
} POST /api/v1/matrix/eigenvalues
Compute eigenvalues and eigenvectors of a square matrix.
Example Response
{
"operation": "eigenvalues",
"eigenvalues": [5.372, -0.372],
"eigenvectors": [
[0.824, 0.566],
[-0.416, 0.909]
],
"characteristic_polynomial": "λ² - 5λ - 2"
} POST /api/v1/matrix/rref
Compute the Reduced Row Echelon Form of a matrix.
Use Cases
- Solving systems of linear equations
- Finding matrix rank
- Identifying pivot columns
- Testing linear independence
POST /api/v1/matrix/lu
Perform LU decomposition with partial pivoting: PA = LU
Factors a matrix into three components:
- P: Permutation matrix (records row swaps for numerical stability)
- L: Lower triangular matrix (with 1s on diagonal)
- U: Upper triangular matrix
Example Request
curl -X POST https://calcoralive.netlify.app/api/v1/matrix/lu \\
-H "Content-Type: application/json" \\
-d '{
"matrix": [[2, 1, 1], [4, -6, 0], [-2, 7, 2]],
"verbosity": "detailed"
}' Example Response
{
"operation": "matrix_lu",
"P": [[0, 1, 0], [1, 0, 0], [0, 0, 1]],
"L": [[1, 0, 0], [0.5, 1, 0], [-0.5, -0.923, 1]],
"U": [[4, -6, 0], [0, 4, 1], [0, 0, 1.615]],
"steps": [
{
"explanation": "Apply partial pivoting for numerical stability",
"computation": "Swap rows to place largest pivot first"
},
{
"explanation": "L stores elimination multipliers",
"computation": "Lower triangular with 1s on diagonal"
},
{
"explanation": "U is result of Gaussian elimination",
"computation": "Upper triangular form"
}
]
} Applications
- Solve Ax = b efficiently: Once computed, reuse LU for multiple right-hand sides
- Compute determinant: det(A) = det(P) × det(L) × det(U)
- Matrix inversion: Solve AX = I using LU factorization
- Numerical stability: Partial pivoting prevents division by small numbers
- Step-by-step explanations
- Input validation and error handling
- Support for symbolic arithmetic
- Numerical precision to 10 decimal places
Python SDK
For Python developers, use the official SDK for easier integration:
Installation
pip install calcora Usage Example
from calcora import differentiate, integrate, matrix_determinant
# Differentiation
result = differentiate("x**2 + 3*x", variable="x", verbosity="detailed")
print(result['output']) # "2*x + 3"
# Indefinite Integration
result = integrate("x**2", variable="x")
print(result['output']) # "x**3/3 + C"
# Definite Integration
result = integrate("x**2", variable="x", lower_limit=0, upper_limit=2)
print(result['output']) # "8/3"
print(result['graph']['area']['value']) # 2.666666666666667
# Matrix Determinant
matrix = [[3, 8], [4, 6]]
result = matrix_determinant(matrix)
print(result['result']) # -14
# LU Decomposition
matrix = [[2, 1, 1], [4, -6, 0], [-2, 7, 2]]
result = matrix_lu(matrix)
print(result['L']) # Lower triangular
print(result['U']) # Upper triangular Full Python API documentation: GitHub README