3.6: Gram-Schmidt Process
View Gram-Schmidt Process on YouTube
View Gram-Schmidt Process Example on YouTube
Given any basis for a vector space, we can use an algorithm called the Gram-Schmidt process to construct an orthonormal basis for that space. Let the vectors \(\text{v}_1,\: \text{v}_2,\cdots , \text{v}_n\) be a basis for some \(n\)-dimensional vector space. We will assume here that these vectors are column matrices, but this process also applies more generally.
We will construct an orthogonal basis \(\text{u}_1,\: \text{u}_2,\cdots , \text{u}_n\), and then normalize each vector to obtain an orthonormal basis. First, define \(\text{u}_1 = \text{v}_1\). To find the next orthogonal basis vector, define
\[\text{u}_2=\text{v}_2-\frac{(\text{u}_1^{\text{T}}\text{v}_2)\text{u}_1}{\text{u}_1^{\text{T}}\text{u}_1}.\nonumber \]
Observe that \(\text{u}_2\) is equal to \(\text{v}_2\) minus the component of \(\text{v}_2\) that is parallel to \(\text{u}_1\). By multiplying both sides of this equation with \(\text{u}_1^{\text{T}}\), it is easy to see that \(u_1^{\text{T}}\text{u}_2 = 0\) so that these two vectors are orthogonal.
The next orthogonal vector in the new basis can be found from
\[\text{u}_3=\text{v}_3-\frac{(\text{u}_1^{\text{T}}\text{v}_3)\text{u}_1}{\text{u}_1^{\text{T}}\text{u}_1}-\frac{(\text{u}_2^{\text{T}}\text{v}_3)\text{u}_2}{\text{u}_2^{\text{T}}\text{u}_2}.\nonumber \]
Here, \(\text{u}_3\) is equal to \(\text{v}_3\) minus the components of \(\text{v}_3\) that are parallel to \(\text{u}_1\) and \(\text{u}_2\). We can continue in this fashion to construct n orthogonal basis vectors. These vectors can then be normalized via
\[\hat{\text{u}}_1=\frac{\text{u}_1}{(\text{u}_1^{\text{T}}\text{u}_1)^{1/2}},\quad\text{etc.}\nonumber \]
Since \(\text{u}_k\) is a linear combination of \(\text{v}_1,\: \text{v}_2,\cdots , \text{v}_k\), the vector subspace spanned by the first \(k\) basis vectors of the original vector space is the same as the subspace spanned by the first \(k\) orthonormal vectors generated through the Gram-Schmidt process. We can write this result as
\[\text{span}\{\text{u}_1,\:\text{u}_2,\cdots ,\text{u}_k\}=\text{span}\{\text{v}_1,\:\text{v}_2,\cdots ,\text{v}_k\}.\nonumber \]
To give an example of the Gram-Schmidt process, consider a subspace of \(\mathbb{R}^4\) with the following basis:
\[W=\left\{\left(\begin{array}{c}1\\1\\1\\1\end{array}\right),\quad\left(\begin{array}{c}0\\1\\1\\1\end{array}\right),\quad\left(\begin{array}{c}0\\0\\1\\1\end{array}\right)\right\}=\{\text{v}_1,\:\text{v}_2,\:\text{v}_3\}.\nonumber \]
We use the Gram-Schmidt process to construct an orthonormal basis for this subspace. Let \(\text{u}_1 = \text{v}_1\). Then \(\text{u}_2\) is found from
\[\begin{aligned}\text{u}_2&=\text{v}_2-\frac{(\text{u}_1^{\text{T}}\text{v}_2)\text{u}_1}{\text{u}_1^{\text{T}}\text{u}_1} \\ &=\left(\begin{array}{c}0\\1\\1\\1\end{array}\right)-\frac{3}{4}\left(\begin{array}{c}1\\1\\1\\1\end{array}\right)=\frac{1}{4}\left(\begin{array}{r}-3\\1\\1\\1\end{array}\right).\end{aligned} \nonumber \]
Finally, we compute \(\text{u}_3\):
\[\begin{aligned}\text{u}_3&=\text{v}_3-\frac{(\text{u}_1^{\text{T}}\text{v}_3)\text{u}_1}{\text{u}_1^{\text{T}}\text{u}_1}-\frac{(\text{u}_2^{\text{T}}\text{v}_3)\text{u}_2}{\text{u}_2^{\text{T}}\text{u}_2} \\ &=\left(\begin{array}{c}0\\0\\1\\1\end{array}\right)-\frac{1}{2}\left(\begin{array}{c}1\\1\\1\\1\end{array}\right)-\frac{1}{6}\left(\begin{array}{r}-3\\1\\1\\1\end{array}\right)=\frac{1}{3}\left(\begin{array}{r}0\\-2\\1\\1\end{array}\right).\end{aligned} \nonumber \]
Normalizing the three vectors, we obtain the orthonormal basis
\[W'=\left\{\frac{1}{2}\left(\begin{array}{c}1\\1\\1\\1\end{array}\right),\quad\frac{1}{2\sqrt{3}}\left(\begin{array}{r}-3\\1\\1\\1\end{array}\right),\quad\frac{1}{\sqrt{6}}\left(\begin{array}{r}0\\-2\\1\\1\end{array}\right)\right\}.\nonumber \]