section 1.3 matrices and matrix operations previously we explored using matrices as a way to solve systems of equations in an efficient and concise manner but matrices have many other uses that are far more general so we'll start this section by making a more general definition for a matrix we'll say that it's a rectangular array of numbers the numbers in the array are called the entries some examples of matrices are this guy over here where we have these three rows and these two columns so we also have this is an example of a matrix this is an example of a matrix and even this little guy over here where we just have one entry is an example of a matrix the size of a matrix is described in terms of its rows these horizontal lines and its columns these vertical lines in a size description the first number always denotes the number of rows and the second denotes the number of columns a matrix with only one row is called a row vector or row matrix and our matrix only one column is called a column vector or a column matrix so this is a row vector and this column vector and this is both notice this matrix has three rows and two columns so it's three by two this one is one row four columns so it's one by four this one is three rows and three columns so it's three by three this one has two rows and one column so it's two by one and this one is just one by one we will use capital letters to denote matrices and lowercase letters to denote numerical quantities thus we may write a equals this matrix or c equals this one notice we don't necessarily have to specify what the numbers are we could use a placeholder variable when discussing matrices it is common to refer to numerical quantities as scalars the entry that occurs in row i and column j of a matrix a will be denoted by a i j thus a general m by n matrix might be written as this so if we're talking about for example a 2 1 i look in the second row and the first column and i would find a 2 1 right there when a compact notation is desired the preceding matrix can be written as a aij we sometimes will just write a j without the m cross n actually more often than not if the size is obvious or we don't want to keep writing it notice this refers to the entire matrix not just the ijth entry we differentiate between that by putting these uh brackets over here notice this is not the same as just writing aij this guy just refers to a single entry inside here whereas this guy refers to the entire matrix a general one by n row vector a and a general m by one column vector b would be written as a equals this guy and b equals this guy a matrix a with n rows and n columns is called a square matrix of order n and the shaded entries a 1 1 a 2 2 a and n are said to be on the main diagonal of a two matrices are defined to be equal if they have the same size and their corresponding entries are equal so just the way you would think let's uh consider these matrices a b and c for what values of x the matrix is equal well notice we need all of these guys to match up if we want them to be equal so in order for all of them to match up we already have two equals two we have one equals one and we have three equals three we just need x to be five so if we put x equals five then that'll make a equals b uh notice a and c are different sizes this one has an extra extra column so it's three columns even though they're both two rows so these matrices will never be equal so a will never be equal to c for any x which means that because a is equal to b for x equals 5 b will never be equal to c for any x either if a and b are matrices of the same size then the sum a plus b is the matrix obtained by adding the entries of b to the corresponding entries of a and the difference a minus b is the matrix obtained by subtracting the entries of b from the corresponding entries of a matrices of different sizes cannot be added or subtracted so the way that you and subtract matrices is pretty much the way you would expect you look and see if the matrix is the same size and then you just add or subtract each of the corresponding components so as an example let's uh find a plus b a plus c etc so first a plus b well that'll be 2 plus negative four so that's negative two and then one plus three so that'll be four and we'll just someone just keep uh adding the corresponding entries should get one two two three and my last row seven zero three five so that's a plus b and for a minus b we'll do the same way except that we'll just subtract so two minus negative four is two plus four is six and my next one will be negative two negative 5 2 negative 3 negative 2 2 5 1 negative 4 11 negative 5. i think that's good notice a and c are different sizes so we can't do a plus c so a plus c is undefined notice that uh b plus c those are different sizes so also undefined it's going to list all the undefined ones uh let's see a minus c the same reason and b minus c all of these guys are undefined if a is any matrix and c is any scalar then the product c times a is the matrix obtained by multiplying each entry of the matrix a by c the matrix c times a is said to be a scalar multiple of a for the matrices abc let's find 2a minus 1b and one-third c okay well to get 2a again this is kind of similar to added subtracting it's kind of the obvious way you would think so we'll just take each of these entries in a and multiply them by two so we'll get two times two is four three times two is six four times 2 is 8 and then 2 6 and 2. so that's 2a let's see for minus 1b again just the way that you would think we'll just multiply each entry by minus one zero times minus one will stay zero two times minus one becomes minus two then we have minus seven one minus three and five last but not least let's take one third of c so we'll just multiply each entry by one-third aka divide by three so nine times the third is three minus six times the third is minus 2 and so on i'll just finish up with 1 0 4 and that's 1 3 c if a is an m by r matrix and b is an r by n matrix then the product a b is the m by n matrix whose entries are determined as follows to find the entry in row i and column j of a b single out row i from the matrix a and column j from the matrix b multiply the corresponding entries the row and column together and then add up the resulting products so this is a lot different than what you would think intuitively you don't necessarily need matrices of the same size as you're about to see in this example so you don't just take corresponding entries and multiply them if this would even correspond i mean what would you even correspond this entry to maybe over here but then this one and there and then this one there but then you're missing one it's hard to even imagine how you would do it if you were trying to match up the entries even if you had two of the same size you could just multiply the corresponding entries but it turns out as we're going to see later on in this course that's not super useful in general it turns out it's much more useful to define matrix multiplication in this as of right now unintuitive way which we're going to talk about a little more in this example it has to do with some of the things we're going to do in terms of linear transformations in terms of different visualizations and different geometric interpretations we're going to see but suffice it to say it turns out that multiplying matrices by this way is very useful to us even though we could do it the other way which would be easier we can get more out of this way so we'll do is we'll consider these matrices and i want to find a b so what i have to do is take the entries in each row multiply them by the entries in the corresponding column and then add them together one by one so i'm going to take let's do this row first in this column so i'll take one my first entry in this row multiply it by four my first entry in this column then my second one is two i'll multiply by zero so plus two times zero now let's take the last one four times two so plus four times two and all together we'll get twelve four plus zero plus eight okay let's do the next row or actually how about i i'm gonna move down the columns instead why not so what i'll do is i'll take stick with this first row but i just did this column i'm gonna be using this one now so what i'll do is i'll take the first number in the row and the first number in the column multiply those so i'll get one times one and then i will add that to two times one i'll pull out the negative that's for this so i'll just subtract 2 times 1 and i'll add that to 4 times 7. and that's 27. okay let's do the third column now so it's one times four plus two times three plus four times five and that's 30. okay fourth column now so we'll do one times three plus two times one plus four times two okay so now that i've finished with all those columns i think what i want to do now is move on to the second row so we'll take that and then we'll go through each column again so we'll do 2 times 4 plus six times zero plus zero times two we get eight okay let's do the next column okay so we have two times one i'll pull out the negative for the minus one times the six so six times minus one and zero times seven and we get minus four okay let's do the next one we get two times four six times three and zero times five so we get twenty six oops okay last one two times three six times one and zero times two and we get twelve as you get more used to this you should be able to do it a little bit faster i'm not gonna go through and write out each of these every single time i'll do it my head but it is a little bit tedious so let's write out each of these entries where they should be in the product matrix so in this case i took um row number one times column number one so that means that this product this 12 should be in row one column one so i'll put the 12 over here i was still in row one but now i'm in column two so that means the 27 should be in row 1 column 2. then it was still row 1 but it was column 3. so the 30 should be in row 1 column 3 and then 13 should be in row 1 column 4. then i started using the second row and i did times the first column so second row we'll get that first eight in the first column then it was negative four in the second column then 26 and then 12. and that's a b suppose that a b and c are matrices with the following sizes let's determine whether the products a b a c b c b a c a and c b are defined well let's look at uh a b in order to multiply a times b i need the columns of a to be the same amount as the rows of b right let's take a look we had three columns over here and that was able to match up to the three rows over here even though i went down the rows of a i went down the two rows i matched each with one of these columns what i did was i would multiply each of the entries in the corresponding one so if we had um let's say four entries over here let's say that there was a six over here then it wouldn't have matched up to these three over here i would have multiplied one times four two times zero and four times two and then i would have been able to do anything with this six there's no number over here so it's very important that however many columns we have over here it matches up with however many rows we have over here even though we mult we're not multiplying the columns we're multiplying the row by the column we still need the columns to be what matches up to the rows so let's take a look and see if they match in our example well a is three by four so that means that four is the number of columns of a and b is four by seven so that means four is the number of rows of b since these numbers match we're good to go so a b is going to be a 3 by 7 matrix notice even though 4 is the number that matches up that's not the size of the product matrix notice over here 3 was the number that matched up with 3 columns in a three rows and b but there are not three rows or three columns in a b the number of rows of our product ended up being the number of rows of a the number of columns in our product ended up being the column number of columns of b so we need these columns to match these rows in order to multiply but in order to see what the product dimensions are we need to count the rows we're actually multiplying by the columns we're actually multiplying so that's why uh a b becomes a three by seven matrix let's look at bc now all right so for bc perfect we have seven columns and seven rows in c seven columns b seven rows and c so that matches so we're allowed to multiply in order to see what size it is we take each of the rows and b and multiply it by a column in c so it should be a four by three matrix so step one check if you're allowed to multiply step two to see how big it's gonna be check the rows by the columns it's the opposite all right let's look at ca okay so for c a we would start with c so we'll look at the columns of c that needs to match the rows of a which it does perfect so we're allowed to multiply so that means it's going to be seven by four uh let's look at ac well a times c four and seven don't match so ac is not defined uh that's not the only one though notice uh for c b three and four don't match so no multiplication for them and let's look at b a well we need seven to match a three again that doesn't work so ac cb and ba are all undefined in general if a equals a i j is an m by r matrix and b equals b i j is an r by n matrix then as illustrated by the shading in the following display we have that the entry a b i j in row i and column j of the product a b given by a i1 b1 j plus ai2 b2j plus ai3 b3j and so on this is called the row column rule for matrix multiplication which is just a very explicit way of saying exactly what we did in the previous example take each entry in each row and multiply it by the corresponding entry in each column add them all together and you'll get the entry in the corresponding row column of the product a matrix can be subdivided or partitioned into smaller matrices by inserting horizontal and vertical rules between selected rows and columns the following formulas show how individual column vectors of a b can be obtained by partitioning b into column vectors and now individual row vectors of a b can be obtained by partitioning a into row vectors so here's a b notice we could write that as a times each of these column vectors this little bold b1 stands for um let's say uh b first row first column b second row still the first column and and so on this is just a whole bunch of entries we could say this is the nth row for example so that's what b1 is this b1 is a shorthand for this entire set of entries similarly this b2 stands for a whole bunch of b's all the way around over here this is just a short way of writing a bunch of b's bunch of b's bunch of b's bunch of b's bunch of different entries and then we multiply all of those by a and so we have a times that first column a times that second column a times that nth column it's basically the exact same way we did the multiplication in the example you can also do it row by row where you take a and you write it out for each of its rows and then you multiply notice this a stands for an entire row of a values this a over here stands for entire row of a values this is not just a single one it's bold so you could think of each of these rows being multiplied by b then compute the product row by row if a and b are the matrices in example five let's compute the second column vector and first row vector of a b so i'll take matrix a which was 1 2 4 and 2 6 0 from example 5 and i'll multiply that by the second column vector so that's one oops one minus one seven of uh b okay so let's see i'll get uh 1 times 1 plus 2 times minus 1 plus 4 times 7 equals 27 then the second row by this column 2 times 1 plus 6 times minus one plus zero times seven is negative four okay so that's the second column vector of the product let's get the uh first row vector well let's see we'll take the first row 1 2 4 of a and we'll multiply that by matrix b so that was 4 1 4 3. zero minus one three one two seven five two okay and let's see let's uh take the row multiply it by that first column so four times one one times four two times zero four times two so we get twelve then row times second column so we get uh 1 times 1 plus 2 times minus 1 plus 4 times 7 is 27 okay now the row times the third column 1 times 4 plus 2 times 3 plus 4 times 5 is 30 and then row times last column so 1 times 3 plus 2 times 1 plus 4 times 2 is 13. okay so that's my first row vector of the product a b if a1 a2 through ar our matrices is the same size and if c1 c2 through c are scalars then an expression of the form c1a1 plus see r c2a2 r is called a linear combination of a 1 a 2 through a r with coefficients c 1 c 2 through c r if a is an n by n matrix m by n and if x is an n by 1 column vector then the product ax can be expressed as a linear combination of the column vectors of a in which the coefficients are the entries of x so let's see if we can prove this well we'll let a bit this general matrix over here and we'll let x be this general n by one column vector so if we multiply these guys together then notice this row gets multiplied by this column vector like so each of the entries get added but then we move on to the next row that's how much multiplication works multiply that by the column so that looks like this and so on we keep doing that but then what we could do is notice every single one of these is multiplied by x1 so we can just uh factor out that x1 because scalar multiplication that's how it works for matrices so we'll just take x1 times this entire row and matrix addition let's see you just uh separate because this remember this is just one giant entry over here so that's just this plus this plus this assuming that you multiplied by each of these scalars along the way so we separate this one giant entry into all of these entries added up or all of these entries added up and then we do that for each of the other ones and we get an entire row vector over here times x1 row vector here times x2 and so on which is uh exactly what we were trying to prove let's write this matrix product as a linear combination of column vectors so notice what we could do is uh take this first uh column over here and we'll just uh write that times this first entry over here kind of like how we in our proof we took the first column over here and multiplied it by the first entry over here went over there so in this case that x1 is a 2 so we'll take 2 times our first column minus 1 1 2. and let's see our second entry was -1 so minus one times our second column is three to one and then three times our third column and there we go we pretty much have our linear combination we just have to set it equal to what it was originally equal to that uh column vector 1 minus 9 minus 3. okay perfect if a and b are the matrices in example five let's write the column vectors of the matrix product a b as linear combinations of column vectors let's see we have a b equals 1 2 4 2 6 0 times 4 1 4 3 0 minus 1 3 1 2 7 five two and we kind of painstakingly figured out that that was 12 27 30 13 8 minus 4 26 12. so let's uh write each of these column vectors as a linear combination of column vectors so 12 8 will be our first one and notice that's let's look at these as our uh what we're multiplying by that was over here we'll do a column by column so we'll take four times the first column 1 2 and we'll add that to 0 times the second column and a 2 6 and then we'll take that last number two and add it and multiply it by our uh last column for zero it from a okay so that's our first column in our product written as a linear combination of the columns from a let's do that for our second column so it's 27 minus four okay so that'll be equal to let's look at our second column in our uh in b multiply that by each of these guys so the first thing we're multiplying is a one so i don't even have to write that i'll just do one times one two is just 1 2. and then i've got the minus 1 times 2 6 so minus 2 6 and then my last one is a seven and that's four zero okay two column vectors in the product down uh how about we do 30 26 now so for 30 26 we'll take four three and five so that'll be four times one two plus three times two six plus five times four zero okay last but not least thirteen 12. okay so we'll grab last one three times one two and we'll add that to oh just one times two six and then two times four zero [Music] suppose that an n by r matrix a is partitioned into its r column vectors c1 c2 through cr each of size n by one and an r by n matrix b is partitioned into its r row vectors r 1 r 2 through r r each of size 1 by n then the product a b is equal to c 1 r 1 plus c 2 r 2 and so on through c r r this equation is called the column row expansion of a b so let's find the column row expansion of this product right over here well first what we want to do is write out all the season r's so for c1 that's going to be this one two right over here we're taking all the columns from our first matrix and the rows from the second one so we'll take one two and then c2 will be the second column three minus one okay now let's look at the rows let's look at r1 what's 2 0 4 for the second guy and r2 is minus 3 five one okay so now what we wanna do is we wanna write a b is equal to the this thing over here so c one r r1 so that's 1 2 times r1 is 2 0 4 okay plus c2 r2 so that's going to be 3 minus 1 times minus 3 5 1. okay but we could actually do that multiplication let's see first row times first column that gives me a two first row times second column gives me zero first row times third column gives me four now second row first column gives me four second row second column zero again second row third column gives me eight okay let's add that what we get when we multiply these i'll do it the same way 3 times negative 3 is negative 9 3 times 5 is 15 then 3 and then for the second row 3 negative 5 and negative 1. okay let's look at what we get when we add those together and we'll get a b right so 8b must be negative 7 15 7 7 negative 5 and 7. via its column or expansion consider a system of m linear equations and n unknowns we can replace the m equations in the system by the matrix equation written like this as we've done previously if we designate these matrices by a x and b respectively then we can replace the original system of m equations and unknowns by this single matrix equation ax equals b so we'll do that pretty often for shorthand represents basically this entire system through this matrix equation the matrix a in this equation is called the coefficient matrix of the system that's this guy augmented matrix for the system is obtained by a joining b to a which we've done as the last column and thus the augmented matrix is given like this very often we will omit this line over here we'll just write all the a's and the b's right next to them but it's nice to see it separated just to remind you it's an equal sign by the way as usual we won't write the um x's very often it'll just be implied that the variables are there if a is any and by matrix then the transpose of a denoted by a t is defined to be the n by n matrix notice we swap the order that results by interchanging the rows and columns of a that is the first column of a t is the first row of a the second column of a t is the second row of a and so forth so as an example let's find some transposes how about we look at uh a t for this a over here okay we're going to take the first uh how about we take the first first column we'll write that as the first row so a11821831 that becomes our first row okay and now let's take the second column and make that our second row one two three two two three two three now let's take third column make that our third row three eight two three eight two four and last but not least a one four eight two four a34 perfect you have to be very careful here because notice i kept the exact same notation as it was originally and originally it was telling us first row second row third row but in keeping those characters it's messed up the notation in the final result because all of these ones you would think would mean that we're in the first row but or not anymore it's referring to the original first row now all of these guys are just the first column so the indices got a little messed up but anywho that's our transposed matrix let's look at b transpose so that's okay let's look at the first column so that'll be our first row and our second column will be our second row okay how about first c transpose our first column will be our first row our second column will be our second row and our third column will be our third row and the easiest one is d transpose that'll just stay four switching the wrong column when it's equal doesn't do anything not only are the columns of a t the rows of a but the rows of a t or the columns of a thus the entry in row i and column j of a t is the entry in row j and column i of a that is if we look at a tij for the entry then that'll be a ji which makes sense in the special case where a is a square matrix the transpose of a can be obtained by interchanging entries that are symmetrically positioned about the main diagonal you basically just have to um look at where the diagonal is those will stay the same because swapping them there in the middle it won't change it but the this one will move to this side and then this entry over here will move to this side and so on if a is a square matrix then the trace of a denoted by tra is defined to be the sum of the entries of the main diagonal of a the trace of a is undefined if a is not a square matrix so let's find the traces of these matrices what we want to do is look at the main diagonal which is there and all that goes like this only works with the square matrix which it is because there's the same number of rows as there are columns so we have trace of a is each of these guys added together so that's a11 plus a two two plus a three three all right how about the trace of b now again look at that main diagonal add those guys up so that's negative one plus 5 plus 7 plus 0 which is 11.