Tools Guides
Math Free No signup

Matrix Operations Calculator

Perform addition, subtraction, multiplication, transpose, determinant, and inverse on matrices up to 5×5.

Loading tool…

About this tool

Enter up to two matrices using on-screen grid inputs (up to 5×5 each). Choose an operation: Add, Subtract, Multiply, Transpose, Determinant (square matrices), or Inverse (2×2 and 3×3). Results are displayed instantly, and matrix multiplication includes a step-by-step dot-product breakdown so you can follow the working.

How to use

  1. 1 Set the row and column dimensions for Matrix A (and Matrix B if needed).
  2. 2 Fill in the values in the grid inputs.
  3. 3 Select the desired operation from the buttons.
  4. 4 View the result matrix or scalar below the inputs.
  5. 5 For multiplication, expand the step-by-step section to see each dot-product calculation.

What this calculator does

A matrix is a rectangular grid of numbers, and matrix algebra is the language behind computer graphics, machine learning, physics simulations, and systems of linear equations. This tool lets you enter two matrices (up to 5×5 each), then add, subtract, or multiply them, transpose either one, and compute a determinant or inverse. Every operation runs instantly in your browser, and the multiplication view shows the full arithmetic for each output cell so you can check your work or learn the mechanics. Below are the rules that govern when each operation is even possible — getting these dimension rules right is most of the battle.

Addition and subtraction: dimensions must match exactly

You can only add or subtract two matrices that have the same number of rows and the same number of columns. The operation is element-by-element: the value in row 1, column 1 of A is added to the value in row 1, column 1 of B, and so on. If the dimensions differ, the tool refuses and tells you why, because there is no defined answer.

Multiplication: the inner dimensions must agree

Matrix multiplication is where most mistakes happen, because it is not element-by-element and it is not commutative — A × B is usually not the same as B × A. The rule: to multiply A by B, the number of columns in A must equal the number of rows in B. The result has as many rows as A and as many columns as B. Each output cell is a dot product: to get the cell in row i, column j, you march across row i of A and down column j of B, multiplying paired entries and summing them.

A worked example

Use the defaults, A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], and press A × B. The top-left cell of the result is computed from A's first row and B's first column:

C[1][1] = 1×5 + 2×7 = 5 + 14 = 19

Continuing for every cell gives [[19, 22], [43, 50]]. The tool's step-by-step panel writes out each of these dot products in full — that 1×5 + 2×7 = 19 line is taken straight from how the tool displays it — so you can trace exactly where every number came from. Try B × A next and you will get [[23, 34], [31, 46]], a different answer, which proves order matters.

Transpose, determinant, and inverse

The transpose flips a matrix across its diagonal: rows become columns. An m×n matrix becomes n×m. It works on any shape.

The determinant is a single number computed from a square matrix. For a 2×2 it is ad − bc. For larger matrices the tool uses cofactor expansion along the first row, recursively breaking the matrix into smaller minors. The determinant tells you something crucial: if it equals zero, the matrix is singular and has no inverse. Geometrically, the determinant is the factor by which the matrix scales area or volume, and a zero determinant means the transformation collapses space into a lower dimension.

The inverse is the matrix equivalent of a reciprocal: A × A⁻¹ gives the identity matrix. The tool computes it for 2×2 and 3×3 square matrices using the adjugate divided by the determinant. If the determinant is zero it correctly reports that no inverse exists. The inverse is how you "divide" by a matrix — it is the key to solving the linear system Ax = b as x = A⁻¹b.

Where matrix operations show up

  • Computer graphics: Rotating, scaling, and translating 3D models is matrix multiplication; the order of multiplication is why "rotate then move" differs from "move then rotate."
  • Solving equations: A system of linear equations becomes Ax = b, solved with the inverse or determinant.
  • Data science: Covariance matrices, transformations, and the math inside neural networks are all matrix operations.
  • Engineering and physics: Stress tensors, circuit analysis, and Markov chains all live in matrix form.

Common mistakes

  • Assuming multiplication commutes. A × B ≠ B × A in general. Always keep the order the problem demands.
  • Mismatching dimensions. Trying to multiply a 2×3 by a 2×2 fails — the inner dimensions (3 and 2) disagree. Check columns-of-A against rows-of-B first.
  • Expecting an inverse for a singular matrix. If the determinant is zero, there is no inverse, no matter how you arrange the numbers.
  • Inverting a non-square matrix. Determinants and inverses are only defined for square matrices; the tool will tell you so.
  • Trusting tiny floating-point residue. Values smaller than about 1×10⁻¹⁰ are displayed as 0 to hide rounding noise — a near-zero determinant still means the matrix is effectively singular.

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.) #}