QR decomposition: examples

Consider the 4 \times 6 matrix

    \[A=\left(\begin{array}{cccc}0.488894 & 0.888396 & 0.325191 & 0.319207 \\ 1.03469 & -1.14707 & -0.754928 & 0.312859 \\ 0.726885 & -1.06887 & 1.3703 & -0.86488 \\ -0.303441 & -0.809499 & -1.71152 & -0.0300513 \\ 0.293871 & -2.94428 & -0.102242 & -0.164879 \\ -0.787283 & 1.43838 & -0.241447 & 0.627707\end{array}\right).\]

This matrix is full column rank. Indeed, the matlab command [Q,R]=qr(A,0) yields a 6 \times 4 Q and a 4 \times 4 R:

    \[A=Q R, \quad Q=\left(\begin{array}{cccc}0.301109 & 0.460748 & -0.0940935 & 0.24499 \\ 0.637266 & 0.0433642 & -0.558601 & 0.251199 \\ 0.447688 & -0.0504968 & 0.519798 & -0.41105 \\ -0.186889 & -0.365412 & -0.617955 & -0.489793 \\ 0.180995 & -0.79363 & 0.163942 & 0.492111 \\ -0.484886 & 0.141088 & -0.0132838 & 0.475232\end{array}\right),\]

    \[R=\left(\begin{array}{cccc}1.62364 & -2.02107 & 0.648726 & -0.420299 \\ 0 & 3.24897 & 0.720385 & 0.434711 \\ 0 & 0 & 2.14747 & -0.67116 \\ 0 & 0 & 0 & 0.744188\end{array}\right).\]

This shows that A is full column rank since R is invertible.

The command [Q,R]=qr(A) actually produces the full QR decomposition, with Q now a 6 \times 6 orthogonal matrix:

    \[Q=\left(\begin{array}{cccccc}0.301109 & 0.460748 & -0.0940935 & 0.24499 & 0.692493 & -0.385519 \\ 0.637266 & 0.0433642 & -0.558601 & 0.251199 & -0.253083 & 0.390928 \\ 0.447688 & -0.0504968 & 0.519798 & -0.41105 & 0.332021 & 0.49763 \\ -0.186889 & -0.365412 & -0.617955 & -0.489793 & 0.452645 & 0.0699514 \\ 0.180995 & -0.79363 & 0.163942 & 0.492111 & 0.213643 & -0.15066 \\ -0.484886 & 0.141088 & -0.0132838 & 0.475232 & 0.309248 & 0.650633\end{array}\right),\]

    \[R=\left(\begin{array}{cccc}1.62364 & -2.02107 & 0.648726 & -0.420299 \\ 0 & 3.24897 & 0.720385 & 0.434711 \\ 0 & 0 & 2.14747 & -0.67116 \\ 0 & 0 & 0 & 0.744188 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0\end{array}\right).\]

We can see what happens when the input is not full column rank: for example, let’s consider the matrix

    \[A=\left(\begin{array}{cccc}1.09327 & 1.10927 & -0.863653 & 1.32288 \\ -1.21412 & -1.1135 & -0.00684933 & -2.43508 \\ -0.769666 & 0.371379 & -0.225584 & -1.76492 \\ -1.08906 & 0.0325575 & 0.552527 & -1.6256 \\ 1.54421 & 0.0859311 & -1.49159 & 1.59683\end{array}\right).\]

(A is not full column rank, as it was constructed so that the last column is a combination of the first and the third.)

The (full) QR decomposition now yields:

    \[R=\left(\begin{array}{cccc}2.61388 & 0.909015 & -1.40302 & 3.82473 \\ 0 & 1.33807 & 0.0979073 & 0.0979073 \\ 0 & 0 & 1.16142 & 1.16142 \\ 0 & 0 & 0 & 0.00000 \\ 0 & 0 & 0 & 0\end{array}\right).\]

We observe that the last triangular element is virtually zero, and the last column is seen to be a linear combination of the first and the third. This shows that the rank of R (itself equal to the rank of A) is effectively 3.

License

Hyper-Textbook: Optimization Models and Applications Copyright © by L. El Ghaoui. All Rights Reserved.

Share This Book