Calculus &
Linear Algebra II

Chapter 11

11 Gram-Schmidt process


The goal of this section is to discuss orthogonal projections, and develop a way of constructing an orthonormal basis for an inner product space.






11.1 Orthogonal set

Let $V$ be a real inner product space. A nonempty set of vectors in $V$ is orthogonal if each vector in the set is orthogonal to all the other vectors in the set. That is, the set $\{\bfv_1,\ldots,\bfv_n\}\subseteq V$ is orthogonal if $$ \langle\bfv_i,\bfv_j\rangle=0,\qquad i\neq j. $$ Let $S$ be a finite set of vectors in $V$ such that ${\bf 0}\notin S$. Then,

$S$ orthogonal $\Longrightarrow$ $S$ linearly independent.



11.1 Orthogonal set

$S$ orthogonal $\Longrightarrow$ $S$ linearly independent.

Let $S = \left\{\v_1, \v_2, \ldots, \v_n\right\}$ be orthogonal and consider \[ k_1 \v_1 + k_2\v_2 + \cdots + k_n\v_n = \mathbf 0. \] Then for any $\v_i\in S$

$0 $ $=$ $ \langle \mathbf 0, \v_i \rangle$ $= \langle k_1 \v_1 + \cdots + k_n\v_n, \v_i \rangle$
$=$ $ k_1 \langle \v_1 , \v_i \rangle + \cdots + k_n \langle \v_n , \v_i \rangle$
$=$ $ k_i \langle \v_i , \v_i \rangle$   by orthogonality.

Since $\mathbf 0 \notin S$, we have that $\v_i\neq \mathbf 0$ and so $\langle \v_i, \v_i \rangle \neq 0$ $\,\Ra \, k_i =0\; \forall i.$ Therefore $\ds \left\{\v_1, \v_2, \ldots, \v_n\right\}$ is linearly independent. $\; \blacksquare$


11.1 Orthogonal set


11.2 Orthonormal basis

An orthogonal set of vectors in $V$ is called orthonormal if all the vectors in the set are unit vectors. That is, the set $\{\bfe_1,\ldots,\bfe_n\}\subset V$ is orthonormal if $$ \langle\bfe_i,\bfe_j\rangle=\delta_{i,j}, $$ where the Kronecker delta is defined by $$ \delta_{i,j}=\begin{cases} \,0,\ & i\neq j,\\[.15cm] \,1,\ &i=j. \end{cases} $$

Examples in $\R^n$ endowed with the usual dot product are given as follows:


11.2 Orthonormal basis

Examples in $\R^n$ endowed with the usual dot product are given as follows:

Example 1: $\left\{ (1,0,0), (0,1,0), (0,0,1)\right\}$ orthonormal set.


Example 2: $\mathcal S = \left\{ \left( \frac{1}{\sqrt{3}},\frac{1}{\sqrt{3}},\frac{1}{\sqrt{3}} \right), \left(-\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}},0\right) \right\}$ orthonormal set in $\R^3$.


Example 3: $\mathcal S \cup \left\{ \left( \frac{1}{\sqrt{6}},\frac{1}{\sqrt{6}},-\frac{2}{\sqrt{6}} \right) \right\}$ orthonormal set in $\R^3$.



11.2 Orthonormal basis


11.2 Orthonormal basis

Examples in $\R^n$ endowed with the usual dot product are given as follows:

Example 1: $\left\{ (1,0,0), (0,1,0), (0,0,1)\right\}$ orthonormal set.

Example 2: $\mathcal S = \left\{ \left( \frac{1}{\sqrt{3}},\frac{1}{\sqrt{3}},\frac{1}{\sqrt{3}} \right), \left(-\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}},0\right) \right\}$ orthonormal set in $\R^3$.

Example 3: $\mathcal S \cup \left\{ \left( \frac{1}{\sqrt{6}},\frac{1}{\sqrt{6}},-\frac{2}{\sqrt{6}} \right) \right\}$ orthonormal set in $\R^3$.

