This week's topic is Linear Algebra. It'll actually be the topic for the next two weeks. And the focus of this course is going to shift a little bit. So the first half, the first four weeks of lectures, I was basically aiming at doing a calculus review. And, getting everybody up to the level where they were able to Take the partial derivatives of the black scholes pricing formulas. Now what I'm sort of driving at, is a problem from portfolio theory. And so we're going to use tools from linear algebra to describe a portfolio. And then in the, in the third week. We'll look at some ways some ways to do mathematical optimization. So for a given sort of target return of your portfolio you'll want to minimize the risk. And then in the final week we'll look at some numerical methods for solving problems like that. So this week's outline today I'm going to try and cover, topics one through five. So, vectors, this is just points, so a vector of length two, you could think of that as a point in a plane. Vector of length three, you could think of that as a point with x, y, z coordinates and then you can just keep going. So you can have a vector in sort of five dimensional space. That's just a vector with five numbers in it. [COUGH] In section two, I'll talk about vector length and then plane, so that's two separate topics. But they're kind of short, so I mushed them into one video. Then, we'll look at, Solving systems of linear equations. So, if I have a, three equations in three unknowns, basically, and the way you would normally think about this, each one of those equations determines a plane. Two planes will intersect in a line. And then the third plane will intersect that line in a single point, and that'll be the solution to my system of linear equations. And then we'll start looking at some concepts from linear algebra that allow us to solve that problem, so something called elimination. And then I'm going to use elimination to motivate the idea of matrix multiplication. Then, next week we'll look at actually solving, so Ax equals b, so this is just the. Matrix form of a system of linear equations. And we're going to look at solving that. And sort of the moral of this set up lectures is that we can solve problems of this form Ax equals b or in general a lot, any problem coming up in linear algebra. Usually by factoring a matrix so there are different ways that a matrix can be factors. So this is breaking it into a product of, so a set of matrices whose product is equal to the original matrix. And then hopefully that representation of the matrix is going to make it easier to solve the problem we're trying to do. And then I'm going to finish by introducing something called the R Environment for Statistical Computing, and this is a software environment that lets you manipulate vectors in matrices. And so I think a lot of these topics will be become a lot more clear once you actually try to use them to solve a particular problem, and that you can do that with a pen and paper but it ends up being a lot of work. And so I don't really want to stress doing that. I want to stress understanding the concepts, and then solving them using a computer. The first topic will be vectors. So imagine we have a, a portfolio. So a portfolio's just a, a collection of assets. literally a portfolio just means a folder, so it's, something like this that I use to collect your quizzes at the end of the day. And I suppose in the old days, people used to put their shares into a portfolio, and so that, the word is sort of stuck around. And I'm going to consider a very simple portfolio. So I have two assets, which I cleverly named asset 1 And asset 2. And then I'll have w1 shares of asset 1, and w2 shares of asset 2. So, you could think of this as me, say owning five shares of Apple and three shares of Google. Something like that. But, instead of just kind of making a list, I want to think of this as a, something called a two dimensional vector. So I'm going to call my vector w, and it'll have components w1 and w2. And so, in general you want to think of a vector because our goal is to eventually combine this with matrices. So there's two ways you can write a vector. I could write it as a row, which is sort of this way, or I can write it as a column, which is this way that's in black. And generally, I want to think of vectors as always being a column, but sometimes just because it's inconvenient to write them, you know if I have a vector of ten things it's going to take up the whole slide just to write one line. So I'll write them in a row, but I'll use parentheses instead. So, this means the same thing. If it's got the square brackets, I mean the vector actually the way it's written down, and if it's got the round brackets, parentheses, then even if I write it like this, what I really mean is a column with w1 on top and w2 on the bottom. And w1 and w2 are called the components of the vector, w. And so the you know simplest operation would be addition. So, suppose I had a second portfolio. So I have u shares of asset 1 and u shares of asset 2. So I can have different numbers but the interpretation has to be the same. So Whatever number goes in the first component of my vector, that's the number of shares of asset 1. Whatever number goes in the second component of my vector, that's the number of shares of asset 2. And then, you know, this is just two separate portfolios. If I were to put them together, it should be pretty clear that it's going to be the, the number of shares of each asset that are going to be in, the combined portfolio. So I'm going to define addition just to work like that. And this isn't just addition for vectors that represent portfolios, this is, this is addition in general for vectors and I'm just trying to use this idea of a portfolio of assets to, to help you understand. So if I have a vector u and a vector w, and I add them together. I'm just going to add them component-wise, so the first component of the sum is equal to the sum of the two first components, and so on. And so the, I think I already set it, but the. So to the language I want to use is component-wise. So if I do an operation on a vector that effects each component of the vector individually, I'll use the, the word component wise. And any. Suppose I want to, consider the problem of multiplying a vector by a scalar quantity, so scalar quantity is just going to be a real number. But it's a single real number, so vector has more than one component, a scalar is just one single real number so if I looked at just multiplying a vector by an integer, and so, 2 is a pretty easy integer to work with. Normally, I would think of 2 times w as just w times w, and so then if I did that using my addition rule, I would just end up with 2w1 2w2 as the sum. And so in general I'm going to do the same thing. So, this scaler here that I put in front of the vector, just ends up getting multiplied into each component of the vector. So when I define multiplying a vector by a scaler so here, this value c is a scaler value, some real number. Then the answer is just going to be c times the first component and c times the second component. Then I can make something called a linear combination of two vectors. So again I have a vector u and a vector w. And I, I now have two scalar quantities, c1, ops, and c2. And I'm just going to combine my scalar rule and my addition rule. So c1 times u becomes cu1, c1u1, c1u2. c2w becomes c2w1 c2w2, and then I just add those component wise, and so I end up with this as the expression for the first component of this linear combination, and this as the expression for the second component. And then one nice thing I can get out of here is if I set c1 equal to 1, ops, and c2 equal to minus 1. Then I end up with u minus w so this allows me to define Vector subtraction. And I guess I should, should mention I'm, I'm using this vectors of length too just because I want to have something to show off that's in the form of a vector. This works for vectors of any length just again if they get longer it's just that much more type setting for me and not much less that will fit on the slides. And so in mathematics generally people tend to trust something more if they can draw a picture of it. And so we can actually draw a picture of vector addition. So suppose a vector W So, again it's just. I'm going to use points and the planes. So, the vector w will have two components. And, we'll draw that with an arrow. And, I'll put the tail of the arrow at the origin. So, for any vector, the tail always goes at the origin. And then the pointy end goes at the point w1, w2. So it goes at the point whose components are the components of the vector. So for example if I let u equal the vector 1,2 and w equal the vector 3,1 then I end up with a picture like this. So, to get u, I put the tail of the arrow, so that's the not pointy end at the origin. I put the pointy end at the point 1,2, so this is the x coordinate, the first component, if you're describing points on the plane you're going to think of that as the x component. And the second one will be the y component. So I just put the pointy end at 1, 2. Same for w, I put the x at 3, and y is 1. So the pointy end goes at the point 1, 3. And then if I add these together, what ends up happening is I can think of addition as taking one vector, so for this bottom path to the sum, I can think of that as taking this vector u, and drawing its tail at the tip of w. So I go, w like that, and then I go u like that, and then I end up at the vector v, which is this blue arrow here. And I could have done it the other way. That's a, it's an associative, I'm sorry, commutative operation so I could have taken, I could have gone from here to here so I've gone up to u. And then taken the vector, w, and placed it here, and that would also get me to the vector, v. And then subtraction. So if I start out with v, and I want to find out what is v minus u, so I'm aiming to do this operation right here. I'll take the vector v, then minus 1 times u. So if I multiply a vector by a scalar, that's just changing the length of the arrow. But it's not changing the direction that it's pointing in. So if I multiply it by negative one, I'm just taking this vector, and, ops. well, here, here's u. It just ends up being this u, but pointing the other direction. So I would draw that from the origin, down. But since I'm doing an addition operation, I move the origin from my vector, u. To be this vector v here. So to get w, I follow v, and then I follow u, and I end up at w. So, since each component in the sum So here I'm using i to mean the components, so in my case I've been looking at vectors of length two so I could be one or two. So, since ui plus wi is equal to wi plus ui because addition is commutative. I have the same property for vectors. So u plus w is equal to w plus u. So that should be pretty obvious. I just have 1 plus 3 is 4 or 3 plus 1 is 4 and so on. There is one special vector called the zero vector. And that has each component equal to zero. So every component in the vector has to be zero. And then it's going to have the same property that zero has for regular numbers if I add zero to any vector. So you have to be a little bit careful here, because the zero vector has to be the same length. As the vector w, but generally if w is a vector and I add 0 to it, you just sort of have to look at that and say, well, this 0, the type of 0 has to match the type of this w in order for me to be able to do this operation. So, 0 must be a vector of 0, the same length as w. And the zero vector has the same property of zero, so if I add it to any vector, I just get my vector back. If I scale a vector, so here I've used 2, but in general this could be any real number c. this pres, well To preserve the direction, it can be any real number except for zero. And, if I put two here, it's going to double the length. If I put an arbitrary constant c here, it will be c times the length. And then minus u, you can think of that as being the same length as u. By just pointing in the opposite direction. So that sort of covers addition and then these, the operations of dealing working with vectors using scalars. We can also Introducing a concept called the dot product or inner product. And this gives us some notion of how you could multiply two vectors together. So if I have two vectors u and w that are length two, the dot product is just going to be the scalar quantity. So here I'm, I'd read this left side as u dot w. And it's just defined to be the product of the first component. The product of the first component plus the product of the second components. Or in general if this a, longer vector. So w or length three. Or length four. Or length five. It's the, the product of the, the components with the same index, and then all of those sumed together. So if it was length four, it would be u1w1 plus u2w2 plus u3w3 plus u4w4, and then, all summed up. And so this going to always be a real number. And just a, a scale or quantity. It's not goig to be a vector. So just a, a simple example. If I take the dot product of 1, 2 and 3,1 I end up with 1 times 3 plus 2 times 1 so 1 times 3. Ops, plus 2 times 1, and that'll be equal to 5. And the reason this type of product makes sense, so again, this is something we can actually understand again, with my portfolio example. So remember, w was my position in assets 1 and 2. So w1 was how many shares of asset 1 I own. And w2 was how many shares of asset 2 I own. And suppose I have another vector p1 and p2 that are the prices of asset 1 and asset 2. Then if I define v to be the dot product of. W and p so w dot p. That's going to be the number of shares of asset 1 times the price of asset 1 plus the number of shares in asset 2 times the price of asset 2 and that'll just be the value of my portfolio.