 The third type of elementary matrices 2.0 that we wanna talk about is how do you upgrade a replacement matrix? How are we gonna generalize that? Well, this leads to the idea of triangular matrices, which there's gonna be two types of triangular matrices we're gonna talk about, which will then correspond to the fact there's really two types of replacement operations we are gonna talk about. So the first one is what we call an upper triangular matrix. An upper triangular matrix is gonna be a square matrix in by n, all of these matrices to talk about so far in by n square matrices. A upper triangular matrix is gonna be a matrix so that all of the numbers below the diagonal are necessarily zero. And so for example, an upper triangular matrix, you see something like this, that if you look at the numbers on the diagonal and above the diagonal, they can be whatever they want. They can be whatever they want, but the numbers below the diagonal have to be zero. And this is why we call it an upper triangular matrix that the location of nonzero numbers is necessarily gonna make this triangular shape. And that doesn't mean that the numbers above the diagonal have to be nonzero. They could be zero too, that's okay. The zero matrix, for example, is an upper triangular matrix. Upper triangular just means that everything below the diagonal has to be zero. And in a similar direction, a lower triangular matrix is gonna be a matrix, square matrix so that everything below the diagonal is, I should say everything above the diagonal is gonna be zero. So the things above the diagonal have to be zero, but the things below it, they could be whatever they want. And so if you look for the nonzero numbers, this is gonna be forming this lower triangular region. This is why we call them upper triangular and lower triangular for these reasons right here. But of course, the numbers along the diagonal, things below the diagonal could be zero for a lower triangle, that's perfectly fine. Now there are some special types of triangular matrices we want to introduce right now. If we add the adjective unit in front of a triangular matrix, that means that we're requiring that the diagonal entries be one. So if you look at this upper triangular matrix right here, we say it's unit upper triangular if the diagonal entries have to be one. And similarly, we say that a unit lower triangular matrix, it's a lower triangular matrix, but the diagonal entries have to be one. Unit here describing the multiplicative unit that is one. We say that a matrix is strictly triangular if the diagonal entries are all zero. So a strictly upper triangular matrix like this, we have zeroes along the diagonals. So we actually might draw our triangle a little bit smaller in fact. And strictly lower triangular get the same idea. We require zeroes along the diagonal right here. And so the nonzeros are only gonna be this lower triangular region there. We're not gonna worry so much about strictly triangular matrices in this lecture. Triangular matrices and unit triangular matrices will be of concern that strictly triangular ones we'll talk about a little bit more in the future. Now I mentioned that the main reason we want to distinguish between upper and lower triangular is that well, the location of the nonzero entries does make a difference. An upper triangular matrix is gonna be a square matrix that's essentially a national on form. It's basically a new word for what we already had, right? So notice that an upper triangular matrix is gonna be a matrix in echelon form, absolutely. A lower triangular matrix would actually be something that's an upside down echelon form. So what we call like chandelier form or something like that, I don't know. But in particular, it's not an extremely new concept as idea of upper triangular matrix. I should mention that if something is of course upper triangular and lower triangular, that actually makes it a diagonal matrix because upper triangular says everything below, everything below the diagonal is zero and upper triangular, lower triangular says everything above the diagonal is zero. So if we put this together, everything except the diagonal has to be zero. So the intersection of the space of upper triangular and lower triangular matrices is the space of diagonal matrices. And it does turn out that of course, if you take the set of upper triangular matrices, that forms a subspace for vector space F to the end by end. Why is that? Well, because if you add together two upper triangular matrices, you have zeros below the diagonal, when you add those together, you'll still have zeros below the diagonal. It's closed under addition, same thing for the lower triangular ones. And if you scale a upper triangular matrix, all of these zeros will still be zeros, C times zero is still zero. Same thing for the lower triangular ones. So these things are closed under linear combinations. Just like we saw with the diagonal matrices, if you take the product of upper triangular matrices, that'll also be upper triangular. If you take the product of lower triangular matrices, that'll also be lower triangular. Unfortunately, if you take the product of an upper triangular and a lower triangular, we don't have necessarily to guarantee what's gonna happen there. Turns out we'll see with the LU factorization that basically every matrix can be factored into a product of an upper and lower triangular matrices with some important exceptions. And so the general product is gonna be basically everything but upper triangular times, upper triangular is upper triangular. And same thing can be said for lower triangular. So those, the set, the space of matrices is again closed under matrix addition, skill of multiplication and matrix multiplication, believe it or not. Unit upper triangular matrices do have the property that they're not gonna be closed under skill of multiplication or addition because if you add or scale these things, you're gonna change the ones along the diagonal, all right? But they do have the property that they close under multiplication. A unit upper triangular times, a unit upper triangular is unit upper triangular. Same thing can be said for unit lower triangular matrices. The strictly upper triangular matrices also much like the upper triangular matrices, they will be closed under addition if you add two strictly upper triangular matrices together, it'll be strictly upper triangular. Same thing if you scale them, same thing if you multiply them, the same thing can be said for strictly lower triangular matrices as well. And so these can be viewed as subsets of F to the end by end, which in terms of dimension, this one's kind of an interesting argument here. The dimension of the upper triangular matrices can be N times N plus one over two. And you might wonder where in the world did that dimension come from? And the idea is, if you put a little asterisk here, it's like, okay, you have some degrees of freedom going on here. To be upper triangular, you could choose that asterisk be whatever you want. You have to get zeros everywhere else. And in terms of the dimension, you get something called the triangular numbers, right? If you start taking these triangles, and you start stacking them on top of each other, you have a line with one, a line with two, a line with three, a line with four, a line say with five, and we can keep on making these triangles bigger and bigger and bigger. And so we might ask how many stars are in this triangle where you're gonna get one plus two plus three plus four plus five and just keep on going right until you stop with N. If you're N by N. And these are called the triangle numbers. Counting numbers stars in these triangles. And there's a cute little formula that shows you that the sum of the triangle, or the sum of the consecutive numbers gives the triangle, that's gonna be N times N plus one over two. You actually can see a video right here if you wanna see a proof of this formula for the triangle numbers. Another formula you can use is that this right here is just N choose two. If you're familiar with the binomial theorem. All right. And so that gives you the dimension of the upper triangular matrices. Like I said, this one's not closed under linear combinations unit triangular matrices. So it doesn't make a subspace. So we wouldn't talk about dimension. For strictly upper triangular matrices or strictly lower triangular, it's the same basic idea. It's just you only get degrees of freedom off of the diagonal. So you're gonna take N times N plus one over two minus N, which you can then write that as two N over two. And so then you end up with N. When you combine those together N squared plus N minus two N over two. Simplify you get N squared minus N over two. And so your dimension turns out the N times N minus one over two dimensional. In case you are interested as these subspaces of these triangular matrices. Some other things we should mention about triangular matrices. An upper triangular matrix can be factored as a product of elementary matrices of replacement type. Now these are gonna be the replacement matrices one uses in the backward phase of the Gaussian Jordan elimination. So these upper triangular matrices correspond to the backwards phase. The back, not the Bach phase, the backwards phase. And likewise, the lower triangular matrices are gonna correspond to the forward phase of Gaussian elimination. And so that's sort of an important distinction here. But in particular, an upper triangular matrix and a lower triangular matrix can be factored. Now, if you take a unit triangular matrix that can be factored into just replacement matrices. And so unit triangular matrices are gonna be replacement matrices 2.0. Upper triangular matrices and lower triangular matrices. This would be if you start combining replacement matrices and scaling matrices together, especially if you allow for zero as part of that. So let's see some examples. Here's a matrix A, which is gonna be upper triangular. It's not unit triangular nor strictly triangular, but it is an upper triangular matrix. Same thing can also be said for B right here. Now it turns out that detecting whether a triangular matrix is singular or non-singular is pretty easy. Much like diagonal entries, we just have to look at the diagonal entries. Triangular matrix, whether it's upper or lower triangular, it'll be non-singular if and only if its diagonal entries are all non-zero. So we're gonna see that A right here is an example of a non-singular matrix. On the other hand, matrix B, because it does have a zero along its diagonal, it's gonna be a singular matrix. Singular. And so we can compute the inverse of A. You're gonna see that the inverse of A, which is also upper triangular, you're gonna get one half one and one fourth along the diagonals. You notice those are the reciprocals of the diagonal of A. That's easy. The other numbers are less obvious. And so I'm not gonna present any formula. We can just use the inversion algorithm there. If you wanna take the product of any two upper triangular matrices, you do get something that's upper triangular. Here's for example, A times B. Let you verify that one. And also like I promised, upper triangular matrices can be factored using replacement matrices and perhaps scaling matrices if it's not unit triangular. So the matrix A, I'm gonna zoom out a little bit so we can see all of these together. The matrix A can be factored the following way. So you have a scaling matrix, scale the fourth row by four. You have an upper replacement matrix. This will be one used in the backwards phase. This will look like row one replaced by row one minus five times row three. Here's another backwards phase replacement. Row two minus three times row three. And then you have a scaling matrix right there. Scale the first row by two. That gives us an elementary factorization of A. And you can just find this from just doing row reduction, right? How would you do each of these operations? Go through it one by one by one. Since it's upper triangular, you're already starting the backwards phase. You would scale the third row by one fourth. Then you'd cancel out these numbers right here. And then you have to scale the first row by one half. And so we get this factorization. I also want to present a factorization for B. You have to be a little bit more careful when you scale by zero because if you're not careful, scaling by zero can devastate things and destroy them. But this does give you a legitimate factorization. Scale the third row by three. Take row one minus two times row two. Take row two minus, sorry, this one was take, you take row one minus two times row three. This one is row two minus five times row three. This you're gonna scale the second row by zero. Then you're gonna take the first row minus row two and then scale the first row by three. And that gives you a factorization into air quote elementary matrices. Technically speaking, this is not an elementary matrix because multiplying by zero is not, that's a singular matrix right there. But that's because this matrix right here is singular as well. So every non-singular matrix can be factored it can be factored to a product of elementary matrices. Since B was singular, at least one of the factors in this factorization cannot be elementary. And so this is what we call a projection matrix. Something we'll talk about later in this series. And singular matrices, when you factor them, we'll have to have some type of projection going on into it. It's an example of an item poping matrix. And again, something we'll talk about a little bit later in this lecture series.