 In this video, I want to show you how very easy it is to do LU decomposition of a matrix. You might be given this as some problem exercises and you just want to check yourself whether your LU decomposition is correct. Very easy to do in Python and we're going to do it in Sympi. I've already created a new notebook here and I've clicked on it at the top there and renamed it LU decomposition. So let's turn this very first cell into just a markdown cell. Remember that will be escape, enter or return. I'm going to put one hashtag or pound sign there and we'll call it LU decomposition. Shift enter, shift return and we have a beautiful title there. Now I want to create a matrix to do my LU decomposition with. So I've got to import Sympi but I'm going to show you something slightly different this time. Instead of importing and using an abbreviation and I have to refer to that abbreviation, I can import specific functions all on their own so that I can just use them directly. Watch this. From Sympi import matrix. As simple as that. Now I have not imported all of Sympi. I've only imported the matrix function and I can now use it directly. I'm not using an abbreviation here to refer to it. I can use it absolutely as is. Shift enter, shift return and it is there now. Let's create a matrix. I'm going to call my matrix matrix A and I don't have to say SYM. Because I haven't imported Sympi. I haven't created an abbreviation anyway. So I can't use that but I can use matrix directly. Matrix. Remember I've got to use parentheses here and I've got to use square brackets and I've got to do row by row. Let's do a 3 by 3 matrix and our first row will have 1, 2, 3 outside of my square brackets. New square brackets for the new row. Let's make it 4, 5 and 6 and let's make the last row. Let's make it something like 10, 11 and 9. As simple as that. I go to the end. Hit return and enter for a new line and I'm going to say just hit A again because I want this new matrix to be written to the screen. Now watch what's going to happen because we do not have in it printing initialized that LaTeX printing. I'm going to get something that looks, well we can see what's going on there. We can see that it is a matrix but we don't have that pretty LaTeX printing. So let's do that. We're going to say from Sympi import in it printing. As simple as that. In it printing. So now that's imported and I can refer to it directly. Hitting the tab for auto-completion there. Open close parentheses. Shift and enter. Shift return. Let's print A now. And we see beautiful matrix there. Much better. And that is why one of the many, many reasons why I love Sympi. So what is LUD composition? Remember you take your matrix and you do your set of elementary row operations on it except for swapping rows. We don't do that. So it is only a constant that you multiply out by row or a constant multiple of a row plus another row or minus another row depending on how you were taught. And that is going to give you an upper triangular matrix. Remember where there are values on the main diagonal and everything below that main diagonal is going to be a zero. And an upper, that's an upper triangular and a lower triangular where everything is ones on the main diagonal and everything zeroes above that. Let's have a look. I'm going to use a method on my matrix. And that method, and I'll show you now what it is, is going to return three values to me. And I've got to store each of those three values in a separate computer variable name. So I'm going to call that L, U, I'm not interested in the last ones. I'll just put an underscore because I'm not really interested in that. And I'm going to say a.LUDComposition. Hit my tab key there, auto-complete. I see LUDComposition there, open, close, parentheses. So I'm using a, and there's a lot of properties or things that we can do to a this matrix. One of the things is LUDComposition. And because a was created as a matrix object, a simple matrix object that has these properties, it has these functions that I can apply to it. And I'm doing this with a dot notation. So it's a.LUDComposition. And that's going to give me three things. It's going to return three things, a lower triangular matrix, the upper triangular matrix, and then just this term where it shows what rows were swapped. But we're not swapping rows here. We're just keeping things simple. And now let's look at the upper triangular form. As you can see there, upper triangular, I have my main diagonal, which here is one, negative three, negative three. Everything below that main diagonal is zero. So this is the upper triangular. If you were just doing your two row operations on it, you would have gotten to this form. Let's look at the lower triangular matrix. And we see all ones. So it's proper. All ones on the main diagonal and everything above that is zero. And if I say L times U, I'm going to get back exactly A. I can even test for that. I can say A equals equals L times U. That double equal sign asks a question, is this true or false? Is the left-hand side really equal to the right-hand side? Shift, enter, shift, return. And I get this Boolean answer back, which says true. Indeed, LU decomposition, multiplying L by U in that order. Remember, these things do not commute. Multiplication matrices do not commute. I'm going to get A back. So this is how simple it is to do LU decomposition in some pi.