Matrix Calculator
Add, subtract, multiply, scale, transpose, and compute the determinant, inverse, and rank of small matrices — with clear errors when an operation is undefined.
Interactive Client Prototype Sandbox
Disclaimer: This free tool is provided “as is,” without warranties of any kind, and is for general informational purposes only — not professional, legal, financial, medical, tax, or engineering advice. Results may contain errors; verify anything important independently and use at your own risk. We accept no liability for any loss or damage arising from its use. See our Terms of Use for details.
Step-by-Step Guide
Set the dimensions (rows × columns) for Matrix A and Matrix B using the selectors. Fill in each cell with a number — decimal and negative values are supported. Select an operation and the result appears immediately.
Available operations: Add (A + B, requires identical dimensions), Subtract (A − B, same), Multiply (A × B, requires A columns = B rows), Scalar multiply (A × k, where k is a constant you enter), Transpose (rotates rows and columns of a single matrix), Determinant (scalar value, square matrices only), Inverse (square matrices only, singular matrices flagged), and Rank (via Gaussian elimination).
Errors are shown inline when an operation is undefined: attempting to multiply non-conformable matrices, invert a singular matrix, or compute the determinant of a non-square matrix all produce clear error messages rather than incorrect results.
Multiplication [[1,2],[3,4]] × [[5,6],[7,8]]: row 1 × col 1 = (1×5)+(2×7)=19; row 1 × col 2 = (1×6)+(2×8)=22; row 2 × col 1 = (3×5)+(4×7)=43; row 2 × col 2 = (3×6)+(4×8)=50 → result [[19,22],[43,50]]. Determinant of [[1,2],[3,4]] = (1×4)−(2×3) = 4−6 = −2. Inverse: multiply adj(A)/det(A) = [[4,−2],[−3,1]] / −2 = [[−2,1],[1.5,−0.5]].
Who it's for
Linear-algebra students, engineers, graphics programmers, and data scientists.
Core Features
- Resizable grids for two matrices (up to 4×4).
- Add, subtract, multiply, and scalar-multiply with dimension checks.
- Transpose, determinant, inverse, and rank via Gaussian elimination.
- Clear errors for non-conformable or singular matrices.
🛡️ No tracking — your inputs, keys, and details never leave this client sandbox.
When can I multiply two matrices?
Matrix multiplication is only defined when the number of columns in the first matrix equals the number of rows in the second. A 2×3 matrix can multiply a 3×4 matrix, producing a 2×4 result. A 3×2 matrix cannot multiply a 3×4 matrix (3 ≠ 2). This rule makes matrix multiplication non-commutative: A×B and B×A are generally not equal and may not even both be defined.
What is a determinant used for?
The determinant is a scalar value computed from a square matrix. It tells you: whether the matrix is invertible (determinant = 0 means singular, no inverse); the scale factor by which the matrix transformation changes areas (in 2D) or volumes (in 3D); and the sign tells you whether the transformation preserves or reverses orientation. Determinants are used in solving systems of equations (Cramer's Rule), computing eigenvalues, and change-of-variables in calculus.
What does it mean for a matrix to be singular?
A square matrix is singular if its determinant is zero. Geometrically, a singular matrix maps space into a lower dimension — it 'collapses' the space, losing information. Algebraically, it means the matrix has no inverse, and any system of equations it represents is either inconsistent (no solution) or underdetermined (infinitely many solutions). Singular matrices arise when rows are linearly dependent — one row is a multiple or linear combination of another.
What is matrix rank?
The rank of a matrix is the number of linearly independent rows (or equivalently columns) it contains. A full-rank matrix has rank equal to its smaller dimension (min of rows and columns) and no redundant rows. Rank is computed via Gaussian elimination (row reduction), which converts the matrix to row echelon form and counts the non-zero rows. For a 3×3 matrix: rank 3 means all rows are independent; rank 2 means one row is a combination of the others; rank 1 means all rows are multiples of one row.
Why is the GPU on your graphics card fundamentally a matrix calculator?
When you move a 3D object on screen, your GPU computes its new position by multiplying a vector of coordinates by a transformation matrix — a matrix multiplication. When a neural network makes a prediction, each layer performs a matrix multiplication followed by a non-linear activation. When a scientist runs a quantum simulation, the state of the system evolves via matrix operations. Matrix algebra is not an abstract academic topic: it is the computational primitive that underlies computer graphics, machine learning, signal processing, and physics simulation. GPUs exist because matrix multiplication is so central to modern computing that it warranted dedicated silicon.
Matrix operations and their geometric meaning
Matrix addition and subtraction combine corresponding elements; they require identical dimensions and represent the combination of two linear transformations. Matrix multiplication (the dot product of rows and columns) represents the composition of two linear transformations — applying one transformation after another. The transpose of a matrix (rows become columns) represents the 'adjoint' of the transformation and is used in computing inverses and in statistics (covariance matrices). The determinant measures the signed scaling factor of the transformation on area or volume: a matrix with |det| = 2 doubles all areas; det = 0 collapses space to a lower dimension.
Gaussian elimination
Gaussian elimination is the standard algorithm for solving linear systems, computing matrix rank, and finding matrix inverses. It applies row operations — multiplying a row by a scalar, adding a multiple of one row to another, swapping rows — to reduce the matrix to row echelon form. These operations do not change the solution set of the corresponding linear system but progressively simplify the equations until the solution (or the absence of a solution) is apparent. The algorithm runs in O(n³) time for an n×n matrix and is numerically stable when implemented with partial pivoting.
When operations are undefined and why it matters
Matrix operations have strict preconditions. Multiplication requires the inner dimensions to match (A columns = B rows); addition requires identical dimensions; the determinant and inverse are defined only for square matrices; the inverse requires a non-zero determinant. These constraints are not arbitrary — they follow directly from the geometric meaning of the operations. Attempting to multiply non-conformable matrices is geometrically meaningless: you cannot compose two transformations that operate on spaces of incompatible dimension. This tool shows explicit error messages for undefined operations rather than returning a garbage result, which makes it suitable for checking homework and verifying manual calculations.