in this video we'll talk about the gram-schmidt process which is also sometimes called gram-schmidt orthogonalization so our goal for this process is given a subspace of RN we'd like to find an orthogonal or orthonormal basis for W and the gram-schmidt process allows us to start with any basis for W and use it to construct a new basis that is orthogonal or orthonormal whichever one we want so here's how the process works so we start with a basis X 1 X 2 up through XP and we assume that that's a basis for the subspace W and then we're going to construct new vectors which we'll call these V 1 V 2 up through V P and this is the way we're going to construct it so starts off easy the first V 1 is just the same as X 1 but then V 2 is X 2 minus X 2 dot V 1 divided by V 1 V 1 times B 1 so what I want you to recognize is that this right here is the projection of X 2 onto V 1 and so when we subtract that what V 2 is is the component of X 2 that's orthogonal to V 1 and so that's gonna guarantee two things it's gonna guarantee that V 2 is orthogonal to V 1 and it's also gonna guarantee that the span of v1 and v2 is the same as the span of X 1 and X 2 and now when we move onto V 3 we're subtracting both the projection of X 3 onto V 1 and also the projection of X 3 onto V 2 so we're taking away the portions the components of X 3 that point in the direction of V 1 or the point in the direction of V 2 and so what we'll remain after we subtract those pieces is the component of X 3 that's orthogonal to both v1 and v2 and so V 3 will be orthogonal to both V 1 and V 2 and we won't lose anything from the span the span of v1 v2 and v3 will be the same as the span of X 1 X 2 and X 3 and so on so when we finish this process this V vectors will all be orthogonal to each other and they'll span the same subspace that the XS band and so that's the theorem the theorem says that when we do this construction those V vectors form not just a basis for W because we already had that but this is an orthogonal basis for W now what do we do if what we really wanted was an orthonormal basis well in that case all we do is first use the gram-schmidt process to find an orthogonal basis and then we just normalize each vector to obtain an orthonormal basis remember that to normalize a vector you just divide it by its length so you take the V vectors and you look at the lengths of each of those vectors and if that vector isn't already a unit vector you divide that vector by its length to create a unit vector so let's take a look at an example so here we have three vectors in r4 and we want to let capital W be the span of those three vectors and what we want is an orthonormal basis for W now I'm leaving out the portion where we actually check that x1 x2 and x3 is a basis for W what we would have to check there is that these three vectors are linearly independent but we know how to do that by row reducing the matrix whose columns are x1 x2 and x3 so let's move on to use them to gram-schmidt process to find an orthonormal basis so here's what the process looks like we have these formulas so v1 is easy that's just the same as X 1 and then v2 is X 2 minus this fraction involving dot products times the vector v1 it turns out that X 2 dot V 1 is negative 2 and V 1 V 1 is 6 and when we subtract we get this vector here and that's our vector V 2 V 3 same idea just a little bit more complicated because we have a few more dot products to compute X 3 dot v1 turns out to be 4 v1 dot v1 turns out to be 6 X 3 dot v2 is negative 8/3 and v2 dot v2 is 7/3 and when we multiply those subtract simplify our fractions we get this vector here which is our vector v3 so those three vectors form an orthogonal basis and so with what we want is or an orthonormal basis we just have to take the lengths of each of those vectors and divide so it turns out that the length of the vector v1 is the square root of 6 and so when you divide by the square root of 6 we get this vector which is what we're calling u 1u stands for unit vectors that's what we have here again we divide v3 by hits length length of v3 turns out to be 4 over ethical 7 and so when we divide we get this and then V 2 the length of V 2 is square root of 7 over 3 and again when we divide and do a little bit of simplification we get YouTube so u1 u2 and u3 is an orthonormal basis it's essentially the same 3 vectors we've found before but we've shrunk or expanded them as necessary to turn them into unit vectors so you can tell this isn't really a difficult process it's just tedious we have a lot of dot products to compute we've got a lot of lengths and sometimes we get nasty square roots and so typically we're gonna use technology here there's nothing really exceptional going on here we're not even really real reducing any matrices except to check that the initial set of vectors is a basis and many times that will be given to us so in Mathematica if we want to use this we can use the orthogonal eyes command so all orthogonal eyes is going to do is exactly the gram-schmidt process that we've done plus it's also going to normalize the vectors for us so we can put a list of vectors in this case I've got the first vector X 1 the second vector X 2 and the third vector X 3 and we put those in a list so then when we execute this command we get the orthonormal basis they were looking for