Transcript for:
Matrix Multiplication Overview

in this video we're going to focus on multiplying matrices so let's say if we have matrix a and it has the elements 2 5 and 6 and matrix b contains the elements 3 4 and negative 5. so let's find the product of a b and b a now in math let's say if we multiply 3 times 5 is 15 and 5 times 3 is also 15. when dealing with matrices the order matters a b and b a they will not be the same so keep that in mind a b tells us that we need to take matrix a and then multiply by b in that order b a tells us that we need to start with matrix b and then multiply by a so the order matters before we begin multiplying let's talk about the order of each matrix what is the order of matrix a matrix a has one row and three columns so it's a one by three matrix the way you write the order is you start with the rows and then you multiply by the columns so matrix b has three rows and only one column so it's a three by one matrix so if we multiply a by b what do you think the order will be so a times b so a is a one by three matrix and b is a three by one matrix in order to multiply these two matrices the columns in the first matrix has to equal the number of rows in the second matrix so make sure you understand that and the order of matrix a b is going to be the product of these two numbers which do not have to be the same so the order of a b is going to be a one by one matrix so therefore we should have one number in this matrix only it could be like 7 12 15 who knows but the order of the matrix is basically the product of those two now what about b times a what is the order of that matrix so we take matrix b and multiply by matrix a what should we get so matrix b is a three by one matrix and matrix a is a one by three matrix so we have to make sure that the number of columns in the first matrix is equal to the number of rows in the second matrix so which we do have so we can multiply these two matrices now the order of the matrix is going to be 3 by 3. so the order for matrix b a it's going to be a three by three matrix and for a b we said it's going to be a one by one matrix now let's confirm that so let's get rid of some stuff so let's start by multiplying matrix a by matrix b so the way you do it is you take all the elements in the first row and then multiply it by all the elements in the first column so it's always going to be row times the column and then you add the products together so it's always going to be r times c so we're going to take this one it's in the first row first column and multiply it by that element in the first row and the first column so it's going to be 2 times 3 and then we're going to multiply these two so it's going to be 5 times 4 and then six times negative five and this will give us only one element so because we took the elements in the first row and multiplied it by the elements in the first column we're going to get a single entry in the first row first column so it's going to be a one by one matrix now two times three is six five times four is twenty six times negative five that's negative thirty and six plus twenty is twenty six twenty six minus thirty is negative four so we can see that a b is a one by one matrix it has one row and only one column and so it's equal to negative four now let's multiply b by a so let's show that it's going to be a three by three matrix so we're going to start with b so remember it's row by column so the first row times the first column so that's going to be three times two and that entry is going to go in the first row first column so three times two is six so now we're still on row one but now we have to multiply by column two so that's going to be three times five so it's going to be in the first row but second column so that's going to be 15. and then we need to multiply row one by column three so so it's going to be row by column so three times six is 18. next we're gonna move on to row two and then column one four times two is eight so that's going to go in the second row first column and then we're gonna have row two by column two so that's four times five and that's twenty and then it's going to be row two times column three and four times six is twenty-four so hopefully you're seeing the pattern of what we're doing here if not feel free to pause the video and rewind until you understand it and then it's going to be row 3 times column 1. so negative 5 times 2 is negative 10 and then row 3 times column 2 5 times negative 5 is negative 25 and then row 3 times column 3. 6 times negative 5 is negative 30. so as we could see a b and b a are clearly different and you can see that ba has three rows and three columns so it's a three by three matrix so hopefully this example gave you a good idea of how to multiply matrices let's work on another example so let's say that matrix a contains the elements 1 4 negative 2 3 5 and negative 6 and matrix b contains the elements 5 2 8 negative 1 3 6 4 5 negative 2 9 7 and negative 3. so go ahead and multiply a times b and also b times a and determine the order of these two products so what is the order of a b so what do you think the order is going to be so notice that a has two rows and it has three columns so matrix a is it's a two by three matrix it has two rows and three columns matrix b contains three rows and it has four columns so matrix b is a three by four matrix so notice that these numbers are the same the number of columns in matrix a is equal to the number of rows in matrix b so that means that we are allowed to multiply a by b these two numbers they must be the same in order for you to multiply the two matrices now the order of matrix a b is going to be 2 times 4 or 2 by 4. so it's going to have two rows and four columns now what about b times a what can we say about that so matrix b has three rows and four columns and matrix a has two rows and three columns so notice that these two numbers do not match they're different and in order to multiply b times a they must be the same so therefore b a does not exist we don't have to worry about that problem so let's focus on multiplying a by b so it's going to have two rows and four columns so let's start by multiplying row one by column one so it's going to be 1 times 5 and then it's going to be plus 4 times 3 and then plus negative 2 times negative 2. so you got to multiply these two first and then these two together and then those two it might be wise for me to perform the operation somewhere else so let me get rid of this i'm going to put the answers there so it's going to be 1 times 5 plus 4 times 3 plus negative two times negative two so this is gonna be five plus twelve plus four five plus twelve is seventeen seventeen plus four is twenty one so because we multiplied row one by column one we need to put this answer in row one column one so this is row one row two and this is going to be row column one two three and four now let's multiply row one by column two and that will produce an entry in row one column two so first we need to take one and then multiply it by two and then it's going to be 4 times 6 and then negative 2 times 9. so 1 times 2 is 2 4 times 6 is 24 negative 2 times 9 is negative 18. so 2 plus 24 is 26 26 minus 18 is 8. so let's place that entry in that slot now let's move on to row one column three and that's going to be an entry in row one column three so we're going to multiply one by eight and then four by four and then negative two times seven or you can write it as plus negative two times seven so one times eight is eight four times four is sixteen negative two times seven is negative fourteen now sixteen minus fourteen is two a plus two is ten so we get that answer now let's move on to the first row fourth column which will produce an entry in row one column four so it's going to be one times negative one plus four times five plus negative two times negative three so this is going to be negative one four times five is twenty negative two times negative three is plus six so twenty plus six is twenty six and twenty six minus one is twenty so hopefully by now you get the hang of it if not feel free to rewind the video so let's move a little faster so row two times column one that's going to be 3 times 5 plus 5 times 3 plus negative 6 times negative 2. so that's 15 plus 15 plus 12. 15 and 15 is 30 30 plus 12 is 42 so we need to put that there next we have row 2 times column two so that's going to be three times two plus five times six plus negative six times nine three and two is six five times six is thirty negative six times nine is negative fifty four now thirty minus fifty four is negative twenty four and six minus twenty four is negative eighteen now let's move on to row two times column three so it's going to be three times eight plus five times four plus negative six times seven so three times eight is twenty-four five times four is twenty negative six times seven is negative forty-two twenty-four plus twenty is 44 and 44 minus 42 is 2. now for the last entry we're going to multiply row 2 by column 4. so that's going to be three times negative one plus five times five plus negative six times negative three so this is negative three five times five is 25 and negative six times negative three is eighteen now negative three plus twenty-five is twenty-two twenty-two plus eighteen is forty and so now you know how to multiply two matrices together and as you can see we did get the two by four matrix as predicted so if you multiply a two by three matrix with a three by four matrix first you must see that these two are the same and then the order of the new matrix is going to be the number of rows of the first matrix times the columns of the second which we have here it's two rows and four columns you