Matrix Calculator

Pick a size (2×2 or 3×3) and an operation — A + B, A − B, A × B, determinant, or inverse — fill in the entries, and get the result as a clean matrix grid.

Put this calculator on your website — free

Copy one snippet and give your visitors a working Matrix Calculator.

How matrix operations work

Addition and subtraction are the gentle ones: matrices of the same size combine entry by entry, exactly as you’d hope. Multiplication is where matrices earn their reputation, because it is not entry-by-entry. Each entry of A × B is a row of A dotted with a column of B: slide along row i of A and down column j of B, multiply the pairs, add them up, and that sum is entry (i, j) of the product. The row-times-column rule looks arbitrary until you learn what matrices are for — they represent transformations (rotations, scalings, shears), and this exact rule is what makes multiplying two matrices the same as applying one transformation after the other. It also explains the famous surprise that A × B ≠ B × A in general: rotating then stretching is not the same as stretching then rotating.

The formula

(A×B)ij = Σk aik·bkj     det[[a, b],[c, d]] = ad − bc
[[a, b],[c, d]]⁻¹ = (1⁄(ad − bc)) · [[d, −b],[−c, a]]

In the product formula, aik is the entry in row i, column k of A and bkj is the entry in row k, column j of B — the sum over k is the row-dot-column operation described above. The 2×2 inverse formula has a pleasant rhythm: swap the diagonal entries, negate the off-diagonal ones, divide everything by the determinant. For 3×3 matrices this calculator uses the cofactor method (each entry of the inverse is a signed 2×2 sub-determinant, transposed and divided by det A). Both inverse formulas divide by the determinant, which is exactly why det A = 0 means no inverse exists.

Worked example

Multiply A = [[1, 2],[3, 4]] by B = [[5, 6],[7, 8]]. Four row-dot-column computations: top-left is (row 1)·(col 1) = 1×5 + 2×7 = 19; top-right is 1×6 + 2×8 = 22; bottom-left is 3×5 + 4×7 = 43; bottom-right is 3×6 + 4×8 = 50. So A × B = [[19, 22],[43, 50]]. (Try B × A and you’ll get [[23, 34],[31, 46]] — order matters.)

Invert A = [[4, 7],[2, 6]]. The determinant is 4×6 − 7×2 = 10. Swap the diagonal, negate the off-diagonal, divide by 10: A⁻¹ = [[0.6, −0.7],[−0.2, 0.4]]. Check by multiplying: A × A⁻¹ = [[1, 0],[0, 1]], the identity.

What the determinant is really telling you

The determinant isn’t just an invertibility gatekeeper — it’s a measurement. A 2×2 matrix transforms the plane, and its determinant is the factor by which it scales area: det A = 3 means every shape comes out with triple the area, and for a 3×3 matrix the same story holds with volume. A negative determinant means the transformation also flips orientation, like a reflection in a mirror. And det A = 0 means the matrix squashes the plane onto a line (or space onto a plane) — area becomes zero, information is destroyed, and no inverse can ever rebuild it. That’s the geometric reason singular matrices have no inverse, and it’s why the warning matters in practice: matrices run 3D graphics (every rotation and camera move is a matrix product), solve systems of equations, power least squares regression, and sit inside every neural network — and in all of those, a determinant near zero is the smell of a problem about to fall over numerically.

Frequently asked questions

How do you multiply two matrices?

Row times column: entry (i, j) of A × B is row i of A dotted with column j of B — multiply the paired entries and add them up. For [[1,2],[3,4]] × [[5,6],[7,8]], the top-left entry is 1×5 + 2×7 = 19, and the full product is [[19,22],[43,50]]. The rule looks odd but is exactly what makes matrix multiplication mean 'apply one transformation, then the other.'

Why is A × B not the same as B × A?

Because matrices represent transformations, and the order you apply transformations matters: rotating a photo and then stretching it horizontally gives a different picture than stretching first and rotating second. Multiply [[1,2],[3,4]] and [[5,6],[7,8]] both ways and you get [[19,22],[43,50]] versus [[23,34],[31,46]]. Commutativity is the exception in matrix land, not the rule.

What does the determinant of a matrix tell you?

It measures how the matrix scales space: a 2×2 matrix with determinant 3 triples every area it transforms, and a 3×3 determinant does the same for volume. A negative determinant means the transformation also flips orientation, like a mirror. And determinant zero means the matrix flattens space onto a line or plane — which is precisely why such matrices have no inverse.

What is a singular matrix and why does it have no inverse?

A singular matrix is one whose determinant is zero — its rows are linearly dependent (in the 2×2 case, one row is a multiple of the other). Geometrically it collapses space flat, sending many different inputs to the same output. Undoing it would require deciding which of those inputs you started from, and that information is gone. Every inverse formula divides by the determinant, so det = 0 makes the division impossible.

How do you find the inverse of a 2×2 matrix by hand?

Three steps: compute the determinant ad − bc, swap the two diagonal entries, negate the two off-diagonal entries, then divide every entry by the determinant. For [[4,7],[2,6]]: the determinant is 24 − 14 = 10, so the inverse is [[6,−7],[−2,4]] divided by 10, which is [[0.6,−0.7],[−0.2,0.4]]. Verify by multiplying: A × A⁻¹ should give the identity matrix [[1,0],[0,1]].

Related calculators