If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

# Gram-Schmidt example with 3 basis vectors

Gram-Schmidt example with 3 basis vectors. Created by Sal Khan.

## Want to join the conversation?

• I am puzzled. Is this not an example of computing in a unnecessarily complicated way? If we pick the order of vectors to be ortonormalized in a smarter(?) way :first and third are orthogonal so they just need to be normalized with (2)^(-1/2).....In the last ortogonalisation Sal realises that the first and last vectors are perpendicular, but does not comment that the whole process could/should have been done in a other order • You are correct, that this could be made simpler by recognizing the first and last vectors are orthogonal, and thus you can just normalize them to have two orthonormal basis vectors out of 3 right off the bat. However, the purpose of the video is to show the Graham Schmidt process from beginning to end with 3 basis vectors which can be applied to ANY set of basis vectors, not just use a trick available in this special case.

The result for this example is some unnecessary computation, but this is sacrificed to provide a through and through example that can be applied to any set of 3 basis vectors.

Note also that in more complex situations, it may not be immediately obvious that two/more vectors in your basis are orthogonal, so applying the Graham Schmidt processes is a rote but guaranteed way of generating an orthonormal basis.
• Hello Khanacademy, I understood the concept explained. I tried using the gram-schmidt method on vectors V1,V2 and V3, which have complex random variables. After the process the vectors were not orthogonal to each other. But when I tried it with real numbers it worked. Please I need more information on this. Thank you. • This feels like a really dumb question...I do not understand how the projection of V2 onto V1 equals (V2 times U1) times U1. I have seen all of the videos preceding but I just can't get it. Could someone explain this to me please? • v2 dot u1 = ||v2||*||u1||*cos(theta) where theta is an angle between v2 and u1
since u1 is a unit vector, ||u1|| = 1 and so
v2 dot u1 = ||v2||*cos(theta)
now, cos(theta) = ||proj|| / ||v2|| so
v2 dot u1 = ||v2||*||proj|| / ||v2|| and thus finally
v2 dot u1 = ||proj||
this is the magnitude of the projection vector
we are projecting onto u1, so we can use it as a direction
proj = ||proj|| * u1 / ||u1||
now again, u1 is a unit vector, so
proj = ||proj|| * u1, and now TADAM!
proj = (v2 dot u1) * u1
• Would you end up with the same orthonormal basis if you found an orthogonal basis first, and then normalized all of the vectors at the end? It would eliminate all of that fraction multiplying. • I'm not quite sure if this is the right place to ask this question. Kindly re-direct me if there's another location where I can ask. Here it is:
I have a set of 3 orthogonal vectors, and I'm in need of a fourth vector that is orthogonal to the other 3 vectors so that the 4 vectors together constitute a basis for the subspace. How do I do this? Assume for the sake of imagination that the vectors are of dimension 4. • There are a few ways to do this. I can think of two off the top of my head. The easiest would be to find the nullspace of the matrix formed by using your three vectors as columns. This will work because the nullspace is always orthogonal to the column space (the span of the column vectors.) So in this case the nullspace will be 1-dimensional and any vector in it will be orthogonal to your first three.

The second way relates to Gram-Shmidt. If you can find any vector that is not in the span of the other three you can Gram-Schmidt it to make it orthogonal. This process is just like you would do for any other vector and you just project it on to the three you already have. Finding this vector might be a little tricky. Technically if you pick any vector at random you have a very good chance of picking one correctly. This is because your three vectors form a hyperplane in 4 space which is relatively small just like a plane in 3 space is relatively small.Iif you gram-schimdt it and it comes out to the zero vector you know you picked a bad vector.
• Dear Sal,
Will the Gram Schmidt process work if we apply row operations to our matrix that consists of the vectors in the basis?
If we bring our matrix to the reduced form and then calculate the characteristic polynomial? • That sounds pretty good! You can get a standard basis for the row space that way (but this isn't Gram-Schmidt).

Better still: Form the matrix A whose column vectors are the original basis "B" = {b1, b2, ..., bk}, then row reduce A^t to get the standard (and orthonormal) basis for its row space, which is also the standard basis for the span of our original set B

(Also, if you have k R^n basis vectors "b_i", and k<n, you can solve (A^t)x=0 (A = [b1 b2 ... bk]), then add the basis vectors for N(A) to the original set of basis vectors, then you have a basis for R^n - but this basis isn't yet orthonormal.)
(1 vote)
• At about , can there be an orthogonal version of a single vector? Doesn't a vector have to be orthogonal to something? ... or have I misunderstood the concept? • It's one of those true by default things. For a set of vectors to be orthogonal the dot product of any vector in the set and any other vector in the set must be zero. Since there is no other vector in the set it is vacuously true that when you do the only vector with the 'other' vectors, the dot products are never nonzero.
(1 vote)
• At or so, why do we ignore the normalization scalar that's being multiplied with the vectors? We can keep it aside until the end like that? Looks cool. • The Gram-Schmidt method is a way to find an orthonormal basis. To do this it is useful to think of doing two things. Given a partially complete basis we first find any vector that is orthogonal to these. Second we normalize. Then we repeat these two steps until we have filled out our basis. There are formulas that you could write down where both steps are taken care of in a long computation but it is useful to understand the process as a multiple step procedure which is what Sal is doing.
• At , the last vector sal just wrote (0,0,1,1) is the vector v1, shouldn't it be the vector v2 instead (0,1,1,0)? Or is it the formula above that should be Y2=V2-Proj(V1)*u1 instead of v2 in the end? • If we form the matrix A whose column vectors are the original basis "B" = {b1, b2, ..., bk}, can't we row reduce A^t to get the standard (and orthonormal) basis for its row space, which is also the standard basis for the span of our original set B?

If this method works, is it better or worse for applications or otherwise?
(1 vote) • If k=n, then indeed we will row reduce A^t to the standard (and orthonormal) basis for it's row space. Actually for k=n we don't need to work very hard to find orthonormal basis, since we know that V is the whole Rn and standard basis for Rn is also a basis for V.

But if k<n, then row reduce of A^t will not result in rows of rref to form orthonormal basis for its row space. E.g. for basis vectors from this video, we will get following vectors:
[1 0 0 1]^t, [0 1 0 -1]^t, [0 0 1 1]^t. These vectors will indeed span the same subspace as the original vectors, but they are not even orthogonal to each other.