Motivation for the construction comes from Physics, where one needs to be able to decompose a force vector into parts that are parallel and orthogonal to a given direction.
To derive the formula, we note that the vector must be a scalar multiple of , since it is parallel to , so for some scalar . Next, since ,, and form a right triangle, 1
Assuming that the angle is acute. If it is obtuse, the scalar is negative, but so is the dot product, so the signs work out.
we know that . But . Plugging this in, and solving for , we get the formula in (3.2.1).
For the first part, try calculating the dot product, using the definition of . Don’t forget that if , since you are assuming you have an orthogonal set of vectors.
It follows from the Orthogonal Lemma that for any subspace , any set of orthogonal vectors in can be extended to an orthogonal basis of . Since any set containing a single nonzero vector is orthogonal, it follows that every subspace has an orthogonal basis. (If , we consider the empty basis to be orthogonal.)
The procedure for creating an orthogonal basis is clear. Start with a single nonzero vector , which we’ll also call . If , choose a vector with . The Orthogonal Lemma then provides us with a vector
such that is orthogonal. If , we’re done. Otherwise, we repeat the process, choosing , and then using the Orthogonal Lemma to obtain , and so on, until an orthogonal basis is obtained.
With one minor modification, the above procedure provides us with a major result. Suppose is a subspace of , and start with any basis of . By choosing our in the procedure above to be these basis vectors, we obtain the Gram-Schmidt algorithm for constructing an orthogonal basis.
Of course, once we’ve used Gram-Schmidt to find an orthogonal basis, we can normalize each vector to get an orthonormal basis. The Gram-Schmidt algorithm is ideal when we know how to find a basis for a subspace, but we need to know an orthogonal basis. For example, suppose we want an orthonormal basis for the nullspace of the matrix
Let’s make that basis look a little nicer by using some scalar multiplication to clear fractions.
This is definitely not an orthogonal basis. So we take , and
,
which equals something we probably don’t want to try to simplify. Finally, we find
.
And now we probably get about five minutes into the fractions and say something that shouldn’t appear in print. This sounds like a job for the computer.
What if we want our vectors normalized? Turns out the GramSchmidt function has an optional argument of true or false. The default is false, which is to not normalize. Setting it to true gives an orthonormal basis:
OK, so that’s nice, and fairly intimidating looking. Did it work? We can specify the vectors in our list by giving their positions, which are 0, 1, and 2, respectively.
First, note that we can actually jump right into the Gram-Schmidt procedure. If the set is not a basis, then it won’t be independent, and when we attempt to construct the third vector in our orthonormal basis, its projection on the the subspace spanned by the first two will be the same as the original vector, and we’ll get zero when we subtract the two.
We got it done! But doing this sort of thing by hand makes it possible that we made a calculation error somewhere. To check our work, we can turn to the computer.
Success! Full disclosure: there was indeed a mistake in the manual computation. Whether it was a typo or a miscalculation, the entry was originally written as . This led, as you might expect, to some very wrong answers for .