Gram‐Schmidt Orthonormalization - drnickmines/MinesLinearAlgebra GitHub Wiki
In the previous lecture, we saw a few reasons why we would like to work with orthogonal bases:
- With an orthogonal basis, we can easily write a vector as a linear combination of the basis vectors.
- With an orthogonal basis, we can find the projection of a vector onto a subspace (which is the vector in the subspace closest to our given vector).
What we did not see is any explanation of how we can have an orthogonal basis. The process by which we construct an orthogonal basis for a space is called Gram-Schmidt Orthogonalization.
The key idea of Gram-Schmidt orthogonalization is from the previous lecture: given a vector
Once we've split
We will illustrate this algorithm first with an example, and then we will generalize it.
We start with a set of linearly independent vectors:
This set is linearly independent, so it is a basis for
- We are building a set of vectors, and we have to start somewhere. So we get started with the following definitions. Note that
$\large W_1$ is a subspace of$\large W$ :
- Now, we need a second vector orthogonal to the first. We will remove the portion of
$\large \vec{x}_2$ that lies in$\large W_1$ , leaving only a vector orthogonal to$\large W_1$ (and therefore, orthogonal to$\large \vec{v}_1$ ).
This is:
We now have two orthogonal vectors in
- (Optional Step). We can scale
$\large \vec{v}_2$ , and it will still be orthogonal to$\large \vec{v}_1$ . Since we're doing this by hand, we'll scale it to get rid of the fractions (when we have the computer do this, we don't scale it since the computer doesn't dislike fractions like we do).
- We follow our pattern and remove the part of
$\large\vec{x}_3$ that is aligned with$\large\vec{v}_1$ and$\large \vec{v}_2$ , leaving a$\large \vec{v}_3$ that is orthogonal to both.
This is:
We now have three orthogonal (and, therefore, linearly independent) vectors in a 3 dimensional subspace, so this set
The general algorithm follows the pattern established in the example. At each step, we remove from our vector any part aligned with the vectors in our growing basis, leaving something completely orthogonal to what we've built so far.
We start with a subspace and a set of linearly independent vectors:
- Define
$\large \vec{v}_1$ and$\large W_1$ to get started:
- Subtract off of
$\large \vec{x}_2$ the component that is in$\large W_1$ , leaving a$\large \vec{v}_2$ that is orthogonal to$\large W_1$ :
- Subtract off of
$\large \vec{x}_3$ the component that is in$\large W_2$ , leaving a$\large \vec{v}_3$ that is orthogonal to everything in$\large W_2$ :
- Subtract off of
$\large \vec{x}_m$ the component that is in the$\large (m-1)^{st}$ subspace, leaving a$\large \vec{v}_m$ that is orthogonal to everything in the$\large (m-1)^{st}$ subspace:
At the end of this process, we have an orthogonal basis
Note
This is a process that requires care and patience if we are doing it by hand. As you can imagine, only students do this by hand on HWs and tests! This is usually done via a computer. We will implement this in Python on a HW assignment
The following .gif illustrates the Gram-Schmidt process for a set of three vectors in
If we need an orthonormal basis instead of just an orthogonal basis, we simply normalize each vector at the end (divide each vector by its length).
I can:
- Use Gram-Schmidt algorithm to generate an orthogonal/orthonormal basis.