An orthonormal basis for $V$ is a basis for $V$ that is also an orthonormal set.

The sets in Examples 1 and 3 are also orthonormal basis for $\R^3$, but the set in Example 2 is NOT a basis for $\R^3$.



11.3 Decomposition theorem

Let $S=\{\bfe_1,\ldots,\bfe_n\}$ be an orthonormal basis for $V$, and let $\bfu\in V$. Then, $$ \bfu=\langle\bfu,\bfe_1\rangle\bfe_1+\ldots+\langle\bfu,\bfe_n\rangle\bfe_n $$ and $$ ||\bfu||^2=\langle\bfu,\bfe_1\rangle^2+\ldots+\langle\bfu,\bfe_n\rangle^2. $$





11.3 Decomposition theorem

Proof: Since $S=\{\bfe_1,\ldots,\bfe_n\}$ is a basis, we can write for any $\u\in V$ \[ \u = a_1\bfe_1 + a_2\bfe_2 + \cdots + a_n\bfe_n. \]

Then, for $i = 1, \ldots n$, we have

$\langle \u, \bfe_i \rangle$ $=$ $\langle a_1\bfe_1 + a_2\bfe_2 + \cdots + a_n\bfe_n, \bfe_i \rangle$
$=$ $a_1\langle \bfe_1 , \bfe_i \rangle+ \cdots + a_n\langle \bfe_n , \bfe_i \rangle$
$=$ $a_i\langle \bfe_i , \bfe_i \rangle$ $\,=a_i. \qquad \blacksquare$

Extra: $\norm{\u}^2 = \langle \u ,\u \rangle $ $= \langle \u ,\bfe_1 \rangle ^2+ \cdots +\langle \u ,\bfe_n \rangle ^2.$



11.4 Orthogonal projection

Let $U$ be a finite-dimensional subspace of the real inner product space $V$. Then, each $\bfv\in V$ can be written in a unique way as $$ \bfv=\bfu+\bfw,\qquad \bfu\in U,\quad \bfw\in U^\bot. $$ In the proof, we will assume that $U$ has an orthonormal basis $S=\{\bfe_1,\ldots,\bfe_k\}$. As we will see in Section 11.6, this assumption is redundant since every finite-dimensional inner product space has such a basis.




11.4 Orthogonal projection

Proof: Let $\v\in S$, then $\v = \u + (\v - \u)$ for any $\u \in U.$ Set \[ \u = \langle \v, \bfe_1 \rangle \bfe_1 + \cdots + \langle \v, \bfe_n \rangle \bfe_n, \quad \text{then }\u \in U. \quad (\star) \] and set $\w = \v-\u$. Then for $i = 1 , \ldots , k$ we have

$\langle \w, \bfe_i \rangle$ $=$ $\langle \v - \langle \v, \bfe_1\rangle\bfe_1 - \cdots - \langle \v, \bfe_k\rangle\bfe_k, \bfe_i \rangle$
$=$ $\langle \v , \bfe_i \rangle- \langle \v , \bfe_i \rangle \langle \bfe_i , \bfe_i \rangle$
$=$ $\langle \v , \bfe_i \rangle- \langle \v , \bfe_i \rangle $ $\,=0$

Then $\w$ is orthogonal to every vector in $U= \text{span} (S)$, which implies $\w\in U^{\perp}.$


11.4 Orthogonal projection

Proof: For uniqueness let $\v = \u + \w$ and $\v = \u'+ \w'$, where $\u, \u'\in U$ and $\w, \w'\in U^{\perp}$. Then \[ \u - \u' = \w' - \w \] but $U \cap U^{\perp} = \{\mathbf 0\}.$ Then \[ \u - \u' = \mathbf 0 = \w'- \w. \] That is $\u = \u'$ and $\w=\w'.$ This implies uniqueness. $\; \blacksquare$




11.4 Orthogonal projection

