| CHAPTER 03.06: BINARY OPERATIONS:
  Multiplying two matrices Example In
  this segment we will talk about an example of how to multiply two matrices. So
  let’s suppose somebody says - give you two matrices - says given the matrix A
  as 5, 2, 3, 1, 2, 7 and the B matrix is given as 3, -2, 5, -8, 9, -10 and
  says find C where C is defined as A multiplied by B. Now the first thing
  which you have to do before you start multiplying two matrices is to check
  for the order of the A and the B matrix. Here, so this one is two rows and
  three columns and this one is three rows and two columns. So you have to
  check if the number of columns of A is same as the number of rows of B - which
  it is. So that means that A times B can be A and B can be multiplied as A
  times B. If this was not the case, if the number of columns here was not the
  same as the number rows here, then you would not be able to multiply A by B. Now
  the resulting matrix. So this is a two by three matrix here, that’s a two by
  three matrix here, the resulting -sorry three by two matrix - so the
  resulting matrix will be a two by two matrix because it will depend on the
  number of rows here and the number of columns here. And that’s the resulting
  size of the C matrix right there. So let’s suppose - let’s go and find out
  what C12 is. So if C12 has to be found out, how do we go about doing that?
  C12 will be equal to what? So if I go from the definition of my Cij, which is the ith row jjth element of C, it is given by summation k; is going
  to one to p a I k b kj. So I want to find the ith
  row jth column of C is given by this summation
  right here so now I know that Kp is - p is the
  order of the - is the number of columns which you have in the A matrix or the
  number of rows, which you have in the B matrix. It is the common number of
  number which we have which we talked about in order for the multiplication to
  proceed. So
  in this case K is equal to one and P is the number of columns of A or the
  number of rows of B, which is three, and you have A I is one and J is two. So
  the A1 K B K which is three, which is two - so that’s what we have for J. So
  now we have the summation; now the only thing which we have here is K so let’s
  find the summation, which we get as A11B12 because I am putting K equal to
  one. Then ill add A12B22 because I’m putting K equal to two now plus A13B32. So
  now I’m going to substitute the values of the corresponding values of A and B,
  which I see in this form, see in this summation here and I should be able to
  get the value of C12. So this is C12, so let’s see what A11 is 5 B12 is;
  first row second column is -2 plus A12 is 2 B22 is -8 and A13 is 3 and B32 is
  -10. So this value here, once you do the summation, you’ll get -56. So that’s
  the value of C12.  Now
  what I also wanted to tell you that C12 can be - also be - which is exactly
  the same thing as this here as that what I need to do is to find the dot
  product of this vector because it’s the first this the C12. So I take the
  first row of the first matrix and the second column of the second matrix. So
  I take the second column of the second matrix and I find the dot product
  between those two vectors. So what that means is that in order to find the
  dot product C12 I’ll take the first row of the A matrix and multiply it to
  the second column of the second matrix -2, -8 and -10. So if I do this matrix
  multiplication here using the one row three columns three rows one column. So
  look at this - this is a one row three columns and this is a three row one
  column and you only get a one row one column, which is just one scale of
  numbers, which you are going to get its 5 times -2 plus 2 times -8 plus 3
  times -10. And this number here is -56. So
  it is exactly the same formula but a different way of quickly looking at it
  and getting what the matrix multiplication is you can follow the same
  procedure, which I just mentioned here, to find the other elements of the two
  by two matrix and they will turn out to be 52, -56, 76, -88. And if you
  follow the same procedure either by finding the dot product of two vectors or
  by using the summation formula itself, you’ll be able to find the other
  elements of the C matrix. And that is the end of this segment |