CHAPTER 03.05: BINARY OPERATIONS: Multiplying two matrices Theory
In this segment we will talk about how do we multiply 2 matrices. So two matrices A and B can be multiplied as A times B. Because we can have multiplication like B times A also, but limiting it to multiplying it to A times B under what circumstances can we multiply B by A or multiply A by B is if the number of columns number of columns of A is same as number of rows of B. So only if the number of columns of A is same as the number of rows of B only then can you multiply it so letís see what that means.
So if I have an A matrix and I have m rows and p columns - †so I gt m rows and p columns of A. Then if I have the B matrix, only if this one has p rows, is this matrix multiplication defined and then this can have any number of columns, n columns. So the number of columns of A has to same as the number of rows of B and the resulting matrix which we call - I suppose - the C matrix will have this many rows and this many columns. So thatís how we are at least able to say whether the matrix multiplication is allowed.
Now how do we find out individual elements of a C matrix is given by a summation so ijth element of C will be given by the summation k is go to one to p, which p is the number of columns of A or the number of rows of B A ik bkj. †So you want to find the ijth element. What you have to do is you have to take the ikth elements where k ranges from 1 to p and the kjth element of B k - again ranges from 1 to p - and do this product. And then you add all of those products to be able to get C ij. So what that basically also means is that if we expand this we will get Ai1 B1j plus Ai2 B2j all the way up to Aip Bpj. So what you are able to see is that all these elements which are taken off the A matrix letís suppose are in the ith row. The column number is changing and then the elements which are taken from B are all in the jth column and the row number is changing so thatís how we would find out what the Cij element will be.
This can be also viewed as that as if we are taking as we just said that hey we are taking the ith row of A; and then we are looking at the jth column of B. So we could be saying that - hey Cij is that we take the a in the row in the ith row Ai1 all the way up to Aip. And then what we are going to do is we are going to multiply by column of the B matrix which will be the jth column so B1j all the way up to Bpj. So we are taking the ith row of A and taking the jth row of B and we are going to find this product. So again what we are finding out is this the 1 row and p columns and this one is the p row and 1 column; and this will result in a 1 by 1 um in a 1 by 1 matrix which is a scalar. And thatís the one which will be corresponding to the Cijth element. So you can either view it as this summation right here or you can look at it as a dot product of these two vectors. And thatís the end of this segment.