The vector $\bfu\in U$ is called the orthogonal projection of $\bfv$ onto $U$ and is given by $$ \mathrm{Proj}_U(\bfv)=\langle\bfv,\bfe_1\rangle\bfe_1+\ldots+\langle\bfv,\bfe_k\rangle\bfe_k. $$ Likewise, the vector $\bfw\in U^\bot$ is called the orthogonal projection of $\bfv$ onto $U^\bot$ and is given by $$ \mathrm{Proj}_{U^\bot}(\bfv)=\bfv-\mathrm{Proj}_U(\bfv). $$



11.4 Orthogonal projection

One can show that $$ \dim V=\dim U+\dim U^\bot. $$ This can be very helpful when determining the orthogonal complement of a subspace $U$. Indeed, suppose you have managed to find $\dim V-\dim U$ linearly independent vectors that are all orthogonal to $U$. Then, these vectors will, in fact, form a basis for $U^\bot$. This property will be used in the next example.



11.5 Example: Orthogonal projection in $\R^3$

Let $\R^3$ be endowed with the usual dot product, and let $$ U= {\rm span}\left(\left\{(0,1,0),\left(-\dfrac{4}{5},0,\dfrac{3}{5}\right)\right\}\right),\quad \bfv=(1,1,1). $$ Find the orthogonal projections of $\bfv$ onto $U$ and $U^\bot$.

First, consider $U = \text{span}(S)$, where $$S= \left\{ \bfe_1 = (0,1,0), \bfe_2= (-4/5, 0, 3/5)\right\}$$ is orthonormal (Check it!📝).



11.5 Example: Orthogonal projection in $\R^3$

Orthogonal projection onto $U$ means

$\u$ $=$ $\mathrm{Proj}_{U}(\v)$ $\,=\, \langle \v, \bfe_1\rangle\bfe_1 + \langle \v, \bfe_2\rangle\bfe_2$
$=$ $\cdots$ $\,=\, \bfe_1 - \frac{1}{5} \bfe_2$ $\,=\, \ds\left(\frac{4}{25} , 1, - \frac{3}{25}\right).$

Orthogonal projection onto $U^{\perp}$ means

$\w$ $=$ $\mathrm{Proj}_{U^{\perp}}(\v)$ $\,=\, \v - \u$
$=$ $\ds \left(\frac{21}{25} , 0, \frac{28}{25}\right).$


11.6 Construction of orthonormal basis

It is often convenient to have an orthonormal basis for a given finite-dimensional inner product space. The following algorithm turns a linearly independent set of vectors into an orthonormal set of vectors with the same span as the original set. Applying the algorithm to a basis thus turns the basis into an orthonormal basis. Hence:

Every finite-dimensional real inner product space has an orthonormal basis.



11.6 Construction of orthonormal basis

It is often convenient to have an orthonormal basis for a given finite-dimensional inner product space. The following algorithm turns a linearly independent set of vectors into an orthonormal set of vectors with the same span as the original set. Applying the algorithm to a basis thus turns the basis into an orthonormal basis. Hence:

Every finite-dimensional real inner product space has an orthonormal basis.

Let $\{\bfv_1,\ldots,\bfv_n\}$ be a linearly independent set of vectors in the real inner product space $V$.

The corresponding Gram-Schmidt process is the following algorithm:



11.6 Construction of orthonormal basis

The corresponding Gram-Schmidt process is the following algorithm:

Step 1. Let $\w_1 = \v_1$. (Easy! 😃)

Step 2. We can obtain a vector $\w_2$ that is orthogonal to $\w_1$ by computing the component of $\v_2$ that is orthogonal to the space $W_1$ spanned by $\w_1$. To do this we use the formula: \[ \w_2 = \v_2 - \mathrm{Proj}_{W_1} \v_2 = \v_2 - \frac{\langle \v_2, \w_1 \rangle}{\norm{\w_1}^2}\w_1. \]





11.6 Construction of orthonormal basis

The corresponding Gram-Schmidt process is the following algorithm:

Step 1. Let $\w_1 = \v_1$. (Easy! 😃)

