Lesson finished
Unlock all 43 lessons of Linear AlgebraFull course ₹40,000 · paid
Matrix Addition, Subtraction and Multiplication Rules
A free lesson from Skill-Lync's Linear Algebra course, on Grow by Skill-Lync · Last updated 16 Nov 2026 · Session: “Week 1 Session 3”
What will you learn in this free Linear Algebra lesson?
The instructor shows that addition and subtraction need matrices of equal dimension and work element by element. For multiplication, the lesson shows that columns of the first must equal rows of the second, works a 3 by 3 row-by-column example, and shows with a 2 by 3 and 3 by 1 pair that A times B differs from B times A.
- Dimension rule for adding matrices
- Element-wise addition and subtraction example
- Row-by-column multiplication procedure
- Why matrix multiplication is not commutative
What comes after lesson 3?
Later in Skill-Lync's Linear Algebra course (paid): lesson 4, Week 1 Session 4; lesson 5, Week 2 Session 1 Part 1; lesson 6, Week 2 Session 1 Part 2. The full course has 43 lessons (20 h 5 min of video); see the course overview or its price and syllabus.
Lesson transcript
Machine transcript of the lesson audio (lightly cleaned). Technical terms may contain errors; the video is the reference.
Hello, everyone. Welcome back to the third video of the first week of linear algebra course. So, in the last time we were discussing about matrix, we got to know that matrix is basically a two-dimensional array. And we also noticed that we usually denote it using capital letters. And then we have its dimension, let's say M by N, where M is the number of rows and N in the number of columns. And also, we can write it either using this square bracket notation, or we can write it using the rounded bracket notation, whichever is preferable.
You also have seen that A, I, J are simply the elements where I and J are the number of rows and the number of columns, respectively. That means the first row, first column element will be A11, similarly A12, up to A1N, and so on, A21, and then the last one would be AM1, and so on, up to AMN. And as M by N, that means M rows and N columns, so basically, we simply have these elements. Now, we also had come across different types of matrices.
We got to know about what a transpose of a matrix is, we got to know about different other matrices, square matrix and rectangular matrix. We also got to know about a special kind of matrix, identity matrix, and another special kind of matrix, where the matrix, if you transpose it, it becomes same as its transpose, which we call a symmetric matrix. Okay, so now, we are going to move on from that, and we are going to look into the matrix arithmetic. That means what happens if we take two matrices, A and B, and if we can add them, subtract them, if we can multiply them, so mainly these three things.
Okay, so let us start with it. First of all, for matrix arithmetic, more specifically, first we are going to talk about matrix addition and subtraction. For matrix addition and subtraction, the first thing is that the dimensions of the matrices must be same. That means if we have one matrix A of dimension M by N, that means M rows and N columns, and we have another matrix B of dimension M by N as well, only in this case we can add or subtract them. But, if we have a matrix A of M by N and another matrix B of K by L and if N and if N and L are not same, so M is not equals to K and N is not equals to L, in this case we cannot add or subtract these two matrices from each other.
Okay, now that is the first criteria. Now the question is, how do we actually perform the addition and the subtraction? So as you can see, on the left hand side of the page, we have simply considered two matrices, A and B. Both are of dimension 3 by 3. The first matrix A is of dimension 3 by 3 with elements A1, B1, C1 in the first row, A2, B2, C2 in the second row, and A3, B3, C3 in the third row. Similarly, the matrix B is also of order 3 by 3 or dimension 3 by 3.
In the first row, we have X1, Y1, Z1, second row has X2, Y2, Z2, and then the third row has X3, Y3, Z3. So, whenever we are adding these two matrices, A plus B, in that case, what happens is that the first row, first column element of the matrix A gets added to the first row, first column element of the matrix B. That means A1 plus X1. Similarly, the first row, second column element of the matrix A will get added to the first row, second column element of the matrix B.
A3 plus X3, and so on, C1 plus Z1. Similarly, A2 plus X2, B2 plus Y2, and C2 plus Z2. And same will happen for the third row, that means A3 plus X3, B3 plus Y3, and C3 plus Z3. Okay, so the fundamental concept here is that as the dimension of the matrix A and B are same, whenever we are adding them, they get added component-wise, or more specifically, position-wise. The position that they are having inside the matrix, the position of their rows and columns, that means IJ.
Similarly, it happens for subtraction as well. So, if we have A minus B, we simply have A1 minus X1, B1 minus Y1, C1 minus Z1 in the first row. Same for the second row, and the third row, and so on. So, let us quickly look at one example. Let us consider a matrix A is, let's say, 1, 2, minus 1, 3, 1, 0, 4, 5, 2. Another matrix B we have is, let's say, 0, 1, 0, 2, 1, 0, and 0, 3, 1. In this case, if we add A and B, if we do A plus B, they get added component-wise.
So, first of all, we need to verify that A is a 3 by 3 matrix, B is also a 3 by 3 matrix. They are same dimension, that means we can add them. So, this one will get added to this, 0. So, we get 1 plus 0, which is 1. Similarly, 2 will get added to 1, which will give us 3, minus 1 will get added to 0, giving us minus 1, and so on for the other components. So, 3 plus 2 will give us 5, and here 1 plus 1 will give us 2, 0, 4, 8, 3.
Another thing, we can see that, after matrix addition, they also can preserve the dimension of the matrices. That means, we have A and B matrices of dimension 3 by 3, and whenever we are doing A plus B, we also have dimension 3 by 3. Okay. Similarly, we can do the subtraction as well, but the idea is same. We just have to subtract, component-wise, the elements of B from the elements of A. Okay. Now, this was matrix addition and subtraction. Now, what happens? When we are about to multiply to matrices, and what are the criterias for that? So let us look into that now. So the matrix multiplication is a bit more complicated than matrix addition.
So, the first thing is that if we have a matrix A of dimension M by N, and another matrix B of dimension P by Q, we can multiply them, but the criteria is that we can multiply A and B, or rather I should say A by B if and only if N is equals to P. That means the number of columns of A is equals to the number of rows of the matrix B. If and only if this criteria is satisfied, we can multiply the two matrices.
Now, if we multiply these two matrices, so A, M by N, and B, P by Q, now as we can see that N is equals to P, simply we can replace P by N, so we have B, N by Q. In that case, what will be the dimension of the product matrix? So, the dimension of the product matrix will simply be the number of rows of the first matrix, that is M, by number of columns of the second matrix, that is Q. Okay, so this is one of the criteria we always have to keep in mind.
So, let us quickly look at an example. So, let us consider a matrix A is equals to, let's say, 1, 2, 3, minus 1, 0, 1, 3, 1, 0. As we can see, it is a 3 by 3 matrix. We have another matrix B, let's say, 1, 0, 1, 2, 1, 0, and 3, 1, 3. Okay, this is also another 3 by 3 matrix. So, what happens if we try to multiply A by B? First thing is that we can see that the number of columns of the first matrix A is equals to the number of rows of the second matrix B.
When that is verified, that means we can multiply A by B. Another thing to notice is that the product matrix, whatever it will be, will have a dimension of 3 by 3. That means the number of rows of the first matrix by number of columns of the second matrix. Now, the question is, how do we do the multiplication? So, we do row by column, okay? So, this is the idea of multiplication, row by column. Another idea is that we are going to use this row, multiply it first to this column, that two are component-wise, and then we add them all.
What I mean by that is, our first element is going to be 1 multiplied to 1 plus 2 multiplied to 2 plus 3 multiplied to 3. And then, our second element will be 1 plus 3. And then, our second element will be 1 plus 2. First row by second column. As we can see, this was our 1, 1 element. Our next element will be 1, 2. That means, first row, second column. That's why, first row by second column. Okay. So, this will be 1 multiplied to 0 plus 2 multiplied to 1 plus 3 multiplied to 1.
Similarly, the first row, third column element will be simply this by this. That means, 1 by 1 plus 2 by 0 and plus 3 by 3. Likewise, in the second row, the first column element will be, so, second row and first column. So, therefore, minus 1 by 1 plus 0 by 2 plus 1 by 3. And similarly, second row, second column, it will be simply minus 1 by 0 plus 0 by 1 plus 1 by 1 and so on. Now, if we just find the rest of the elements and we just multiply and add them, what we get is now AB turns out to be simply 14, 5, 10, 2, 1, 2 and 5, 1, 3.
Another thing you can notice that, like I said previously, that they preserve the row of first matrix and column of second matrix. So, you can see that this product matrix is of dimension 3 by 3. Okay, another important question that we might have to ourselves is, what happens if we try to multiply the matrices other way around? So, if we are able to do AB, can you also do BA? First thing is that this property is called commutativity. That means, if A can be multiplied by B and B can also be multiplied by A and they give the same result, then what you get is basically a property that is called commutativity.
But, matrices are not commutative. So, let us look at an example to verify that fact. So, matrix multiplication is not commutative. That means, I dot E means, that means, A cross B is not equals to B multiplied to A. Okay, first of all, they may or may not exist as well. So, let us consider another example. Let us say that the matrix A is 1, 2, 3 in the first row and minus 1, 0, 1 in the second row. As you can see, this is simply a 2 by 3 matrix as it has 2 rows and 3 columns.
Similarly, we can consider another matrix B. Let us say it is simply 1, 0, 1. Okay, as you can see, it has 3 rows but, Only one column. Okay. So, by the rule, we can multiply this as we simply have the number of columns of the first matrix equals to the number of rows of the second matrix. Therefore, the product matrix will be of dimension 2 by 1. So, let us just find out A multiplied by B in the same way we had done for the previous one. So, again, it will be row by column. So, in the first element, we get 1 multiplied to 1 plus 2 multiplied to 0 plus 3 multiplied to 1.
And in the second row, we will have minus 1 multiplied to 1 plus 0 multiplied to 0 plus 1 multiplied to 1. Therefore, we get 1 plus 0 multiplied to 1. Therefore, we get 1 plus 0 plus 3 in the first row and minus 1 plus 0 plus 1 in the second row, which gives us 4 in the top row and 0 in the bottom row. As you can see, it is of dimension 2 by 1. It has two rows, one column. Therefore, it satisfies the property.
Now, can we find B A? First of all, B is of order 3 by 1 and A is of order 2 by 3. As we can see that 1 is not equal to 2. We simply can't multiply. Therefore, this is verified that for in general, A multiplied to B is not equal to B multiplied to A. Now, in this case, we saw that B A does not exist. But, in some cases, they may exist, but they won't be the same. You will get to see that more often when we keep doing the other things whenever we will be doing matrix multiplication.
For other purposes, you will get to see that this property is verified. Okay. Now, when we have learned about matrix multiplication, the next thing that comes to the mind is a map that takes this matrices to a number. Now, that particular map has a name and therefore, to sum up the idea of matrix multiplication, we can simply just, we'll have a quick go through over the concept again. So, basically, again, if we have the matrix, let's say X of dimension M by N and let us write its element by X11, X12, up to X1, N.
Similarly, it will be in the second row, X21, X22, up to X2, N, and so on. For the last row, it will have XM1, XM2, and XMN. Clearly, it is a M by N matrix. Similarly, we can consider another matrix such that it can be multiplied to X from the right. That means its number of rows will be same as the number of columns of X. So, it will be N by something. Let us take that something to be Q. And let us call the elements R in terms of Y.
So, Y11, Y12, up to Y1Q, and similarly, in the second row, Y21, Y22, up to Y2Q, and it has N rows. That means the first element of the last row will be simply YN1, YN2, and simply the last element will be YNQ. Okay. Now, as you can see, they can be multiplied because this is equals to this, and their dimension will be after multiplication. So, that means let us call XY is some other matrix, Z, and their dimension, as can be seen, would be M by Q.
Okay. So, let us call X and Y's in terms of X and Y's, the small X's and the small Y's. Now, whenever we are trying to think of it in a computational way, how the programs work, we simply have to think of the indices. So, basically, we'll have to run a for loop for each of the lists of the lists, X and Y, and then we have to simply multiply them and add them up to get each of the small Z's. Okay. And, the number of rows for X is I, for Y, the number of columns is Z, that's why Z has IJ.
That means the position of Z will be the IJth position in the bigger matrix. Now, something we have to remember here that up until where these indexes, the indices I and J, run. So, as we do row by column, so, for the first matrix, there are simply M rows, right? So, for that reason, I will be from 1 up to M, because it has M rows. And, for the second matrix, the number of columns are Q. So, that is why J will run from 1 up to Q.
And, what about K? So, K is going to be N, from 1 up to N, because we can simply see that X is an M by N matrix and Y is an N by Q matrix. So, this N will define the indices of K. Now, this is a very important concept, and it will come very handy when we will be using it in terms of coding aspect. Okay. So, we have learned about matrix multiplication and other matrix arithmetic, like addition and subtraction. But, what happens about matrix division?
Can we actually divide a matrix by another? So, I see you in the next one.