Matrix Calculator
Add, subtract, multiply, transpose, or take the determinant of matrices up to 6×6.
Written by Golam Rabbani, Founder & Lead Engineer
How to use this matrix calculator
- Pick an operation: A + B, A − B, A × B, transpose Aᵀ, or determinant det(A).
- Set the dimensions of matrix A (rows × cols), up to 6 × 6.
- For add, subtract, or multiply, set the dimensions of matrix B as well.
- Type a number into every cell of the matrices you need.
- Press Run. The result appears as a labelled grid, or as a single number for the determinant.
- Use Copy to copy the result as tab-separated values, or Reset to clear all cells.
About this matrix calculator
The matrix calculator performs the five most common matrix operations entirely in your browser: addition, subtraction, multiplication, transpose, and determinant. Dimensions are capped at 6 × 6 to keep the determinant fast and the page responsive (Input Delay-friendly). Add and subtract require A and B to share the same shape; multiplication requires A’s column count to equal B’s row count and produces an m × n result.
As a worked example, choose multiplication, set A to a 2 × 3 matrix [[1, 2, 3], [4, 5, 6]] and B to a 3 × 2 matrix [[7, 8], [9, 10], [11, 12]]. The result is a 2 × 2 matrix: [[1·7 + 2·9 + 3·11, 1·8 + 2·10 + 3·12], [4·7 + 5·9 + 6·11, 4·8 + 5·10 + 6·12]] = [[58, 64], [139, 154]]. Switching to determinant on the 2 × 2 [[1, 2], [3, 4]] returns 1·4 − 2·3 = −2.
For the determinant the tool uses LU decomposition with partial pivoting (O(n³)), which stays numerically stable up to 6 × 6 and runs in well under a millisecond — no cofactor blow-up at higher dimensions.
FAQ
- Why is the matrix dimension capped at 6 × 6?
- Six is large enough for textbook and undergraduate problems while keeping the UI grid mobile-friendly and the LU determinant essentially instant. Beyond that the input experience suffers more than the math.
- Why does add or subtract require identical dimensions?
- Add and subtract operate element-wise. Each cell (i, j) in the result is A[i][j] ± B[i][j], so both matrices must share the same number of rows and columns.
- What is the rule for matrix multiplication dimensions?
- For A × B to be defined, the number of columns of A must equal the number of rows of B. If A is m × k and B is k × n, the product is m × n.
- How is the determinant calculated?
- Through LU decomposition with partial pivoting: the tool reduces A to upper-triangular form, multiplies the pivots, and flips the sign once per row swap. This is numerically stable and runs in O(n³).
- What is a transpose?
- The transpose Aᵀ swaps rows and columns. An m × n matrix becomes n × m, and the entry at (i, j) ends up at (j, i).
- Is everything client-side?
- Yes. The matrices and the result never leave your browser. Nothing is uploaded.