Matrix
The /matrix endpoint performs mathematical operations on matrices. It supports arithmetic, scalar multiplication, transposition, and linear algebra operations on up to 20×20 matrices.
How it works?
Determinant is computed via Gaussian elimination with partial pivoting. Matrix inverse uses Gauss-Jordan elimination on an augmented matrix. All inputs are validated: values must be finite numbers, rows must have uniform length, and the matrix must not exceed 20×20.
curl -X POST \ "https://api.moxon.dev/v6/matrix" \ -H "Content-Type: application/json" \ -d '{}'Send the request to see the response here.
The request body must be JSON:
operationstringrequiredThe operation to perform (see available operations)
- add
- subtract
- multiply
- scalar
- transpose
- determinant
- inverse
- identity
matrixjsonrequiredThe input matrix (2D array of numbers)
matrix2jsonconditionalSecond matrix — required for
add,subtract,multiplyscalarnumberconditionalScalar value — required for
scalar, used byidentity
| Operation | Description | Requires |
|---|---|---|
add | Element-wise addition | matrix2 |
subtract | Element-wise subtraction | matrix2 |
multiply | Matrix multiplication | matrix2 |
scalar | Multiply all elements by a scalar | scalar |
transpose | Transpose rows and columns | — |
determinant | Compute the determinant (square matrices only) | — |
inverse | Compute the inverse (square, non-singular matrices) | — |
identity | Generate an identity matrix of size scalar×scalar | scalar |
The response format depends on the operation:
| Operation | result type |
|---|---|
add, subtract, multiply, scalar, transpose, inverse, identity | number[][] |
determinant | number |
If parameters are missing or invalid, the API will return an error:
- 400
Please provide a valid operationTheoperationparameter is missing or invalid. Valid values:add,subtract,multiply,scalar,transpose,determinant,inverse,identity - 400
Matrix must be a non-empty 2D arrayThe matrix is missing or malformed - 400
All rows must have the same lengthThe matrix rows are not uniform - 400
Matrix values must be finite numbersThe matrix contains non-numeric values - 400
Matrix exceeds maximum size of 20×20The matrix is larger than 20×20 - 400
Both matrices must have the same dimensionsDimension mismatch for add/subtract - 400
Matrix dimensions incompatible for multiplicationColumn count of A ≠ row count of B - 400
Matrix must be squareOperation requires a square matrix - 400
Matrix is singular and cannot be invertedThe matrix has no inverse
Last updated on September 12, 2026