Step 2. We can obtain a vector $\w_2$ that is orthogonal to $\w_1$ by computing the component of $\v_2$ that is orthogonal to the space $W_1$ spanned by $\w_1$. To do this we use the formula: \[ \w_2 = \v_2 - \mathrm{Proj}_{W_1} \v_2 = \v_2 - \frac{\langle \v_2, \w_1 \rangle}{\norm{\w_1}^2}\w_1. \]

Step 3. To construct a vector $\w_3$ that is orthogonal to both $\w_1$ and $\w_2$, we compute the component of $\v_3$ orthogonal to the space $W_2$ spanned by $\w_1$ and $\w_2$. Here we use the formula: \[ \w_3 = \v_3 - \mathrm{Proj}_{W_2} \v_3 = \v_3 - \frac{\langle \v_3, \w_1 \rangle}{\norm{\w_1}^2}\w_1 - \frac{\langle \v_3, \w_2 \rangle}{\norm{\w_2}^2}\w_2. \]



11.6 Construction of orthonormal basis

Step 1. Let $\w_1 = \v_1$. (Easy! 😃)

Step 2. We can obtain a vector $\w_2$ that is orthogonal to $\w_1$ by computing the component of $\v_2$ that is orthogonal to the space $W_1$ spanned by $\w_1$. To do this we use the formula: \[ \w_2 = \v_2 - \mathrm{Proj}_{W_1} \v_2 = \v_2 - \frac{\langle \v_2, \w_1 \rangle}{\norm{\w_1}^2}\w_1. \]

Step 3. To construct a vector $\w_3$ that is orthogonal to both $\w_1$ and $\w_2$, we compute the component of $\v_3$ orthogonal to the space $W_2$ spanned by $\w_1$ and $\w_2$. Here we use the formula: \[ \w_3 = \v_3 - \mathrm{Proj}_{W_2} \v_3 = \v_3 - \frac{\langle \v_3, \w_1 \rangle}{\norm{\w_1}^2}\w_1 - \frac{\langle \v_3, \w_2 \rangle}{\norm{\w_2}^2}\w_2. \]

Step n. Continuing in this way we will produce after $n$ steps an orthogonal set of nonzero vectors $\left\{\w_1, \w_2, \ldots, \w_n \right\}.$

Final step. To convert the orthogonal basis into an orthonormal basis $\left\{\mathbf q_1, \mathbf q_2, \ldots, \mathbf q_n \right\},$ normalize the orthogonal basis vectors.



11.6 Construction of orthonormal basis

Inspired by Lucas Vieira - @LucasVB


The Gram-Schmidt Process

To convert a basis $\{\v_1, \ldots, \v_n\}$ into an orthogonal basis $\{\mathbf w_1, \mathbf w_2, \ldots, \mathbf w_n\}$, perform the following computations:

Step 1. Let $\w_1 = \v_1$ (Easy! 😃)

Step 2. $\ds \w_2 = \v_2 - \frac{\langle \v_2, \w_1 \rangle}{\norm{\w_1}^2}\w_1$

Step 3. $\ds\w_3 = \v_3 - \frac{\langle \v_3, \w_1 \rangle}{\norm{\w_1}^2}\w_1 - \frac{\langle \v_3, \w_2 \rangle}{\norm{\w_2}^2}\w_2$

$\qquad\quad\quad\vdots$

Step n. $\ds\w_n = \v_n - \sum_{k=1}^{n-1}\frac{\langle \v_n, \w_k \rangle}{\norm{\w_k}^2}\w_k $

Final step. To convert the orthogonal basis $\{\mathbf w_1, \ldots, \mathbf w_n\}$ into an orthonormal basis $\left\{\mathbf q_1, \ldots, \mathbf q_n \right\},$ normalize the orthogonal basis vectors.



11.7 Example: Orthonormal basis for $P_1(\R)$

Exercise: 📝 Here the inner product is \[ \langle \mathbf p, \mathbf q \rangle= \int_{-1}^{1}p(x)q(x)dx \] and the basis is $\beta = \left\{1+ x, 1-2x\right\}$.





Credits