EXAMPLE OF FINDING QR FACTORIZATION

Here is another example of orthonormalization and writing a matrix in QR form.
This one involves three vectors. Let v_1 =

3
4
0
0

v_2 =

3
4
6
8

and v_3 =

2
1
2
1

We want to find an orthonormal basis for the span V of v_1, v_2, v_3, and we also want the QR factorization of the matrix formed from the v's, namely

3 3 2
4 4 1
0 6 2
0 8 1

Note that Q will be the 4 by 3 matrix formed from the w's, while R = [r_ij] will be a 3 by 3 upper triangular matrix whose entries are computed in the course of finding the w's.

w_1 = (1/|| v_1 ||) v_1 = (1/5)v_1 =

3/5
4/5
0
0

and this also tells us that \$r_11 = || v_1 || = 5.

To find w_2 first subtract the projection of v_2 on the line through w_1. Since v_2 . w_1 = 25/5 = 5, which is also r_12, the projection is 5w_1 which is

3
4
0
0

and subtracting this from v_2 gives

0
0
6
8

The length of this vector is r_22 = 10 and dividing by it gives w_2 which is

0
0
3/5
4/5

The dot product of v_3 and w_1 is 6/5 + 4/5 = 2 = r_13,
the dot product of v_3 and w_2 is 6/5 + 4/5 = 2 = r_23,
and then v_3 - 2 w_1 - 2 w_2 =

2            6/5               0
1     -     8/5     -       0
2               0             6/5
1               0             8/5

which is

4/5
-3/5
4/5
-3/5

The length of this vector is the square root of (16+9+16+9)/25 , i.e., the square root of 2, and so r_33 = 2^.5. Dividing the vector above by 2^.5, which is the same as multiplying by 2^.5/2, we find that w_3 =

4(2^.5)/10
-3(2^.5)/10
4(2^.5)/10
-3(2^.5)/10

We could make use of the fact that 4(2^.5)/10 = 2(2^.5)/5 but we shall leave w_3 as is. Thus, Q is the matrix with columns w_1, w_2, w_3 and is

3/5       0      4(2^.5)/10
4/5       0   -3(2^.5)/10
0   3/5      4(2^.5)/10
0   4/5   -3(2^.5)/10

and R is the matrix (entries computed as we went along):

r_11   r_12       r_13
0      r_22       r_23
0        0           r_33

or

5    5     2
0   10     2
0    0   2^.5

One can check that QR =

3 3 2
4 4 1
0 6 2
0 8 1

as required.