Matrix subtraction calculator

Type two matrices of the same size, one row per line, and get A − B.

One row per line, numbers separated by spaces. Fractions such as 1/2 are allowed.

Fill in the fields; the answer appears here straight away.

How it works

  1. Enter the values

    Type the numbers or the formula. Decimals may use a point or a comma. No idea? Click Fill in an example.

  2. Instant answer

    The answer appears as you type, with the most important intermediate values.

  3. See the working

    Under "How it's worked out" you see the steps, handy for checking your own calculation.

How matrices are subtracted

Subtract the numbers in the same position. For A = [[5, 6], [7, 8]] and B = [[1, 2], [3, 4]], A − B = [[4, 4], [4, 4]]. Note that A − B is not the same as B − A: every sign flips.

Both matrices need the same size. Fractions are allowed and the result is exact. To add, use the matrix addition calculator.

A 2 × 3 example

A B A − B
1 0 2 2 5 −2 −1 −5 4
3 −1 4 0 1 1 3 −2 3

Each entry is the difference of the entries in the same position: 1 − 2 = −1, 0 − 5 = −5, 2 − (−2) = 4.

Differences between data sets

Subtracting is how you compare two tables of the same shape: this year's figures minus last year's, a measured grid minus a prediction, or one image minus another to see what changed. Positive entries are increases and negative entries decreases, so the signs carry meaning. Combine with matrix addition to rebuild the original: (A − B) + B = A.

Next steps

Whether a matrix can be inverted depends on its determinant, which you can calculate with the determinant calculator.

Frequently asked questions

Is A − B the same as B − A?

No. Swapping them flips every sign: if A − B has the entry 4, then B − A has −4 in the same position.

What size must the matrices be?

The same. Both need the same number of rows and columns, and the calculator says so when they differ.

How do I subtract a matrix from itself?

You get the zero matrix, with only zeros, because every entry minus itself is 0.

Is subtracting the same as adding the negative?

Yes. A − B = A + (−B), where −B has every entry of B with its sign changed.