We want to transform a matrix into upper triangular form, but not through elementary row operations, rather through orthogonal transformations that have better conditioning. Imagine rotating and reflecting geometric space to simplify the matrix, without changing its fundamental properties.
Let A∈Rm×n be a rectangular matrix with m≥n and . Then there exists an orthogonal matrix with and an upper triangular matrix with diagonal elements for , such that:
RankA=n
Q∈Rm×m
QTQ=I
R∈Rm×n
rii>0
i=1,…,n
A=Q⋅R
This representation is called the QR decomposition of A.
Since the lower part of matrix R only contains zeros, we can save storage and computation.
Economical QR decomposition only uses the parts that are actually needed:
A=Q⋅R=(Q1Q2)⋅(R10)=Q1⋅R1
Here Q1∈Rm×n only takes the first through n-th columns
from Q, and R1∈Rn×n is a square upper triangular matrix.
Why is it called economical? Because we save storage space and computational time.
Instead of storing matrix Q of size m×m which can be very large,
we only need Q1 of size m×n.
The columns of matrix Q2∈Rm×(m−n) that we don't use form
an orthonormal basis of KernelAT:
Although the Gram-Schmidt process provides an elegant theoretical way to obtain QR decomposition,
this method is not suitable for practical computation. The main problem is numerical instability due to cancellation,
orthogonality of columns is quickly lost during computation.
To overcome this problem, we need a method that is more numerically stable.
One of the most successful approaches is the Householder procedure,
which uses orthogonal reflection transformations. Another alternative is the Givens procedure with rotation transformations.
For a vector v∈Rm with ∥v∥2=1,
we can define the Householder transformation matrix:
S=I−2vvT∈Rm×m
Note that vvT is a dyadic product, which is the multiplication of column vector
v∈Rm×1 with row vector vT∈R1×m.
The result of this multiplication is an m×m matrix with rank 1 for v=0.
Don't confuse this with scalar multiplication vTv∈R.
Given matrix A∈Rm×n with m≥n
and RankA=n. For QR decomposition computation,
matrix A is transformed column by column through Householder reflections
into upper triangular form.
Start with A1=A and reflect the first column of A1
with respect to a vector using reflection plane with:
Due to orthogonal transformation, it holds that cond2(R)=cond2(A)
The diagonal elements of R are the numbers ±∥a~i∥2
from the i-th step. Choosing the transformation so that all are positive gives the QR decomposition.
If ∥a~i∥2=0, A does not have full rank
and the algorithm stops.
For numerical reasons choose the sign so that cancellation is avoided:
ui=a~i∓∥a~i∥2⋅e1 (general form)
Instead of constructing Q, in compact storage one can also store
only the information needed for the transformation:
Store vector a~i∓∥a~i∥2⋅e1
If you only want to compute economical QR decomposition, remove the corresponding columns of Q and rows of R.