This video is part 4 in a 6 part series on matrices and matrix math. None of these videos
are for any particular program. This video is over matrix multiplication. There are 3
main rules of matrix multiplication. When you are multiplying two matrices they do not
have to be the same size, the inner dimensions of the sizes must agree and the size of the
resulting matrix is the outer dimensions of the originals. Let me demonstrate what I mean.
Let's say you have a matrix "A" which is a 3 by 2 and you have a matrix "B" that is a
2 by 6. They are obviously not the same size but if you are going to multiply A * B you
have a 3 by 2 and a 2 by 6. Rule number 2 is that the inner dimensions must agree. As
you can see here the inner dimensions are both 2. This means they are able to be multiplied.
Rule number 3 says that the size of the resulting matrix is the outer dimensions of the originals.
In this case our originals are 3 by 2 and 2 by 6 so our answer matrix is going to be
a 3 by 6. Even if we do happen to have 2 matrices that are the exact same size such as 3 by
3 and 3 by 3 it does not mean that a multiplication of "C" times "D" is going to be equal to a
multiplication of "D" times "C". This is much different from any other multiplication. The
order in this case does matter. Although you would end up with a same size matrix no matter
which way you multiplied them. As an example we are going to multiply the two matrices
above. "A" is a 3 by 2 and "B" which is a 2 by 4. In this case the inner dimensions
do agree and our resulting matrix is a 3 by 4. Multiplication between two matrices in
this manner is much different from regular multiplication. Still let's start by making
space for our final matrix. Each element of this new matrix is calculated individually.
To calculate element "AB" of 1,1 which is this first spot you have to calculate the
first row of "A" and the first column of "B". If we write those down here the first row
of "A" equals 10 9 and the first column of "B" equals 1 4. For "AB" of 1,1 we calculate
it by 10 times 1 plus 9 times 4. This ends up being 10 plus 36 which is 46. The reason
we did this is because of the way these matrices are being calculated. For the multiplication
of "AB" to have one number in this first element we need the entire row of "A" and the entire
column of "B". Calculating it we have to multiply the first element of the first row of "A"
and the first element of the first row in "B" which is 10 and add to it the second element
in "A" and the second element in "B" to get the 46. For the next spot "AB" of row one
column two we need to get row one of "A" and column two of "B" since this is in row one
column two of "AB". Row one is still 10 9 and column two is 9 8. To multiply these together
for "AB" 1,2 it is 10 times 9 plus 9 times 8. That is 90 plus 72 which is 162. This number
is taken and placed here. You have to do that for every single element in "AB". Imagine
if you had an even larger matrix. Let' say you are multiplying an 8 by 3 with a 3 by
12. Your final matrix would end up being 8 by 12. That would be extremely tedious to
calculate by hand. These two matrices were 3 by 2 and a 2 by 4. Normally you would be
able to switch multiplication around and multiply it the other direction but in this case if
you try to calculate "B" times "A" the inner dimensions do not match so you would not even
be able to begin to calculate this. Even if you did have two square matrices though such
as having "C" and "D" each 3 by 3 and your resulting matrix is a 3 by 3 because "C" and
"D" are most likely different matrices if you were to reverse the multiplication you
would most likely end up with a different matrix. There are two special types of multiplication.
The first type is when you multiply a square matrix with its identity. If you have a square
matrix such as a 3 by 3 and you multiply it by the identity you would get back the same
3 by 3 matrix. If you had the square matrix A which is still the 3 by 3 and you multiplied
it by its own inverse what you would get back instead is the identity matrix. Inverse however
will be covered in the final video of this series.