fbpx
Wikipedia

QR decomposition

In linear algebra, a QR decomposition, also known as a QR factorization or QU factorization, is a decomposition of a matrix A into a product A = QR of an orthonormal matrix Q and an upper triangular matrix R. QR decomposition is often used to solve the linear least squares (LLS) problem and is the basis for a particular eigenvalue algorithm, the QR algorithm.

Cases and definitions edit

Square matrix edit

Any real square matrix A may be decomposed as

 

where Q is an orthogonal matrix (its columns are orthogonal unit vectors meaning  ) and R is an upper triangular matrix (also called right triangular matrix). If A is invertible, then the factorization is unique if we require the diagonal elements of R to be positive.

If instead A is a complex square matrix, then there is a decomposition A = QR where Q is a unitary matrix (so the conjugate transpose  ).

If A has n linearly independent columns, then the first n columns of Q form an orthonormal basis for the column space of A. More generally, the first k columns of Q form an orthonormal basis for the span of the first k columns of A for any 1 ≤ kn.[1] The fact that any column k of A only depends on the first k columns of Q corresponds to the triangular form of R.[1]

Rectangular matrix edit

More generally, we can factor a complex m×n matrix A, with mn, as the product of an m×m unitary matrix Q and an m×n upper triangular matrix R. As the bottom (mn) rows of an m×n upper triangular matrix consist entirely of zeroes, it is often useful to partition R, or both R and Q:

 

