QR decomposition
Encyclopedia : Q : QR : QRD : QR decomposition
In linear algebra, the QR decomposition of a matrix is a decomposition of the matrix into an orthogonal and a triangular matrix. The QR decomposition is often used to solve the linear least squares problem. The QR decomposition is also the basis for a particular eigenvalue algorithm, the QR algorithm.
Definition
A QR decomposition of a real square matrix A is a decomposition of A as- [ A = QR, \, ]
More generally, we can factor a complex [m]×[n] matrix (with m ≥ n) as the product of an [ m]×[n] unitary matrix (in the sense that Q∗Q = I ) and an [n]×[ n] upper triangular matrix.
If A is nonsingular, then this factorization is unique if we require that the diagonal elements of R are positive.
Computing the QR decomposition
There are several methods for actually computing the QR decomposition, such as by means of Givens rotations, Householder transformations, or the Gram-Schmidt decomposition. Each has a number of advantages and disadvantages.Computing QR by means of Gram-Schmidt
Recall the Gram-Schmidt method, with the vectors to be considered in the process as columns of the matrix [A=(\mathbf_1| \cdots|\mathbf_n)]. Then- [\mathbf_1 = \mathbf_1, \qquad\mathbf_1 = _1 \over \|\mathbf_1\|}]
- [\mathbf_2 = \mathbf_2-\mathrm__1}\,\mathbf_2, \qquad\mathbf_2 = _2 \over \|\mathbf_2\|}]
- [\mathbf_3 = \mathbf_3-\mathrm__1}\,\mathbf_3-\mathrm__2}\,\mathbf_3, \qquad\mathbf_3 = _3 \over \|\mathbf_3\|} ]
- :[\vdots]
- [\mathbf_k = \mathbf_k-\sum_^\mathrm__j}\,\mathbf_k,\qquad\mathbf_k = _k\over\|\mathbf_k\|}]
- [\mathbf_1 = \mathbf_1\|\mathbf_1\| ]
- [\mathbf_2 = \mathrm__1}\,\mathbf_2+\mathbf_2\|\mathbf_2\| ]
- [\mathbf_3 = \mathrm__1}\,\mathbf_3+\mathrm__2}\,\mathbf_3+\mathbf_3\|\mathbf_3\| ]
- :[\vdots]
- [\mathbf_k = \sum_^\mathrm__j}\,\mathbf_k+\mathbf_k\|\mathbf_k\| ]
Now these equations can be written in matrix form, viz.,
- [\left(\mathbf_1\left|\ldots\right|\mathbf_n\right)\begin \|\mathbf_1\| & \langle\mathbf_1,\mathbf_2\rangle & \langle\mathbf_1,\mathbf_3\rangle & \ldots \\0 & \|\mathbf_2\| & \langle\mathbf_2,\mathbf_3\rangle & \ldots \\0 & 0 & \|\mathbf_3\| & \ldots \\\vdots & \vdots & \vdots & \ddots \end]
Alternatively, [\begin R \end] can be calculated as follows:
Recall that [\beginQ\end = \left(\mathbf_1\left|\ldots\right|\mathbf_n\right).] Then, we have
- [\begin R = Q^A = \end \begin \langle\mathbf_1,\mathbf_1\rangle & \langle\mathbf_1,\mathbf_2\rangle & \langle\mathbf_1,\mathbf_3\rangle & \ldots \\0 & \langle\mathbf_2,\mathbf_2\rangle & \langle\mathbf_2,\mathbf_3\rangle & \ldots \\0 & 0 & \langle\mathbf_3,\mathbf_3\rangle & \ldots \\\vdots & \vdots & \vdots & \ddots \end.]
Example
Consider the decomposition of- [A = \begin12 & -51 & 4 \\6 & 167 & -68 \\-4 & 24 & -41 \end.]
- [\begin Q\,Q^ = I.\end]
- [U = \begin\mathbf u_1 & \mathbf u_2 & \mathbf u_3\end=\begin12 & -69 & -58 \\6 & 158 & 6 \\-4 & 30 & -165 \end;]
- [Q = \begin\frac & \frac & \frac\end=\begin 6/7 & -69/175 & -58/175 \\ 3/7 & 158/175 & 6/175 \\ -2/7 & 6/35 & -33/35 \end;]
- [\begin A = Q\,Q^A = Q R; \end]
- [\begin R = Q^A =\end\begin 14 & 21 & -14 \\ 0 & 175 & -70 \\ 0 & 0 & 35\end.]
- [\begin Q = \end\begin 0.857142857142857 & -0.394285714285714 & -0.331428571428571 \\ 0.428571428571429 & 0.902857142857143 & 0.034285714285714 \\ -0.285714285714286 & 0.171428571428571 & -0.942857142857143 \end;]
- [\begin R = \end\begin 14 & 21 & -14 \\ 1.11022302462516 \times 10^ & 175 & -70 \\ -1.77635683940025 \times 10^ & -5.32907051820075 \times 10^ & 35\end.]
Computing QR by means of Householder reflections
A Householder reflection (or Householder transformation) is a transformation that takes a vector and reflects it about some plane. We can use this property to calculate the QR factorization of a matrix.Q can be used to reflect a vector in such a way that all coordinates but one disappear.
Let [\mathbf] be an arbitrary m-dimensional column vector such that ||[\mathbf]|| = |α| for a scalar α (if the algorithm is implemented using floating-point arithmetic, then α should get the opposite sign as the first coordinate of [\mathbf] to avoid loss of significance).
Then, where [\mathbf_1] is the vector (1,0,...,0)T, and ||·|| the Euclidean norm, set
- [\mathbf = \mathbf - \alpha\mathbf_1,]
- [\mathbf = \over\|\mathbf\|},]
- [Q = I - 2 \mathbf\mathbf^T.]
- [Qx = (\alpha, 0, \cdots, 0)^T.\,]
- [Q_1A = \begin \alpha_1&\star&\dots&\star\\ 0 & & & \\ \vdots & & A' & \\ 0 & & & \end]
- [Q_k = \begin I_ & 0\\ 0 & Q_k'\end.]
- [ R = Q_t \cdots Q_2Q_1A]
- [ Q = Q_1Q_2 \cdots Q_t]
This method has greater numerical stability than the Gram-Schmidt method above.
Example
Let us calculate the decomposition of- [A = \begin12 & -51 & 4 \\6 & 167 & -68 \\-4 & 24 & -41 \end.]
Now,
- [\mathbf = \mathbf - \alpha\mathbf_1,]
- [\mathbf = \over\|\mathbf\|},].
- [\alpha = 14] and [\mathbf = \mathbf_1 = (12, 6, -4)^T]
- [\mathbf = (-2, 6, -4)^T] and [\mathbf = }(-1, 3, -2)^T], and then
- [Q_1 = I - \sqrt} \begin -1 \\ 3 \\ -2 \end\begin -1 & 3 & -2 \end]
- [ = I - \begin1 & -3 & 2 \\-3 & 9 & -6 \\2 & -6 & 4 \end]
- [ = \begin6/7 & 3/7 & -2/7 \\3/7 &-2/7 & 6/7 \\-2/7 & 6/7 & 3/7 \\\end.]
- [Q_1A = \begin14 & 21 & -14 \\0 & -49 & -14 \\0 & 168 & -77 \end,]
Take the (1, 1) minor, and then apply the process again to
- [A' = M_ = \begin-49 & -14 \\168 & -77 \end.]
- [Q_2 = \begin1 & 0 & 0 \\0 & -7/25 & 24/25 \\0 & 24/25 & 7/25 \end]
Now, we find
- [Q=Q_1Q_2=\begin6/7 & -69/175 & 58/175\\3/7 & 158/175 & -6/175 \\-2/7 & 6/35 & 33/35\end ]
- [R=Q^\top A=\begin14 & 21 & -14 \\0 & 175 & -70 \\0 & 0 & -35\end.]
Computing QR by means of Givens rotations
QR decompositions can also be computed with a series of Givens rotations. Each rotation zeros an element in the subdiagonal of the matrix, forming the R matrix. The concatenation of all the Givens rotations forms the orthogonal Q matrix.In practice, Givens rotations are not actually performed by building a whole matrix and doing a matrix multiplication. A Givens rotation procedure is used instead which does the equivalent of the sparse Givens matrix multiplication, without the extra work of handling the sparse elements. The Givens rotation procedure is useful in situations where only a relatively few off diagonal elements need to be zeroed, and is more easily parallelized than Householder transformations.
Example
Let us calculate the decomposition of- [A = \begin12 & -51 & 4 \\6 & 167 & -68 \\-4 & 24 & -41 \end]
- [G_1 = \begin1 & 0 & 0 \\0 & \cos(\theta) & \sin(\theta) \\0 & -\sin(\theta) & \cos(\theta)\end]
- [\approx \begin1 & 0 & 0 \\0 & 0.83205 & -0.55470 \\0 & 0.55470 & 0.83205\end]
- [G_1A \approx \begin12 & -51 & 4 \\7.21110 & 125.63959 & -33.83671 \\0 & 112.60414 & -71.83368\end]
Connection to a determinant
We can use QR decomposition to find the absolute value of the determinant of a matrix. Suppose a matrix is decomposed as [A=QR]. Then we have- [\det(A)=\det(Q)\cdot\det(R).]
- [|\det(A)|=|\det(R)|=\Big|\prod_ r_\Big|,]
See also
- Polar decomposition
- Eigenvalue decomposition
- Spectral decomposition
References
- Roger A. Horn and Charles R. Johnson, Matrix Analysis, Section 2.6, Cambridge University Press, 1985. ISBN 0-521-30586-1 hardback, ISBN 0-521-38632-2 paperback.
External links
- [Online Matrix Calculator] Performs QR decomposition of matrices.
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
