🔧 Operation
📝 Matrix A
📝 Matrix B
🔢 Scalar
🔢 Identity size (n)
📤 Result
{{ resultPretty }}
JSON form
{{ resultJson }}
ℹ️ About Matrix Calculator
What does this matrix calculator do?
This is an online matrix calculator that runs entirely in your browser. Enter any pair of matrices up to 8×8 and compute matrix addition, matrix subtraction, matrix multiplication, scalar multiplication, transpose, determinant, or inverse on demand. The tool also generates an identity matrix of any size in [1, 8] for use as a starting template.
Every operation uses the same TypeScript logic module on the server through the API endpoint below, so a
curl call against the JSON API returns the same numbers as the interactive interface.
Operations and algorithms
- Add / Subtract — element-wise
C[i][j] = A[i][j] ± B[i][j]. A and B must share the same dimensions. - Multiply — classical row-by-column product
C[i][j] = ∑k A[i][k] × B[k][j]. Requirescols(A) = rows(B). - Scalar multiply — multiply every entry of A by the scalar s.
- Transpose —
AT[i][j] = A[j][i]. Rows become columns. - Determinant — Sarrus / cofactor expansion for
n ≤ 3; LU decomposition with partial pivoting forn ≥ 4. The determinant is the product of the upper-triangular diagonal multiplied by the sign of the row swaps. - Inverse — Gauss-Jordan elimination on the augmented matrix
[A | I]with partial pivoting. The right half becomesA-1when the left half reduces toI. - Identity — square matrix with
1on the diagonal and0elsewhere.
Common use cases
- Linear algebra coursework — verify hand calculations for Gauss-Jordan inverses, cofactor determinants, and basic matrix arithmetic.
- Graphics and game development — quick sanity checks on rotation, scaling, and composite 4×4 transformation matrices.
- Engineering and physics — solve small linear systems
Ax = bby computingA-1bfor design or simulation work. - Data analysis prototypes — confirm a covariance, projection, or rotation matrix before pasting it into a notebook.
- API consumers — call the
/api/tools/math/matrix-calculatorendpoint from a script to get matrix arithmetic without pulling in a heavy linear-algebra dependency.
Worked example
With A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]:
- A + B = [[6, 8], [10, 12]]
- A × B = [[19, 22], [43, 50]]
- AT = [[1, 3], [2, 4]]
- det(A) = 1·4 - 2·3 = -2
- A-1 = [[-2, 1], [1.5, -0.5]]
Limitations and edge cases
- Matrices are restricted to at most 8×8 entries to keep the in-browser arithmetic fast and the API endpoint within the Node bridge's 5 second timeout.
- All entries must be finite numbers. NaN, Infinity, blank cells, and non-numeric strings are rejected up front.
- Determinant requires a square matrix; non-square inputs throw an explicit error.
- Inverse requires a square, non-singular matrix. A pivot magnitude under
1e-12during Gauss-Jordan elimination is treated as singular and throws "Matrix is singular (or nearly so); cannot invert". - Multiplication requires
cols(A) = rows(B). The error message reports both dimensions to help spot mistakes. - Numerical results use double-precision floats. Expect tiny rounding error (~1e-15) on inverse round-trips of non-integer matrices.
Source references
- Wikipedia: Matrix multiplication — definitions and dimensional rules.
- Wikipedia: Determinant — Laplace expansion and LU-based computation.
- Wikipedia: LU decomposition — partial pivoting and sign tracking for the determinant.
- Wikipedia: Gaussian elimination — Gauss-Jordan inversion procedure used by this calculator.
- Wikipedia: Invertible matrix — conditions for the inverse to exist (non-zero determinant).
API Usage Example:
POST /api/tools/math/matrix-calculator
Content-Type: application/json
{
"operation": "add",
"a": [
[
1,
2
],
[
3,
4
]
],
"b": [
[
5,
6
],
[
7,
8
]
]
}