Matrix Addition & Subtraction
Matrices of the same dimensions are added or subtracted by combining matching entries position by position. Enter both matrices and choose the operation; the calculator returns the resulting matrix.
The operation that keeps ordinary arithmetic's habits
Matrix addition is the operation that behaves exactly as you would guess. Two matrices of the same shape are added by adding the numbers in matching positions, and the result has that shape too. There is no rule to remember and no order to get wrong.
That makes it worth stating what addition does not share with matrix multiplication, which is almost everything. This calculator adds or subtracts two matrices entrywise and shows the result.
Matrices are introduced alongside a warning that they do not behave like numbers, and for multiplication that warning is fully earned. Addition is the exception: it is commutative, it is associative, it has a zero, and every matrix has a negative. All the intuitions from ordinary arithmetic transfer intact.
The one thing that does not transfer is that addition is not always defined. Two numbers can always be added; two matrices can only be added when their shapes match exactly, and that is the single condition to check.
How to use this calculator
- Enter matrix A Commas between entries within a row, semicolons between rows. A 2×2 matrix is written as 1, 2; 3, 4, and whitespace around the separators is ignored.
- Enter matrix B in the same format It must have the same number of rows and the same number of columns as A. A mismatch is rejected with an explicit message rather than being padded or truncated.
- Choose add or subtract Addition combines matching entries; subtraction takes each entry of B away from the matching entry of A. Order matters for subtraction and not for addition.
- Read the result It has the same shape as both inputs. Every entry depends only on the two entries in the same position, so any single entry can be checked in isolation.
The formula, and where it comes from
(A + B)ᵢⱼ = Aᵢⱼ + Bᵢⱼ (A − B)ᵢⱼ = Aᵢⱼ − Bᵢⱼ
The definition is one line because the operation genuinely is that simple. Position by position, the entries are combined, and nothing from any other position is involved — no sums over an index, no dot products, no dependence on the order of the factors.
That independence is what makes the shape condition necessary. An entry of the result needs both of its inputs, so a position present in one matrix and absent from the other has nothing to combine, and the operation is undefined rather than partially computable.
Subtraction is implemented as addition with the second matrix negated rather than as a separate rule, which is why the two operations share every property except commutativity — and lose that for the same reason ordinary subtraction does.
Because the arithmetic is entrywise, whole-number inputs give whole-number outputs exactly. There is no accumulation of rounding error, since no entry is ever multiplied or divided.
What each input means
- A First matrix — form field “Matrix A”
- Entered row by row. Its dimensions determine the required dimensions of B and of the result.
- B Second matrix — form field “Matrix B”
- Must match A exactly in both dimensions. Entries may be negative or fractional.
- op Operation — form field “Operation”
- Addition or subtraction. Subtraction is always A minus B, so swapping the two matrices negates every entry of the result.
Worked examples
Every number below is produced by the same calculation engine the tool above runs. Nothing here is typed by hand, so the walkthrough cannot drift from what you get when you enter the same values yourself.
Adding two 2×2 matrices
Add the matrix with rows (1, 2) and (3, 4) to the one with rows (5, 6) and (7, 8). Four independent additions, one per position.
Inputs Matrix A = 1, 2; 3, 4, Matrix B = 5, 6; 7, 8, Operation = add
- Matrix A [[1, 2], [3, 4]]
- Matrix B [[5, 6], [7, 8]]
- Add entrywise Combine matching entries position by position.
- Result [[6, 8], [10, 12]]
Result [[6, 8], [10, 12]]
Each entry of the result is the sum of the two entries directly above it in the same position. Nothing in the top-left corner depends on anything in the bottom-right, which is exactly what distinguishes this from multiplication.
Swapping the two matrices would give an identical result. Addition is commutative for matrices just as it is for numbers, which is not true of the product.
Subtracting, where order matters
Subtract the matrix with rows (1, 2) and (3, 4) from the one with rows (9, 8) and (7, 6).
Inputs Matrix A = 9, 8; 7, 6, Matrix B = 1, 2; 3, 4, Operation = subtract
- Matrix A [[9, 8], [7, 6]]
- Matrix B [[1, 2], [3, 4]]
- Subtract entrywise Combine matching entries position by position.
- Result [[8, 6], [4, 2]]
Result [[8, 6], [4, 2]]
Every entry of the second matrix is taken away from the matching entry of the first. Reversing the two would negate every entry of the answer, which is the matrix version of the fact that subtraction of numbers is not commutative either.
Subtracting a matrix from itself would give the zero matrix — the additive identity, and the matrix that leaves any other unchanged when added to it.
Reading the result
The shape never changes
Adding or subtracting returns a matrix of the same dimensions as the two inputs. Any operation that changes the shape of a matrix is a different operation, and multiplication is the usual one being confused with this.
What entrywise means in practice
Each output entry can be verified on its own, without recomputing anything else. That is worth exploiting when checking work by hand: a disagreement is localised to one position rather than to the whole calculation.
The properties that carry over
Addition of matrices is commutative and associative, the zero matrix acts as an identity, and every matrix has a negative. Those are the ordinary arithmetic rules, and unlike with multiplication they hold without qualification.
When you would use this
Combining measurements on the same grid
Two tables of readings over the same rows and columns — sales by product and region across two months, say — are added by position, and the sum is another table of the same shape.
Taking a difference between states
Subtracting one matrix from another gives a change matrix, whose entries are the increases and decreases position by position. Signs then carry the direction of each change.
Assumptions and limitations
What this calculator assumes
- Both matrices have identical dimensions; nothing is padded, truncated or broadcast.
- Entries are real numbers, entered with commas between columns and semicolons between rows.
- Subtraction is A minus B in the order the fields are given.
- The result has the same dimensions as the inputs.
Where it stops being the right tool
- No scalar multiplication, so scaling a matrix before adding must be done by hand.
- Two matrices at a time: a longer sum has to be built in stages.
- No multiplication, transpose, determinant or inverse — each has its own tool.
- Only rectangular numeric matrices; symbolic entries are not accepted.
Common mistakes
Trying to add matrices of different shapes
Why it happens. Multiplication only requires the inner dimensions to agree, so it is easy to carry that laxer rule across. Addition requires both dimensions to match exactly.
How to avoid it. Count rows and columns in each before entering. A 2×3 and a 3×2 can be multiplied but never added, which is the pair that most often causes the confusion.
Combining entries across positions
Why it happens. Matrix multiplication trains the habit of pairing a row against a column, and that habit can survive into an operation where it does not belong.
How to avoid it. Work position by position. The entry in row 2, column 1 of the result depends only on the entries in row 2, column 1 of the inputs.
Reversing the operands when subtracting
Why it happens. Addition is commutative, so the order of the fields feels unimportant, and that carries over to subtraction where it is not.
How to avoid it. The first field is the one being subtracted from. If every entry of your answer has the opposite sign to the tool's, the two were entered the other way round.
Key terms
Frequently asked questions
When can matrices be added?
Only when they have identical dimensions — the same number of rows and the same number of columns. The operation is entrywise, so every position in one matrix needs a counterpart in the other.
How is matrix subtraction defined?
Each entry of the second matrix is subtracted from the matching entry of the first. It is equivalent to negating the second matrix and adding, which is how it is implemented.
Is matrix addition commutative?
Yes, always. Adding matrices is adding numbers position by position, and addition of numbers is commutative. This is a genuine contrast with matrix multiplication, where the order of the factors usually changes the product.
Can I add a 2×3 matrix to a 3×2 one?
No. They contain the same number of entries but not in the same arrangement, so there is no correspondence between positions. That pair can be multiplied, which is often the source of the confusion.