A matrix (plural matrices) is just an array or table of numbers. What would it mean to add two tables together? Well you’re about to find out! In this short article, we’ll discuss how to add and subtract matrices.
Image by Andrey Popov
What Is a Matrix?
First, let’s talk about what a matrix is.
A matrix is a rectangular array of numbers.
Each horizontal line of numbers in a matrix is a row. Each vertical line is a column. We often call the individual numbers the entries of the matrix.
If there are m rows and n columns in the array, then we say that the dimensions of the matrix are m × n. This will become important because only matrices having the same dimensions can be added or subtracted.
How to Add and Subtract Matrices
There are two essential rules for adding matrices together.
- You can only add two matrices that have the same exact dimensions. So, you can add two 3 × 4 matrices together. But you can’t add a 3 × 4 matrix to a 4 × 3 matrix. (The order of the dimensions matter too!)
- Add corresponding entries. That is, the upper-left entry of the first matrix has to be added to the upper-left entry of the second matrix, and so on.
To subtract two matrices, A – B, follow these steps:
- Change the operation to an addition, A + (-B) by converting every entry of B to its opposite (flip signs).
- Add the matrices, using the method above.
(You could instead just subtract the corresponding entries to compute A – B, but then you’d have to keep track of subtracting negative amounts sometimes. I just find it easier to flip every sign first and then add. It amounts to the same thing algebraically.)
Consider the following three matrices:
a) A + B
b) A + C
c) B – A
d) C – C
a) First check the dimensions. Both A and B have two rows and two columns. Since they are both 2 × 2 matrices, they can be added together. Remember to add corresponding entries.
b) This time, when we check dimensions, we find a mismatch. A is 2 × 2, but C is 3 × 2. Therefore, the sum does not exist. In other words, there’s no answer.
c) Just as in part a, both matrices have the same dimensions. So we’re allowed to subtract them. Don’t forget to flip the signs of the second one!
d) Obviously C has the same dimensions as itself, so the rules say that you may subtract.
Because all of the entries are the same, when you subtract C — C you end up with zero (0) in every spot.
(By the way, any matrix having nothing but 0 in every entry is called a zero or null matrix.)