QR decomposition: examples
Consider the
matrix
![Rendered by QuickLaTeX.com \[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).\]](https://ecampusontario.pressbooks.pub/app/uploads/quicklatex/quicklatex.com-be94bbae78a46dc0ed57670425c959b6_l3.png)
This matrix is full column rank. Indeed, the matlab command [Q,R]=qr(A,0) yields a
and a
:
![Rendered by QuickLaTeX.com \[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),\]](https://ecampusontario.pressbooks.pub/app/uploads/quicklatex/quicklatex.com-224d9e697b2c1278554125af8f436f1c_l3.png)
![Rendered by QuickLaTeX.com \[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).\]](https://ecampusontario.pressbooks.pub/app/uploads/quicklatex/quicklatex.com-f2305d0019450598a958ba08182820ae_l3.png)
This shows that
is full column rank since
is invertible.
The command [Q,R]=qr(A) actually produces the full QR decomposition, with
now a
orthogonal matrix:
![Rendered by QuickLaTeX.com \[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),\]](https://ecampusontario.pressbooks.pub/app/uploads/quicklatex/quicklatex.com-b9bcf52880698d976524d84f45ee0ae4_l3.png)
![Rendered by QuickLaTeX.com \[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).\]](https://ecampusontario.pressbooks.pub/app/uploads/quicklatex/quicklatex.com-9a6115219ee959b9601dbda25d63417d_l3.png)
We can see what happens when the input is not full column rank: for example, let’s consider the matrix
![Rendered by QuickLaTeX.com \[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).\]](https://ecampusontario.pressbooks.pub/app/uploads/quicklatex/quicklatex.com-a025d13efe8b4df9193460c738d07dcf_l3.png)
(
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:
![Rendered by QuickLaTeX.com \[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).\]](https://ecampusontario.pressbooks.pub/app/uploads/quicklatex/quicklatex.com-19e692ff78c27888cf3a5923df06b033_l3.png)
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
(itself equal to the rank of
) is effectively
.