where R1 is an n×n upper triangular matrix, 0 is an (mnn zero matrix, Q1 is m×n, Q2 is m×(mn), and Q1 and Q2 both have orthogonal columns.

Golub & Van Loan (1996, §5.2) call Q1R1 the thin QR factorization of A; Trefethen and Bau call this the reduced QR factorization.[1] If A is of full rank n and we require that the diagonal elements of R1 are positive then R1 and Q1 are unique, but in general Q2 is not. R1 is then equal to the upper triangular factor of the Cholesky decomposition of A* A (= ATA if A is real).

QL, RQ and LQ decompositions edit

Analogously, we can define QL, RQ, and LQ decompositions, with L being a lower triangular matrix.

Computing the QR decomposition edit

There are several methods for actually computing the QR decomposition, such as the Gram–Schmidt process, Householder transformations, or Givens rotations. Each has a number of advantages and disadvantages.

Using the Gram–Schmidt process edit

Consider the Gram–Schmidt process applied to the columns of the full column rank matrix  , with inner product   (or   for the complex case).

Define the projection:

 

then:

 

We can now express the  s over our newly computed orthonormal basis:

 

where  . This can be written in matrix form:

 

where:

 

and

 

Example edit

Consider the decomposition of

 

Recall that an orthonormal matrix   has the property  .

Then, we can calculate   by means of Gram–Schmidt as follows:

 

Thus, we have

 

Relation to RQ decomposition edit

The RQ decomposition transforms a matrix A into the product of an upper triangular matrix R (also known as right-triangular) and an orthogonal matrix Q. The only difference from QR decomposition is the order of these matrices.

QR decomposition is Gram–Schmidt orthogonalization of columns of A, started from the first column.

RQ decomposition is Gram–Schmidt orthogonalization of rows of A, started from the last row.

Advantages and disadvantages edit

The Gram-Schmidt process is inherently numerically unstable. While the application of the projections has an appealing geometric analogy to orthogonalization, the orthogonalization itself is prone to numerical error. A significant advantage is the ease of implementation.

Using Householder reflections edit

 
Householder reflection for QR-decomposition: The goal is to find a linear transformation that changes the vector   into a vector of the same length which is collinear to  . We could use an orthogonal projection (Gram-Schmidt) but this will be numerically unstable if the vectors   and   are close to orthogonal. Instead, the Householder reflection reflects through the dotted line (chosen to bisect the angle between   and  ). The maximum angle with this transform is 45 degrees.

A Householder reflection (or Householder transformation) is a transformation that takes a vector and reflects it about some plane or hyperplane. We can use this operation to calculate the QR factorization of an m-by-n matrix   with mn.

Q can be used to reflect a vector in such a way that all coordinates but one disappear.

Let   be an arbitrary real m-dimensional column vector of   such that   for a scalar α. If the algorithm is implemented using floating-point arithmetic, then α should get the opposite sign as the k-th coordinate of  , where   is to be the pivot coordinate after which all entries are 0 in matrix A's final upper triangular form, to avoid loss of significance. In the complex case, set[2]

 

and substitute transposition by conjugate transposition in the construction of Q below.

Then, where   is the vector [1 0 ⋯ 0]T, ||·|| is the Euclidean norm and   is an m×m identity matrix, set

 

Or, if   is complex

 

  is an m-by-m Householder matrix, which is both symmetric and orthogonal (Hermitian and unitary in the complex case), and

 

This can be used to gradually transform an m-by-n matrix A to upper triangular form. First, we multiply A with the Householder matrix Q1 we obtain when we choose the first matrix column for x. This results in a matrix Q1A with zeros in the left column (except for the first row).

 

This can be repeated for A′ (obtained from Q1A by deleting the first row and first column), resulting in a Householder matrix Q2. Note that Q2 is smaller than Q1. Since we want it really to operate on Q1A instead of A′ we need to expand it to the upper left, filling in a 1, or in general:

 

After   iterations of this process,  ,

 

is an upper triangular matrix. So, with

 

  is a QR decomposition of  .

This method has greater numerical stability than the Gram–Schmidt method above.

The following table gives the number of operations in the k-th step of the QR-decomposition by the Householder transformation, assuming a square matrix with size n.

Operation Number of operations in the k-th step
Multiplications  
Additions  
Division  
Square root  

Summing these numbers over the n − 1 steps (for a square matrix of size n), the complexity of the algorithm (in terms of floating point multiplications) is given by

 

Example edit

Let us calculate the decomposition of

 

First, we need to find a reflection that transforms the first column of matrix A, vector  , into  .

Now,

 

and

 

Here,

  and  

Therefore

  and  , and then
 

Now observe:

 

so we already have almost a triangular matrix. We only need to zero the (3, 2) entry.

Take the (1, 1) minor, and then apply the process again to

 

By the same method as above, we obtain the matrix of the Householder transformation

 

after performing a direct sum with 1 to make sure the next step in the process works properly.

Now, we find

 

Or, to four decimal digits,

 

The matrix Q is orthogonal and R is upper triangular, so A = QR is the required QR decomposition.

Advantages and disadvantages edit

The use of Householder transformations is inherently the most simple of the numerically stable QR decomposition algorithms due to the use of reflections as the mechanism for producing zeroes in the R matrix. However, the Householder reflection algorithm is bandwidth heavy and not parallelizable, as every reflection that produces a new zero element changes the entirety of both Q and R matrices.

Using Givens rotations edit

QR decompositions can also be computed with a series of Givens rotations. Each rotation zeroes 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 relatively few off-diagonal elements need to be zeroed, and is more easily parallelized than Householder transformations.

Example edit

Let us calculate the decomposition of

 

First, we need to form a rotation matrix that will zero the lowermost left element,  . We form this matrix using the Givens rotation method, and call the matrix  . We will first rotate the vector  , to point along the X axis. This vector has an angle  . We create the orthogonal Givens rotation matrix,  :

 

And the result of   now has a zero in the   element.

 

We can similarly form Givens matrices   and  , which will zero the sub-diagonal elements   and  , forming a triangular matrix  . The orthogonal matrix   is formed from the product of all the Givens matrices  . Thus, we have  , and the QR decomposition is  .

Advantages and disadvantages edit

The QR decomposition via Givens rotations is the most involved to implement, as the ordering of the rows required to fully exploit the algorithm is not trivial to determine. However, it has a significant advantage in that each new zero element   affects only the row with the element to be zeroed (i) and a row above (j). This makes the Givens rotation algorithm more bandwidth efficient and parallelizable than the Householder reflection technique.

Connection to a determinant or a product of eigenvalues edit

We can use QR decomposition to find the determinant of a square matrix. Suppose a matrix is decomposed as  . Then we have

 

  can be chosen such that  . Thus,

 

where the   are the entries on the diagonal of  . Furthermore, because the determinant equals the product of the eigenvalues, we have

 

where the   are eigenvalues of  .

We can extend the above properties to a non-square complex matrix   by introducing the definition of QR decomposition for non-square complex matrices and replacing eigenvalues with singular values.

Start with a QR decomposition for a non-square matrix A:

 

where   denotes the zero matrix and   is a unitary matrix.

From the properties of the singular value decomposition (SVD) and the determinant of a matrix, we have

 

where the   are the singular values of  .

Note that the singular values of   and   are identical, although their complex eigenvalues may be different. However, if A is square, then

 

It follows that the QR decomposition can be used to efficiently calculate the product of the eigenvalues or singular values of a matrix.

Column pivoting edit

Pivoted QR differs from ordinary Gram-Schmidt in that it takes the largest remaining column at the beginning of each new step—column pivoting—[3] and thus introduces a permutation matrix P:

 

Column pivoting is useful when A is (nearly) rank deficient, or is suspected of being so. It can also improve numerical accuracy. P is usually chosen so that the diagonal elements of R are non-increasing:  . This can be used to find the (numerical) rank of A at lower computational cost than a singular value decomposition, forming the basis of so-called rank-revealing QR algorithms.

Using for solution to linear inverse problems edit

Compared to the direct matrix inverse, inverse solutions using QR decomposition are more numerically stable as evidenced by their reduced condition numbers.[4]

To solve the underdetermined ( ) linear problem   where the matrix   has dimensions   and rank  , first find the QR factorization of the transpose of  :  , where Q is an orthogonal matrix (i.e.  ), and R has a special form:  . Here   is a square   right triangular matrix, and the zero matrix has dimension  . After some algebra, it can be shown that a solution to the inverse problem can be expressed as:   where one may either find   by Gaussian elimination or compute   directly by forward substitution. The latter technique enjoys greater numerical accuracy and lower computations.

To find a solution   to the overdetermined ( ) problem   which minimizes the norm  , first find the QR factorization of  :  . The solution can then be expressed as  , where   is an   matrix containing the first   columns of the full orthonormal basis   and where   is as before. Equivalent to the underdetermined case, back substitution can be used to quickly and accurately find this   without explicitly inverting  . (  and   are often provided by numerical libraries as an "economic" QR decomposition.)

Generalizations edit

Iwasawa decomposition generalizes QR decomposition to semi-simple Lie groups.

See also edit

References edit

  1. ^ a b c Trefethen, Lloyd N.; Bau, David III (1997). Numerical linear algebra. Philadelphia, PA: Society for Industrial and Applied Mathematics. ISBN 978-0-898713-61-9.
  2. ^ Stoer, Josef; Bulirsch, Roland (2002), Introduction to Numerical Analysis (3rd ed.), Springer, p. 225, ISBN 0-387-95452-X
  3. ^ Strang, Gilbert (2019). Linear Algebra and Learning from Data (1st ed.). Wellesley: Wellesley Cambridge Press. p. 143. ISBN 978-0-692-19638-0.
  4. ^ Parker, Robert L. (1994). Geophysical Inverse Theory. Princeton, N.J.: Princeton University Press. Section 1.13. ISBN 978-0-691-20683-7. OCLC 1134769155.

Further reading edit

External links edit

  • Performs QR decomposition of matrices.
  • LAPACK users manual gives details of subroutines to calculate the QR decomposition
  • gives details and examples of routines to calculate QR decomposition
  • ALGLIB includes a partial port of the LAPACK to C++, C#, Delphi, etc.
  • Eigen::QR Includes C++ implementation of QR decomposition.

decomposition, linear, algebra, also, known, factorization, factorization, decomposition, matrix, into, product, orthonormal, matrix, upper, triangular, matrix, often, used, solve, linear, least, squares, problem, basis, particular, eigenvalue, algorithm, algo. In linear algebra a QR decomposition also known as a QR factorization or QU factorization is a decomposition of a matrix A into a product A QR of an orthonormal matrix Q and an upper triangular matrix R QR decomposition is often used to solve the linear least squares LLS problem and is the basis for a particular eigenvalue algorithm the QR algorithm Contents 1 Cases and definitions 1 1 Square matrix 1 2 Rectangular matrix 1 3 QL RQ and LQ decompositions 2 Computing the QR decomposition 2 1 Using the Gram Schmidt process 2 1 1 Example 2 1 2 Relation to RQ decomposition 2 1 3 Advantages and disadvantages 2 2 Using Householder reflections 2 2 1 Example 2 2 2 Advantages and disadvantages 2 3 Using Givens rotations 2 3 1 Example 2 3 2 Advantages and disadvantages 3 Connection to a determinant or a product of eigenvalues 4 Column pivoting 5 Using for solution to linear inverse problems 6 Generalizations 7 See also 8 References 9 Further reading 10 External linksCases and definitions editSquare matrix edit Any real square matrix A may be decomposed as A Q R displaystyle A QR nbsp where Q is an orthogonal matrix its columns are orthogonal unit vectors meaning Q T Q 1 displaystyle Q textsf T Q 1 nbsp and R is an upper triangular matrix also called right triangular matrix If A is invertible then the factorization is unique if we require the diagonal elements of R to be positive If instead A is a complex square matrix then there is a decomposition A QR where Q is a unitary matrix so the conjugate transpose Q Q 1 displaystyle Q dagger Q 1 nbsp If A has n linearly independent columns then the first n columns of Q form an orthonormal basis for the column space of A More generally the first k columns of Q form an orthonormal basis for the span of the first k columns of A for any 1 k n 1 The fact that any column k of A only depends on the first k columns of Q corresponds to the triangular form of R 1 Rectangular matrix edit More generally we can factor a complex m n matrix A with m n as the product of an m m unitary matrix Q and an m n upper triangular matrix R As the bottom m n rows of an m n upper triangular matrix consist entirely of zeroes it is often useful to partition R or both R and Q A Q R Q R 1 0 Q 1 Q 2 R 1 0 Q 1 R 1 displaystyle A QR Q begin bmatrix R 1 0 end bmatrix begin bmatrix Q 1 amp Q 2 end bmatrix begin bmatrix R 1 0 end bmatrix Q 1 R 1 nbsp where R1 is an n n upper triangular matrix 0 is an m n n zero matrix Q1 is m n Q2 is m m n and Q1 and Q2 both have orthogonal columns Golub amp Van Loan 1996 5 2 call Q1R1 the thin QR factorization of A Trefethen and Bau call this the reduced QR factorization 1 If A is of full rank n and we require that the diagonal elements of R1 are positive then R1 and Q1 are unique but in general Q2 is not R1 is then equal to the upper triangular factor of the Cholesky decomposition of A A ATA if A is real QL RQ and LQ decompositions edit Analogously we can define QL RQ and LQ decompositions with L being a lower triangular matrix Computing the QR decomposition editThere are several methods for actually computing the QR decomposition such as the Gram Schmidt process Householder transformations or Givens rotations Each has a number of advantages and disadvantages Using the Gram Schmidt process edit Further information Gram Schmidt Numerical stability Consider the Gram Schmidt process applied to the columns of the full column rank matrix A a 1 a n displaystyle A begin bmatrix mathbf a 1 amp cdots amp mathbf a n end bmatrix nbsp with inner product v w v T w displaystyle langle mathbf v mathbf w rangle mathbf v textsf T mathbf w nbsp or v w v w displaystyle langle mathbf v mathbf w rangle mathbf v dagger mathbf w nbsp for the complex case Define the projection proj u a u a u u u displaystyle operatorname proj mathbf u mathbf a frac left langle mathbf u mathbf a right rangle left langle mathbf u mathbf u right rangle mathbf u nbsp then u 1 a 1 e 1 u 1 u 1 u 2 a 2 proj u 1 a 2 e 2 u 2 u 2 u 3 a 3 proj u 1 a 3 proj u 2 a 3 e 3 u 3 u 3 u k a k j 1 k 1 proj u j a k e k u k u k displaystyle begin aligned mathbf u 1 amp mathbf a 1 amp mathbf e 1 amp frac mathbf u 1 mathbf u 1 mathbf u 2 amp mathbf a 2 operatorname proj mathbf u 1 mathbf a 2 amp mathbf e 2 amp frac mathbf u 2 mathbf u 2 mathbf u 3 amp mathbf a 3 operatorname proj mathbf u 1 mathbf a 3 operatorname proj mathbf u 2 mathbf a 3 amp mathbf e 3 amp frac mathbf u 3 mathbf u 3 amp vdots amp amp vdots mathbf u k amp mathbf a k sum j 1 k 1 operatorname proj mathbf u j mathbf a k amp mathbf e k amp frac mathbf u k mathbf u k end aligned nbsp We can now express the a i displaystyle mathbf a i nbsp s over our newly computed orthonormal basis a 1 e 1 a 1 e 1 a 2 e 1 a 2 e 1 e 2 a 2 e 2 a 3 e 1 a 3 e 1 e 2 a 3 e 2 e 3 a 3 e 3 a k j 1 k e j a k e j displaystyle begin aligned mathbf a 1 amp left langle mathbf e 1 mathbf a 1 right rangle mathbf e 1 mathbf a 2 amp left langle mathbf e 1 mathbf a 2 right rangle mathbf e 1 left langle mathbf e 2 mathbf a 2 right rangle mathbf e 2 mathbf a 3 amp left langle mathbf e 1 mathbf a 3 right rangle mathbf e 1 left langle mathbf e 2 mathbf a 3 right rangle mathbf e 2 left langle mathbf e 3 mathbf a 3 right rangle mathbf e 3 amp vdots mathbf a k amp sum j 1 k left langle mathbf e j mathbf a k right rangle mathbf e j end aligned nbsp where e i a i u i displaystyle left langle mathbf e i mathbf a i right rangle left mathbf u i right nbsp This can be written in matrix form A Q R displaystyle A QR nbsp where Q e 1 e n displaystyle Q begin bmatrix mathbf e 1 amp cdots amp mathbf e n end bmatrix nbsp and R e 1 a 1 e 1 a 2 e 1 a 3 e 1 a n 0 e 2 a 2 e 2 a 3 e 2 a n 0 0 e 3 a 3 e 3 a n 0 0 0 e n a n displaystyle R begin bmatrix langle mathbf e 1 mathbf a 1 rangle amp langle mathbf e 1 mathbf a 2 rangle amp langle mathbf e 1 mathbf a 3 rangle amp cdots amp langle mathbf e 1 mathbf a n rangle 0 amp langle mathbf e 2 mathbf a 2 rangle amp langle mathbf e 2 mathbf a 3 rangle amp cdots amp langle mathbf e 2 mathbf a n rangle 0 amp 0 amp langle mathbf e 3 mathbf a 3 rangle amp cdots amp langle mathbf e 3 mathbf a n rangle vdots amp vdots amp vdots amp ddots amp vdots 0 amp 0 amp 0 amp cdots amp langle mathbf e n mathbf a n rangle end bmatrix nbsp Example edit Consider the decomposition of A 12 51 4 6 167 68 4 24 41 displaystyle A begin bmatrix 12 amp 51 amp 4 6 amp 167 amp 68 4 amp 24 amp 41 end bmatrix nbsp Recall that an orthonormal matrix Q displaystyle Q nbsp has the property Q T Q I displaystyle Q textsf T Q I nbsp Then we can calculate Q displaystyle Q nbsp by means of Gram Schmidt as follows U u 1 u 2 u 3 12 69 58 5 6 158 6 5 4 30 33 Q u 1 u 1 u 2 u 2 u 3 u 3 6 7 69 175 58 175 3 7 158 175 6 175 2 7 6 35 33 35 displaystyle begin aligned U begin bmatrix mathbf u 1 amp mathbf u 2 amp mathbf u 3 end bmatrix amp begin bmatrix 12 amp 69 amp 58 5 6 amp 158 amp 6 5 4 amp 30 amp 33 end bmatrix Q begin bmatrix frac mathbf u 1 mathbf u 1 amp frac mathbf u 2 mathbf u 2 amp frac mathbf u 3 mathbf u 3 end bmatrix amp begin bmatrix 6 7 amp 69 175 amp 58 175 3 7 amp 158 175 amp 6 175 2 7 amp 6 35 amp 33 35 end bmatrix end aligned nbsp Thus we have Q T A Q T Q R R R Q T A 14 21 14 0 175 70 0 0 35 displaystyle begin aligned Q textsf T A amp Q textsf T Q R R R amp Q textsf T A begin bmatrix 14 amp 21 amp 14 0 amp 175 amp 70 0 amp 0 amp 35 end bmatrix end aligned nbsp Relation to RQ decomposition edit The RQ decomposition transforms a matrix A into the product of an upper triangular matrix R also known as right triangular and an orthogonal matrix Q The only difference from QR decomposition is the order of these matrices QR decomposition is Gram Schmidt orthogonalization of columns of A started from the first column RQ decomposition is Gram Schmidt orthogonalization of rows of A started from the last row Advantages and disadvantages edit The Gram Schmidt process is inherently numerically unstable While the application of the projections has an appealing geometric analogy to orthogonalization the orthogonalization itself is prone to numerical error A significant advantage is the ease of implementation Using Householder reflections edit nbsp Householder reflection for QR decomposition The goal is to find a linear transformation that changes the vector x displaystyle mathbf x nbsp into a vector of the same length which is collinear to e 1 displaystyle mathbf e 1 nbsp We could use an orthogonal projection Gram Schmidt but this will be numerically unstable if the vectors x displaystyle mathbf x nbsp and e 1 displaystyle mathbf e 1 nbsp are close to orthogonal Instead the Householder reflection reflects through the dotted line chosen to bisect the angle between x displaystyle mathbf x nbsp and e 1 displaystyle mathbf e 1 nbsp The maximum angle with this transform is 45 degrees A Householder reflection or Householder transformation is a transformation that takes a vector and reflects it about some plane or hyperplane We can use this operation to calculate the QR factorization of an m by n matrix A displaystyle A nbsp with m n Q can be used to reflect a vector in such a way that all coordinates but one disappear Let x displaystyle mathbf x nbsp be an arbitrary real m dimensional column vector of A displaystyle A nbsp such that x a displaystyle mathbf x alpha nbsp for a scalar a If the algorithm is implemented using floating point arithmetic then a should get the opposite sign as the k th coordinate of x displaystyle mathbf x nbsp where x k displaystyle x k nbsp is to be the pivot coordinate after which all entries are 0 in matrix A s final upper triangular form to avoid loss of significance In the complex case set 2 a e i arg x k x displaystyle alpha e i arg x k mathbf x nbsp and substitute transposition by conjugate transposition in the construction of Q below Then where e 1 displaystyle mathbf e 1 nbsp is the vector 1 0 0 T is the Euclidean norm and I displaystyle I nbsp is an m m identity matrix set u x a e 1 v u u Q I 2 v v T displaystyle begin aligned mathbf u amp mathbf x alpha mathbf e 1 mathbf v amp frac mathbf u mathbf u Q amp I 2 mathbf v mathbf v textsf T end aligned nbsp Or if A displaystyle A nbsp is complex Q I 2 v v displaystyle Q I 2 mathbf v mathbf v dagger nbsp Q displaystyle Q nbsp is an m by m Householder matrix which is both symmetric and orthogonal Hermitian and unitary in the complex case and Q x a 0 0 displaystyle Q mathbf x begin bmatrix alpha 0 vdots 0 end bmatrix nbsp This can be used to gradually transform an m by n matrix A to upper triangular form First we multiply A with the Householder matrix Q1 we obtain when we choose the first matrix column for x This results in a matrix Q1A with zeros in the left column except for the first row Q 1 A a 1 0 A 0 displaystyle Q 1 A begin bmatrix alpha 1 amp star amp cdots amp star 0 amp amp amp vdots amp amp A amp 0 amp amp amp end bmatrix nbsp This can be repeated for A obtained from Q1A by deleting the first row and first column resulting in a Householder matrix Q 2 Note that Q 2 is smaller than Q1 Since we want it really to operate on Q1A instead of A we need to expand it to the upper left filling in a 1 or in general Q k I k 1 0 0 Q k displaystyle Q k begin bmatrix I k 1 amp 0 0 amp Q k end bmatrix nbsp After t displaystyle t nbsp iterations of this process t min m 1 n displaystyle t min m 1 n nbsp R Q t Q 2 Q 1 A displaystyle R Q t cdots Q 2 Q 1 A nbsp is an upper triangular matrix So with Q T Q t Q 2 Q 1 Q Q 1 T Q 2 T Q t T Q 1 Q 2 Q t displaystyle begin aligned Q textsf T amp Q t cdots Q 2 Q 1 Q amp Q 1 textsf T Q 2 textsf T cdots Q t textsf T amp Q 1 Q 2 cdots Q t end aligned nbsp A Q R displaystyle A QR nbsp is a QR decomposition of A displaystyle A nbsp This method has greater numerical stability than the Gram Schmidt method above The following table gives the number of operations in the k th step of the QR decomposition by the Householder transformation assuming a square matrix with size n Operation Number of operations in the k th step Multiplications 2 n k 1 2 displaystyle 2 n k 1 2 nbsp Additions n k 1 2 n k 1 n k 2 displaystyle n k 1 2 n k 1 n k 2 nbsp Division 1 displaystyle 1 nbsp Square root 1 displaystyle 1 nbsp Summing these numbers over the n 1 steps for a square matrix of size n the complexity of the algorithm in terms of floating point multiplications is given by 2 3 n 3 n 2 1 3 n 2 O n 3 displaystyle frac 2 3 n 3 n 2 frac 1 3 n 2 O left n 3 right nbsp Example edit Let us calculate the decomposition of A 12 51 4 6 167 68 4 24 41 displaystyle A begin bmatrix 12 amp 51 amp 4 6 amp 167 amp 68 4 amp 24 amp 41 end bmatrix nbsp First we need to find a reflection that transforms the first column of matrix A vector a 1 12 6 4 T displaystyle mathbf a 1 begin bmatrix 12 amp 6 amp 4 end bmatrix textsf T nbsp into a 1 e 1 a 0 0 T displaystyle left mathbf a 1 right mathbf e 1 begin bmatrix alpha amp 0 amp 0 end bmatrix textsf T nbsp Now u x a e 1 displaystyle mathbf u mathbf x alpha mathbf e 1 nbsp and v u u displaystyle mathbf v frac mathbf u mathbf u nbsp Here a 14 displaystyle alpha 14 nbsp and x a 1 12 6 4 T displaystyle mathbf x mathbf a 1 begin bmatrix 12 amp 6 amp 4 end bmatrix textsf T nbsp Therefore u 2 6 4 T 2 1 3 2 T displaystyle mathbf u begin bmatrix 2 amp 6 amp 4 end bmatrix textsf T 2 begin bmatrix 1 amp 3 amp 2 end bmatrix textsf T nbsp and v 1 14 1 3 2 T displaystyle mathbf v frac 1 sqrt 14 begin bmatrix 1 amp 3 amp 2 end bmatrix textsf T nbsp and then Q 1 I 2 14 14 1 3 2 1 3 2 I 1 7 1 3 2 3 9 6 2 6 4 6 7 3 7 2 7 3 7 2 7 6 7 2 7 6 7 3 7 displaystyle begin aligned Q 1 amp I frac 2 sqrt 14 sqrt 14 begin bmatrix 1 3 2 end bmatrix begin bmatrix 1 amp 3 amp 2 end bmatrix amp I frac 1 7 begin bmatrix 1 amp 3 amp 2 3 amp 9 amp 6 2 amp 6 amp 4 end bmatrix amp begin bmatrix 6 7 amp 3 7 amp 2 7 3 7 amp 2 7 amp 6 7 2 7 amp 6 7 amp 3 7 end bmatrix end aligned nbsp Now observe Q 1 A 14 21 14 0 49 14 0 168 77 displaystyle Q 1 A begin bmatrix 14 amp 21 amp 14 0 amp 49 amp 14 0 amp 168 amp 77 end bmatrix nbsp so we already have almost a triangular matrix We only need to zero the 3 2 entry Take the 1 1 minor and then apply the process again to A M 11 49 14 168 77 displaystyle A M 11 begin bmatrix 49 amp 14 168 amp 77 end bmatrix nbsp By the same method as above we obtain the matrix of the Householder transformation Q 2 1 0 0 0 7 25 24 25 0 24 25 7 25 displaystyle Q 2 begin bmatrix 1 amp 0 amp 0 0 amp 7 25 amp 24 25 0 amp 24 25 amp 7 25 end bmatrix nbsp after performing a direct sum with 1 to make sure the next step in the process works properly Now we find Q Q 1 T Q 2 T 6 7 69 175 58 175 3 7 158 175 6 175 2 7 6 35 33 35 displaystyle Q Q 1 textsf T Q 2 textsf T begin bmatrix 6 7 amp 69 175 amp 58 175 3 7 amp 158 175 amp 6 175 2 7 amp 6 35 amp 33 35 end bmatrix nbsp Or to four decimal digits Q Q 1 T Q 2 T 0 8571 0 3943 0 3314 0 4286 0 9029 0 0343 0 2857 0 1714 0 9429 R Q 2 Q 1 A Q T A 14 21 14 0 175 70 0 0 35 displaystyle begin aligned Q amp Q 1 textsf T Q 2 textsf T begin bmatrix 0 8571 amp 0 3943 amp 0 3314 0 4286 amp 0 9029 amp 0 0343 0 2857 amp 0 1714 amp 0 9429 end bmatrix R amp Q 2 Q 1 A Q textsf T A begin bmatrix 14 amp 21 amp 14 0 amp 175 amp 70 0 amp 0 amp 35 end bmatrix end aligned nbsp The matrix Q is orthogonal and R is upper triangular so A QR is the required QR decomposition Advantages and disadvantages edit The use of Householder transformations is inherently the most simple of the numerically stable QR decomposition algorithms due to the use of reflections as the mechanism for producing zeroes in the R matrix However the Householder reflection algorithm is bandwidth heavy and not parallelizable as every reflection that produces a new zero element changes the entirety of both Q and R matrices Using Givens rotations edit QR decompositions can also be computed with a series of Givens rotations Each rotation zeroes 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 relatively few off diagonal elements need to be zeroed and is more easily parallelized than Householder transformations Example edit Let us calculate the decomposition of A 12 51 4 6 167 68 4 24 41 displaystyle A begin bmatrix 12 amp 51 amp 4 6 amp 167 amp 68 4 amp 24 amp 41 end bmatrix nbsp First we need to form a rotation matrix that will zero the lowermost left element a 31 4 displaystyle a 31 4 nbsp We form this matrix using the Givens rotation method and call the matrix G 1 displaystyle G 1 nbsp We will first rotate the vector 12 4 displaystyle begin bmatrix 12 amp 4 end bmatrix nbsp to point along the X axis This vector has an angle 8 arctan 4 12 textstyle theta arctan left frac 4 12 right nbsp We create the orthogonal Givens rotation matrix G 1 displaystyle G 1 nbsp G 1 cos 8 0 sin 8 0 1 0 sin 8 0 cos 8 0 94868 0 0 31622 0 1 0 0 31622 0 0 94868 displaystyle begin aligned G 1 amp begin bmatrix cos theta amp 0 amp sin theta 0 amp 1 amp 0 sin theta amp 0 amp cos theta end bmatrix amp approx begin bmatrix 0 94868 amp 0 amp 0 31622 0 amp 1 amp 0 0 31622 amp 0 amp 0 94868 end bmatrix end aligned nbsp And the result of G 1 A displaystyle G 1 A nbsp now has a zero in the a 31 displaystyle a 31 nbsp element G 1 A 12 64911 55 97231 16 76007 6 167 68 0 6 64078 37 6311 displaystyle G 1 A approx begin bmatrix 12 64911 amp 55 97231 amp 16 76007 6 amp 167 amp 68 0 amp 6 64078 amp 37 6311 end bmatrix nbsp We can similarly form Givens matrices G 2 displaystyle G 2 nbsp and G 3 displaystyle G 3 nbsp which will zero the sub diagonal elements a 21 displaystyle a 21 nbsp and a 32 displaystyle a 32 nbsp forming a triangular matrix R displaystyle R nbsp The orthogonal matrix Q T displaystyle Q textsf T nbsp is formed from the product of all the Givens matrices Q T G 3 G 2 G 1 displaystyle Q textsf T G 3 G 2 G 1 nbsp Thus we have G 3 G 2 G 1 A Q T A R displaystyle G 3 G 2 G 1 A Q textsf T A R nbsp and the QR decomposition is A Q R displaystyle A QR nbsp Advantages and disadvantages edit The QR decomposition via Givens rotations is the most involved to implement as the ordering of the rows required to fully exploit the algorithm is not trivial to determine However it has a significant advantage in that each new zero element a i j displaystyle a ij nbsp affects only the row with the element to be zeroed i and a row above j This makes the Givens rotation algorithm more bandwidth efficient and parallelizable than the Householder reflection technique Connection to a determinant or a product of eigenvalues editWe can use QR decomposition to find the determinant of a square matrix Suppose a matrix is decomposed as A Q R displaystyle A QR nbsp Then we havedet A det Q det R displaystyle det A det Q det R nbsp Q displaystyle Q nbsp can be chosen such that det Q 1 displaystyle det Q 1 nbsp Thus det A det R i r i i displaystyle det A det R prod i r ii nbsp where the r i i displaystyle r ii nbsp are the entries on the diagonal of R displaystyle R nbsp Furthermore because the determinant equals the product of the eigenvalues we have i r i i i l i displaystyle prod i r ii prod i lambda i nbsp where the l i displaystyle lambda i nbsp are eigenvalues of A displaystyle A nbsp We can extend the above properties to a non square complex matrix A displaystyle A nbsp by introducing the definition of QR decomposition for non square complex matrices and replacing eigenvalues with singular values Start with a QR decomposition for a non square matrix A A Q R 0 Q Q I displaystyle A Q begin bmatrix R 0 end bmatrix qquad Q dagger Q I nbsp where 0 displaystyle 0 nbsp denotes the zero matrix and Q displaystyle Q nbsp is a unitary matrix From the properties of the singular value decomposition SVD and the determinant of a matrix we have i r i i i s i displaystyle Big prod i r ii Big prod i sigma i nbsp where the s i displaystyle sigma i nbsp are the singular values of A displaystyle A nbsp Note that the singular values of A displaystyle A nbsp and R displaystyle R nbsp are identical although their complex eigenvalues may be different However if A is square then i s i i l i displaystyle prod i sigma i Big prod i lambda i Big nbsp It follows that the QR decomposition can be used to efficiently calculate the product of the eigenvalues or singular values of a matrix Column pivoting editPivoted QR differs from ordinary Gram Schmidt in that it takes the largest remaining column at the beginning of each new step column pivoting 3 and thus introduces a permutation matrix P A P Q R A Q R P T displaystyle AP QR quad iff quad A QRP textsf T nbsp Column pivoting is useful when A is nearly rank deficient or is suspected of being so It can also improve numerical accuracy P is usually chosen so that the diagonal elements of R are non increasing r 11 r 22 r n n displaystyle left r 11 right geq left r 22 right geq cdots geq left r nn right nbsp This can be used to find the numerical rank of A at lower computational cost than a singular value decomposition forming the basis of so called rank revealing QR algorithms Using for solution to linear inverse problems editCompared to the direct matrix inverse inverse solutions using QR decomposition are more numerically stable as evidenced by their reduced condition numbers 4 To solve the underdetermined m lt n displaystyle m lt n nbsp linear problem A x b displaystyle A mathbf x mathbf b nbsp where the matrix A displaystyle A nbsp has dimensions m n displaystyle m times n nbsp and rank m displaystyle m nbsp first find the QR factorization of the transpose of A displaystyle A nbsp A T Q R displaystyle A textsf T QR nbsp where Q is an orthogonal matrix i e Q T Q 1 displaystyle Q textsf T Q 1 nbsp and R has a special form R R 1 0 displaystyle R left begin smallmatrix R 1 0 end smallmatrix right nbsp Here R 1 displaystyle R 1 nbsp is a square m m displaystyle m times m nbsp right triangular matrix and the zero matrix has dimension n m m displaystyle n m times m nbsp After some algebra it can be shown that a solution to the inverse problem can be expressed as x Q R 1 T 1 b 0 displaystyle mathbf x Q left begin smallmatrix left R 1 textsf T right 1 mathbf b 0 end smallmatrix right nbsp where one may either find R 1 1 displaystyle R 1 1 nbsp by Gaussian elimination or compute R 1 T 1 b displaystyle left R 1 textsf T right 1 mathbf b nbsp directly by forward substitution The latter technique enjoys greater numerical accuracy and lower computations To find a solution x displaystyle hat mathbf x nbsp to the overdetermined m n displaystyle m geq n nbsp problem A x b displaystyle A mathbf x mathbf b nbsp which minimizes the norm A x b displaystyle left A hat mathbf x mathbf b right nbsp first find the QR factorization of A displaystyle A nbsp A Q R displaystyle A QR nbsp The solution can then be expressed as x R 1 1 Q 1 T b displaystyle hat mathbf x R 1 1 left Q 1 textsf T mathbf b right nbsp where Q 1 displaystyle Q 1 nbsp is an m n displaystyle m times n nbsp matrix containing the first n displaystyle n nbsp columns of the full orthonormal basis Q displaystyle Q nbsp and where R 1 displaystyle R 1 nbsp is as before Equivalent to the underdetermined case back substitution can be used to quickly and accurately find this x displaystyle hat mathbf x nbsp without explicitly inverting R 1 displaystyle R 1 nbsp Q 1 displaystyle Q 1 nbsp and R 1 displaystyle R 1 nbsp are often provided by numerical libraries as an economic QR decomposition Generalizations editIwasawa decomposition generalizes QR decomposition to semi simple Lie groups See also editPolar decomposition Eigenvalue decomposition Spectral decomposition LU decomposition Singular value decompositionReferences edit a b c Trefethen Lloyd N Bau David III 1997 Numerical linear algebra Philadelphia PA Society for Industrial and Applied Mathematics ISBN 978 0 898713 61 9 Stoer Josef Bulirsch Roland 2002 Introduction to Numerical Analysis 3rd ed Springer p 225 ISBN 0 387 95452 X Strang Gilbert 2019 Linear Algebra and Learning from Data 1st ed Wellesley Wellesley Cambridge Press p 143 ISBN 978 0 692 19638 0 Parker Robert L 1994 Geophysical Inverse Theory Princeton N J Princeton University Press Section 1 13 ISBN 978 0 691 20683 7 OCLC 1134769155 Further reading editGolub Gene H Van Loan Charles F 1996 Matrix Computations 3rd ed Johns Hopkins ISBN 978 0 8018 5414 9 Horn Roger A Johnson Charles R 1985 Matrix Analysis Cambridge University Press sec 2 8 ISBN 0 521 38632 2 Press WH Teukolsky SA Vetterling WT Flannery BP 2007 Section 2 10 QR Decomposition Numerical Recipes The Art of Scientific Computing 3rd ed New York Cambridge University Press ISBN 978 0 521 88068 8External links editOnline Matrix Calculator Performs QR decomposition of matrices LAPACK users manual gives details of subroutines to calculate the QR decomposition Mathematica users manual gives details and examples of routines to calculate QR decomposition ALGLIB includes a partial port of the LAPACK to C C Delphi etc Eigen QR Includes C implementation of QR decomposition Retrieved from https en wikipedia org w index php title QR decomposition amp oldid 1216197164, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.