Using Gram-Schmidt to find the QR decomposition

linear algebramatrices

I'm having problems doing a QR decomposition of a matrix…

Let $A=\begin{bmatrix}
{1} & {1} & {0} \\
{0} &{1} &{1} \\
{1} & {0} &{1}
\end{bmatrix}$

Find the QR decomposition for A

Here's what I've been doing:

I choose this basis, $B=\left \{(1,0,1), (1,1,0), (0,1,1)\right \}$ (the columns of the matrix).

Now I use the Gram-Schmidt process (and this is where I'm having trouble)

$u_{1}=(1,0,1)$

$u_{2}=(1,1,0)$ (cuz $<(1,0,1), (1,1,0)>=0$)

$u_{3}=(0,1,1)-\frac{<(0,1,1), (1,1,0)>}{<(1,1,0), (1,1,0)>}(1,1,0)-\frac{<(0,1,1), (1,0,1)>}{<(1,0,1), (1,0,1)>}(1,0,1)=$ $(0,1,1)-1/2(1,1,0)-1/2(1,0,1)=(-1, 1/2, 1/2)$

And now I find the norm for all the three vectors:

$||u_{1}||=||u_{2}||=||u_{3}||=\sqrt{2}$

So the orthonormal basis must be $B'= \left \{(\frac{1}{\sqrt{2}},0,\frac{1}{\sqrt{2}}), (\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}},0), (\frac{-1}{\sqrt{2}}, \frac{1}{2\sqrt{2}}, \frac{1}{2\sqrt{2}})\right \}$ (Which it isn't orthonormal)

So $Q=\begin{bmatrix}
{\frac{1}{\sqrt{2}}} & {\frac{1}{\sqrt{2}}} & {\frac{-1}{\sqrt{2}}} \\
{0} &{\frac{1}{\sqrt{2}}} &{\frac{1}{2\sqrt{2}}} \\
{\frac{0}{\sqrt{2}}} & {0} &{\frac{1}{2\sqrt{2}}}
\end{bmatrix}$

Which $Q^{t}Q \neq I$ ($I$ being the identity matrix), so all I did was wrong…
Where's my mistake?

Best Answer

You're computing $u_2$ wrongly.

I find it useful to set up a systematic way, where the information can be picked up easily.

Let $v_1$, $v_2$ and $v_3$ be the three columns of $A$.

GS1

$u_1=v_1$

$\langle u_1,u_1\rangle=2$

GS2

$\alpha_{12}=\dfrac{\langle u_1,v_2\rangle}{\langle u_1,u_1\rangle}=\dfrac{1}{2}$

$u_2=v_2-\alpha_{12}u_1=\begin{bmatrix}1/2\\1\\-1/2\end{bmatrix}$

$\langle u_2,u_2\rangle=\dfrac{3}{2}$

GS3

$\alpha_{13}=\dfrac{\langle u_1,v_3\rangle}{\langle u_1,u_1\rangle}=\dfrac{1}{2}$

$\alpha_{23}=\dfrac{\langle u_2,v_3\rangle}{\langle u_2,u_2\rangle}=\dfrac{1}{3}$

$u_3=v_3-\alpha_{13}u_1-\alpha_{23}u_2=\begin{bmatrix}-2/3\\2/3\\2/3\end{bmatrix}$

$\langle u_3,u_3\rangle=\dfrac{4}{3}$

Matrix $Q$

The matrix $Q$ has as columns the vectors $u_1$, $u_2$ and $u_3$ divided by their norms: $$ Q=\begin{bmatrix} 1/\sqrt{2} & 1/\sqrt{6} & -1/\sqrt{3} \\ 0 & 2/\sqrt{6} & 1/\sqrt{3} \\ 1/\sqrt{2} & -1/\sqrt{6} & 1/\sqrt{3} \end{bmatrix} $$

Matrix $R$

The matrix $R$ is obtained by multiplying each row of the upper unitriangular with the entries $\alpha_{ij}$ by the norm of the corresponding $u$ vector. $$ R=\begin{bmatrix} 1 & 1/2 & 1/2 \\ 0 & 1 & 1/3 \\ 0 & 0 & 1 \end{bmatrix} \begin{array}{l}\cdot\sqrt{2}\\\cdot \sqrt{6}/2\\\cdot 2/\sqrt{3}\end{array}= \begin{bmatrix} \sqrt{2} & \sqrt{2}/2 & \sqrt{2}/2 \\ 0 & \sqrt{6}/2 & \sqrt{6}/6 \\ 0 & 0 & 2/\sqrt{3} \end{bmatrix} $$

Related Question