Tools Guides
math Free No signup

Matrix Calculator

Perform matrix operations — add, subtract, multiply, transpose, determinant, and inverse — with step-by-step working.

Loading tool…

About this tool

Select a matrix size (2×2, 3×3, or 4×4) and fill in the grid cells for Matrix A and Matrix B. Choose an operation: Addition, Subtraction, Multiplication, Transpose, Determinant, or Inverse. Results are displayed as a formatted matrix grid. For Determinant and Inverse, the tool shows full cofactor-expansion working so you can follow every step. Errors are clearly reported for singular matrices, incompatible sizes, and non-square inputs.

How to use

  1. 1 Select the matrix size (2×2, 3×3, or 4×4) from the size selector.
  2. 2 Enter values into the Matrix A grid — and Matrix B if the operation requires two matrices.
  3. 3 Choose an operation: Add, Subtract, Multiply, Transpose, Determinant, or Inverse.
  4. 4 Click Calculate to see the result matrix and, for Determinant/Inverse, the step-by-step working.

What a matrix calculator does

A matrix is a grid of numbers, and matrix algebra is the engine behind 3D graphics, machine learning, physics simulations, economics, and any system of linear equations. This calculator works with square matrices of size 2×2, 3×3, or 4×4 and performs the core operations: addition, subtraction, multiplication, transpose, determinant, and inverse. You fill the grids with numbers (decimals allowed), pick an operation, and it computes the result entirely in your browser. For the determinant and inverse it also shows step-by-step working so you can check the method, not just the answer.

How each operation actually works

Addition and subtraction are element-wise: the entry in row i, column j of the result is simply A[i][j] ± B[i][j]. Both matrices must be the same size, which is why this tool keeps A and B identical in dimension.

Multiplication is the operation people get wrong, because it is not element-wise. Each result entry is a dot product of a row of A with a column of B: result[i][j] = Σ A[i][k] × B[k][j] over all k. This makes matrix multiplication non-commutative — A×B generally does not equal B×A — and it's why the order you enter the matrices matters.

Transpose flips the matrix over its diagonal: rows become columns, so the entry at (i, j) moves to (j, i).

Determinant is computed by cofactor expansion along the first row. For a 2×2 it's the familiar ad − bc. For larger matrices the tool recursively breaks the problem into smaller "minor" matrices, multiplying each first-row entry by the determinant of the submatrix left after deleting its row and column, with alternating + and − signs.

Inverse uses the adjugate method: A⁻¹ = adj(A) / det(A), where the adjugate is the transposed matrix of cofactors. If the determinant is zero (technically, within a tiny tolerance of zero) the matrix is singular and has no inverse — the tool reports this rather than returning nonsense.

A worked example: 2×2 determinant and inverse

Take the matrix A = [[4, 7], [2, 6]].

  • Determinant: det(A) = (4 × 6) − (7 × 2) = 24 − 14 = 10. Since it's non-zero, an inverse exists.
  • Inverse: for a 2×2 you swap the diagonal entries, negate the off-diagonal, and divide by the determinant:
    A⁻¹ = (1/10) × [[6, −7], [−2, 4]] = [[0.6, −0.7], [−0.2, 0.4]].

You can verify the result by multiplying A × A⁻¹ in the tool — it should return the identity matrix [[1, 0], [0, 1]], give or take tiny floating-point rounding.

Common use cases

  • Solving linear systems. A set of simultaneous equations written as Ax = b is solved by x = A⁻¹b; the inverse and determinant are the heart of that.
  • Computer graphics. 4×4 matrices represent translation, rotation, and scaling of 3D objects; multiplying them chains transformations.
  • Checking homework. Compute the answer here, then compare with your hand calculation — the step display makes it a study aid, not just a black box.
  • Engineering and statistics. Covariance matrices, transformation matrices, and Markov transition matrices all rely on these operations.

Tips and common mistakes

  • Multiplication order is not interchangeable. A×B ≠ B×A in general. Decide which matrix is the "transformation" and which is the "input," and put them in that order.
  • A zero determinant means no inverse. Geometrically, the matrix collapses space onto a lower dimension, so it can't be undone. If you see the "singular" error, your rows or columns are linearly dependent (one is a combination of the others).
  • Watch floating-point noise. Inverses and chained operations can leave values like 0.9999998 instead of 1. The display rounds for readability, but expect tiny residue when you verify results.
  • Empty cells count as zero. Blank inputs are read as 0, so an unfilled entry silently changes your answer — fill every cell deliberately.
  • Determinant only for square matrices. All operations here use square matrices, which is correct: determinant and inverse are undefined for non-square matrices, and multiplication of non-square matrices requires matching inner dimensions.
  • Transpose ≠ inverse. A beginner trap is treating the transpose as an inverse. They're equal only for special (orthogonal) matrices; in general they're entirely different results.

Frequently Asked Questions

{# Alpine.js — self-hosted. (The previous jsdelivr CDN tag had a stale SRI integrity hash, so the browser refused to run it and window.Alpine was never defined — silently breaking every FAQ accordion and Alpine tool.) #}