Orthogonal Factorization

Theorem Every real \(m\times n\) matrix \(\mathbf{A}\) (\(m\ge n\)) can be written as \(\mathbf{A}=\mathbf{Q}\mathbf{R}\), where \(\mathbf{Q}\) is an \(m\times m\) orthogonal matrix and \(\mathbf{R}\) is an \(m\times n\) upper triangular matrix.

  • Thin QR: \(\mathbf{A} = \hat{\mathbf{Q}} \hat{\mathbf{R}}\), where \(\hat{\mathbf{Q}}\) is \(m\times n\) and ONC, and \(\hat{\mathbf{R}}\) is \(n\times n\) and upper triangular.
A = rand(1.:9.,6,4);
Q,R = qr(A);

We can get the thin from Q by converting to matrix:

Q_hat = Matrix(Q)

#6×4 Matrix{Float64}:
# -0.35793   -0.14544    -0.152543   0.829375
# -0.178965  -0.71283    -0.130244  -0.0381754
# -0.417585   0.207821   -0.702897  -0.0976324
# -0.298275  -0.498701    0.397811  -0.146905
# -0.536895   0.0280366  -0.078145  -0.512537
# -0.536895   0.421951    0.548947   0.129896

Verify that \(Q^T Q\) is the identity:

Q_hat'*Q_hat

#4×4 Matrix{Float64}:
#  1.0          -2.21581e-17  -2.82658e-17   4.37205e-17
# -2.21581e-17   1.0          -5.41623e-17   8.02735e-17
# -2.82658e-17  -5.41623e-17   1.0          -9.94081e-17
#  4.37205e-17   8.02735e-17  -9.94081e-17   1.0