Consider the matrix
\(A=\left(\begin{array}{rrrr} -1 \amp 1 \amp 0 \amp 1 \\ 1 \amp -1 \amp 0 \amp 1 \\ -1 \amp 0 \amp 2 \amp 1 \end{array} \right)\text{.}\) Find an orthogonal basis of the row space of
\(A\text{.}\) It is easy to check that rank of
\(A\) is 3. Hence row are linearly independent vectors in
\(\R^4\text{.}\)
Let \(v_1=(-1,1,0,1), v_2 = (1,-1,0,1), v_3=(-1,0,2,1)
\text{.}\)
\begin{align*}
u_1: = \amp (-1,1,0,1)\\
u_2: = \amp v_2 -\frac{u_2\cdot u_1}{\norm{u_1}^2}u_1\\
=\amp (1,-1,0,1)-\frac{-1}{3}(-1,1,0,1)=(2/3, -2/3, 0, 4/3)\\
u_3: = \amp v_3 -\frac{u_3\cdot u_1}{\norm{u_1}^2}u_1-\frac{u_3\cdot u_2}{\norm{u_2}^2}u_2\\
= \amp (-1,0,2,1)-\frac{2}{3}(-1,1,0,1)-\frac{2/3}{9/2}(2/3, -2/3, 0, 4/3)\\
=\amp (-1/2, -1/2, 2, 0)
\end{align*}
Hence
\begin{equation*}
\{(-1, 1, 0, 1), (2/3, -2/3, 0, 4/3), (-1/2, -1/2, 2, 0)\}
\end{equation*}
is an orthogonal basis of the row space of \(A\text{.}\)
Sage also has an inbuilt method for Gramm-Schmidt orthogonalization process. For example,
A.gram_schmidt()
performs Gram-Schmidt orthogonalization on the rows of the matrix,
\(A\) returning a new matrix and a matrix accomplishing the transformation.
Here
\(Q\) is the matrix whose rows are nothing but orthogonal vectors obtained by Gram-Schmidt and
\(R\) is an upper triangular matrix. We shall see meaning of
\(R\) and how it is obtained in later sections.