 In this video lecture, let's have a look at Matrix Algebra in Sympy. As per usual, I'm going to import Sympy and I'm going to use the abbreviation SYM and I'm going to invoke prettyPrinting by stating sym.init underscore printing open and close parenthesis and we'll execute that code. Sympy is now loaded into this notebook and I can refer to everything contained within Sympy by just referring to it via its abbreviation SYM. So I'm going to print to the screen this string the matrix A and we're going to define the matrix. Simply going to attach this matrix to a variable. So I'm going to design this matrix and attach it to the variable. So this variable in computer memory now contains this matrix that's going to print that variable in other words the matrix. So how do you do that? It's sym.capitalM uppercase in matrix and I have my open and close parenthesis and now I'm just going to take the elements of that matrix. Now watch very carefully with the open and close parenthesis there's also an open and close square brackets. So the whole thing has to be enclosed in open and close parenthesis and open and close square brackets. And then every row is within another set of square brackets and every row all the elements in that row I should say. And then every row is separated by a comma. By a comma. So it's a comma and then the second row there. You will note that each row here has two columns. So I'm going to have as elements in my first row column one is one column two is two. And I say remember the floating dot I want these to be floating point values not integers. Otherwise you're going to do equations on you're going to multiply matrices for instance and the answers are not going to come out correct. Especially if you do the inverse if these are not floating point values. They might but just make sure to be 100% sure put those dots you don't have to put the zero. So I'm going to have one and two and I'm going to have negative a half which I've done as negative one divided by two enclosed in parenthesis and then one. And then I'm going to print a let's see how that works. And there it is a thing of beauty. One, two, negative a half and one and there is my matrix A beautiful. Now I'm not going to show you how to do a second matrix and how to do matrix additions. You should know about matrix algebra. They should be the same size if you want to do addition and subtraction. Very easy to do. Just store them as variables A and another one B and just say A plus B. No issue. You can sort these things out for yourself very easy to do. Let's do something a bit more interesting. Eigen values. So the Eigen values of matrix A very simple. SYM dot matrix A. So I had this variable and I called it variable A. So I can just refer to A there. If I didn't do that I could have just typed out the whole thing here. SYM dot uppercase matrix open close parentheses open close square brackets and entered the whole thing there. But I have attached it to this variable A. So I can just use that. Dot Eigen valves VALS open close parentheses off we go. And this Eigen the Eigen values of matrix A is there's one. Eigen value of one negative i and one Eigen value of one plus i. So there were more than one of these it'll be two three whatever. It's so easy to get the Eigen values and it's just as easy to get the Eigen vectors. It's SYM dot matrix A dot Eigen vex. And there you go. So what it will do it will say for the Eigen value one minus i. There's one Eigen vector and it's two i and one. For the Eigen value one plus one i there's one Eigen vector negative two i and one. Very easy very beautiful to do. Now SYMPI it's symbolic remember. It can do things that are even more fantastic. I can have symbols in my matrix. So first of all look at this B11, B12, B13, B21, B22. And I am saying that this is a variable and I latch it on to this symbol. And that looks ugly but you'll see in a bit. So it equals SYM dot symbols as we did with X, Y, Theta, etc. I'm going to introduce this variable B and I'm going to attach to that this matrix. Which has one, two, three, three, two, one rows each with one, two, three columns. And I'm referring to those symbols. I'm going to print the string the matrix B colon and then actually print that. And voila look at that isn't that fantastic. I mean it really looks good. You can't deny that it's putting the sub values there. B sub 11 referring to row one column one. There we have row one column two, row one column three and that's beautiful. Let's declare more symbols C1, C2 and C3 as symbols C1, C2, C3. And now this is going to be a column matrix. Because there's these commas in between the rows and each row only contains one column. Let's see, let's see if that is so. Indeed a column matrix. So B is a three by three matrix. C is a three by one matrix. I can multiply it in that order B times C. Very easy to do. That's why I'm not even showing you addition and subtraction. If the matrices are of equal size, you can add and subtract them. Let's look at multiplication. Remember, I can't have C times B that would be impossible. It's a three by one matrix times three by three matrix times a three by one matrix. The result should be a three by one matrix. Let's have a look so I can simply refer to the variables B and C. And let's run that code and look at that. So it's taken these symbols with the subscripts and it's done in the most beautiful fashion showing you there's my first row, my second row, my third row. Indeed a three by one matrix as we thought it would be beautiful to do. Look at this one. We have matrix F. So again, I've just used F. Let's print that. And it's a two by two matrix and how to get the determinant. So instead of values, I could have put values in here as well. So as we did with matrix A, let's we have the determinant. So you just refer to it as F dot DET, open and close parentheses. And it will actually show you how the determinant of a two by two matrix is done. It's F sub one one times F sub two two minus the product of F sub one two and F sub two one. And if I put in values there, it would have actually given me the answer. Same with the inverse of a matrix. So it can be done symbolically or with actual constant values. So again, it will just be F dot INV open and close parentheses. And off we go. They show you actually how to do the inverse of a two by two matrix and it needn't be two by two. I can use a much bigger one. Even this, try stating B dot INV open and close parentheses. It actually goes off screen. It's so large, but it'll show you symbolically then how to do this. As I said, you can also put values in there. It's really just a pleasure to work with matrices in some pie.