Gram-Schmidt Orthonormalization
We can orthonormalize a set of vectors into an orthonormal set by executing the following algorithm:
- Normalize by setting .
- For :
- Orthogonalize with respect to the direction of each the previously computed vectors by subtracting from the projection of onto the subspace of , such that .
- Normalize by setting .
Intuition
In short, Gram-Schmidt normalizes the first vector in the set and orthogonalizes all subsequent vectors by subtracting from them their orthogonal projections onto the span of all previously orthonormalized vectors, which leaves them orthogonal to that span. Then they are simply normalized and the process is repeated.
Example
We can illustrate the Gram-Schmidt process as follows. In this case, we limit our set to three vectors . We first set to normalize (since ). We can then illustrate the 3 vectors in as follows:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% Vectors
\draw[->, thick, green] (0,0) -- (2,3) node[midway, above left] {$\vec{a}_2$};
\draw[->, thick, red] (0,0) -- (3,1) node[midway, above] {$\vec{a}_1$};
\draw[->, thick, orange] (0,0) -- ({3 / sqrt(10)},{1 / sqrt(10)}) node[midway, below] {$\vec{q}_1$};
\end{tikzpicture}
\end{document}Note that . Now we start the second part of the process by setting illustrated as:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% Vectors
\draw[->, thick, green] (0,0) -- (2,3) node[midway, above left] {$\vec{a}_2$};
\draw[->, thick, red] (0,0) -- (3,1) node[below right] {$\vec{a}_1$};
\draw[->, thick, dashed, pink] (0,0) -- (27/10,9/10) node[midway, below right] {$\mathrm{proj}_{\mathrm{Span}(\vec{q}_1)}(\vec{a}_2)$};
\draw[->, thick, orange] (0,0) -- ({3 / sqrt(10)},{1 / sqrt(10)}) node[midway, below] {$\vec{q}_1$};
\draw[->, thick, magenta] (0,0) -- (-7/10,21/10) node[midway, left] {$\vec{z}_2$};
\draw[->, thick, dashed, purple] (2,3) -- (27/10,9/10) node[midway, right] {$\vec{a}_2-\mathrm{proj}_{\mathrm{Span}(\vec{q}_1)}(\vec{a}_2)$};
\end{tikzpicture}
\end{document}Let’s take a second to deconstruct what’s happening. Essentially, we are calculating as a vector that is orthogonal to the span of (and in higher dimensions simultaneously to the span of ). We do this by subtracting from the orthonormal projection of onto the span. This is because captures all the components of in the direction of , so subtracting it from leaves it only the components of the vector that are orthogonal to the span. The actual dimensions of do not matter as long as it’s orthogonal to .
We now continue with the second part of the final step of our algorithm, where we calculate the normalized . We can illustrate our space as:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% Vectors
\draw[->, thick, green] (0,0) -- (2,3) node[midway, above left] {$\vec{a}_2$};
\draw[->, thick, red] (0,0) -- (3,1) node[right] {$\vec{a}_1$};
\draw[->, thick, dashed, pink] (0,0) -- (27/10,9/10) node[midway, below right] {$\mathrm{proj}_{\mathrm{Span}(\vec{q}_1)}(\vec{a}_2)$};
\draw[->, thick, orange] (0,0) -- ({3 / sqrt(10)},{1 / sqrt(10)}) node[midway, below] {$\vec{q}_1$};
\draw[->, thick, magenta] (0,0) -- (-7/10,21/10) node[left] {$\vec{z}_2$};
\draw[->, thick, dashed, purple] (2,3) -- (27/10,9/10) node[midway, right] {$\vec{a}_2-\mathrm{proj}_{\mathrm{Span}(\vec{q}_1)}(\vec{a}_2)$};
\draw[->, thick, yellow] (0,0) -- ({-sqrt(10) / 10},{3 * sqrt(10) / 10}) node[midway, left] {$\vec{q}_2$};
\end{tikzpicture}
\end{document}As such, form an orthonormal basis for where .
Case
What if there was another vector in our set such that our set is now ? This step requires some more calculation in our algorithm. We can continue with how we left our algorithm above so that we calculate . Note that the two vectors in the brackets (illustrated in pink in the plot below) represent and respectively. Check out the plot below for an illustration:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% Vectors
\draw[->, thick, green] (0,0) -- (2,3) node[midway, above left] {$\vec{a}_2$};
\draw[->, thick, red] (0,0) -- (3,1) node[right] {$\vec{a}_1$};
\draw[->, thick, teal] (0,0) -- (-3,1) node[midway, above left] {$\vec{a}_3$};
\draw[->, thick, orange] (0,0) -- ({3 / sqrt(10)},{1 / sqrt(10)}) node[midway, below] {$\vec{q}_1$};
\draw[->, thick, yellow] (0,0) -- ({-sqrt(10) / 10},{3 * sqrt(10) / 10}) node[midway, left] {$\vec{q}_2$};
\draw[->, thick, pink] (0,0) -- (-3/8,-1/8) node[midway, above left]{};
\draw[->, thick, pink] (0,0) -- (-1/6,1/2) node[midway, above left]{};
\draw[->, thick, magenta] (0,0) -- (-59/24, 5/8) node[midway, below]{$\vec{z}_3$};
\end{tikzpicture}
\end{document}Then, we can calculate the normalized version of as , represented below:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% Vectors
\draw[->, thick, green] (0,0) -- (2,3) node[midway, above left] {$\vec{a}_2$};
\draw[->, thick, red] (0,0) -- (3,1) node[right] {$\vec{a}_1$};
\draw[->, thick, teal] (0,0) -- (-3,1) node[midway, above left] {$\vec{a}_3$};
\draw[->, thick, orange] (0,0) -- ({3 / sqrt(10)},{1 / sqrt(10)}) node[midway, below] {$\vec{q}_1$};
\draw[->, thick, yellow] (0,0) -- ({-sqrt(10) / 10},{3 * sqrt(10) / 10}) node[midway, left] {$\vec{q}_2$};
\draw[->, thick, pink] (0,0) -- (-3/8,-1/8) node[midway, above left]{};
\draw[->, thick, pink] (0,0) -- (-1/6,1/2) node[midway, above left]{};
\draw[->, thick, magenta] (0,0) -- (-59/24, 5/8) node[midway, below]{$\vec{z}_3$};
\draw[->, thick, brown] (0,0) -- ({-59/sqrt(3706)}, {15 / sqrt(3706)}) node[midway, below]{$\vec{q}_3$};
\end{tikzpicture}
\end{document}As such, the Gram-Schmidt process is inapplicable for , where is the dimension of the vectors. This stems from the simple fact that in -space, you cannot have more than $n$ linearly independent vectors.
Example
Extending Basis