🔢 Matrix Calculator
Enter two matrices (rows separated by newlines, values by commas or spaces) to add, subtract or multiply them, or find the determinant and inverse of matrix A.
The three rules behind the six operations
Addition and subtraction work element by element. Multiplication is a row-by-column dot product, and the 2×2 inverse falls out of the determinant:
(AB) ij = Σ k A ik B kj
det [a b; c d] = ad − bc
inv [a b; c d] = (1/det) × [ d −b ; −c a ]
With the defaults A = [1 2; 3 4] and B = [5 6; 7 8], A × B is [19 22; 43 50] - the top-left 19 is 1×5 + 2×7. The determinant of A is 1×4 − 2×3 = −2, so its inverse is [−2 1; 1.5 −0.5].
Entering matrices and the size rules
- One row per line, values split on commas or spaces. Rows of unequal length are rejected.
- Add and subtract need identical shapes. Multiply needs A's column count to equal B's row count: a 2×3 times a 3×2 gives a 2×2.
- Determinant and inverse stop at 3×3 and need a square matrix. Transpose has no size limit and ignores B.
- Results round to four decimals, so an inverse full of thirds shows 0.3333.
Frequently asked questions
How do you find the inverse of a 2x2 matrix?
Swap the diagonal entries, flip the sign on the other two, then divide by the determinant. For [1 2; 3 4] that is [4 -2; -3 1] over -2, giving [-2 1; 1.5 -0.5].
Why does my matrix have no inverse?
Its determinant is zero, meaning one row is a multiple of another. [1 2; 2 4] is the usual example: 1 times 4 minus 2 times 2 is 0.
Is A times B the same as B times A?
Almost never. With the defaults A times B is [19 22; 43 50] but B times A is [23 34; 31 46]. Order matters.