MatrixCalc

Matrix addition and subtraction calculator

Add or subtract two matrices of the same size, up to 50×50, entry by entry — with the intermediate sums shown so you can check your own working.

Matrix A
rows: 3
cols: 3
Matrix B
rows: 3
cols: 3
Operations
Result
Pick an operation to see the result here. Errors will show up in this area.

Tips: adjust sizes (max 50×50). For A×B, cols(A)=rows(B). det/inverse/trace/power require square matrices.

React, Tailwind & shadcn/ui. No external math deps. — English

Addition and subtraction are the two operations on matrices that behave exactly as you would hope: entry by entry, no surprises. Fill in A and B above and press A + B or A − B.

The one rule

Both matrices must have the same dimensions. A 2×3 can be added to another 2×3 and to nothing else — not to a 3×2, not to a 2×4. The result keeps those dimensions, and the entry in each position is simply the sum of the two entries in that position.

Because it works positionally, matrix addition inherits the arithmetic you already know: it is commutative, so A + B = B + A, and associative, so the grouping of a three-way sum does not matter. This is a genuine contrast with multiplication, where A·B and B·A are usually different matrices and can even have different shapes. Subtraction is addition of the negative: A − B is A + (−1)·B, so it is not commutative, in the same ordinary way that 5 − 3 differs from 3 − 5.

Worked example

12
34
+
56
78
=
68
1012

Each position is handled independently: 1 + 5 = 6, 2 + 6 = 8, and so on. The zero matrix plays the role zero plays for numbers — adding it changes nothing — and A − A returns it.

Common mistakes

  • Adding matrices of different sizes. There is no convention for padding the shorter one; the operation is simply undefined.
  • Adding a scalar to a matrix. A + 3 has no meaning. To add 3 along the diagonal, add 3·I; to add it everywhere, add a matrix of threes.
  • Expecting det(A + B) = det(A) + det(B). Determinants do not distribute over addition, and there is no useful formula relating the three.
  • Mixing up the order in a subtraction. A − B and B − A differ by a sign in every entry.

Frequently asked questions

Can I add matrices of different sizes?
No. Addition and subtraction require identical dimensions, because they work position by position and every position must exist in both matrices.
Is matrix addition commutative?
Yes. A + B = B + A always, since it reduces to adding ordinary numbers in each position. Multiplication is the operation where order matters.
How do I subtract matrices?
Subtract entry by entry, in the same positions. Equivalently, multiply the second matrix by −1 and add.
What is the zero matrix?
The matrix with every entry zero. It is the additive identity: A + 0 = A, and A − A = 0.

Want the full explanation? Read the guide: How matrix multiplication works

Other calculators