How to make R close to the identity

4 views (last 30 days)
Haya M
Haya M on 20 Jan 2021
Answered: Arjun on 22 Apr 2025
Hi everyone..
Is there any idea how I can make the matrix R in qr factorisation close to the identity?
Here is my attempt for a random matrix, the norm I got is somthing close to 1:(
A = complex(rand(3,3),rand(3,3))
[q,r]=qr(A)
dr = diag(sign(diag(r)))
qu = q*dr
ru = dr'*r
normru=norm(ru-eye(3,3))

Answers (1)

Arjun
Arjun on 22 Apr 2025
For a random matrix, it is generally not possible to make the "R" factor from QR factorization close to the identity matrix. This is because, in the QR decomposition "A = QR", the "R" matrix reflects the intrinsic structure of "A", and only takes the form of the identity matrix if "A" itself has special properties.
If your goal is to have "R" close to the identity matrix, you should use an orthogonal matrix as your input for "A". When "A" is orthogonal, its QR decomposition yields "Q = A" and "R = I", the identity matrix.
Please read the proof for this below:
  • For an Orthogonal Matrix A:
  • Since A is orthogonal, A^T = A^-1.
  • If we apply the QR decomposition to A (A = QR), then we have A^T = (QR)^T = R^T Q^T.
  • Since A^T = A^-1 = Q^-1 R^-1 = Q^T R^-1 and Q^T = Q^-1, we can see that R^-1 = R^T.
  • This means that R is an orthogonal matrix as well.
  • But R is also upper triangular, so R must be a diagonal matrix.
  • Furthermore, since A is orthogonal (A^T A = I), then (Q^T R^T)(QR) = Q^T R^2 Q = I. This implies that R^2 = I, and since R is diagonal, the diagonal elements must be ±1. However, the diagonal elements of R are positive (due to the Gram-Schmidt process used to find R), so they must be 1.
  • In summary: If A is orthogonal, its QR decomposition becomes A = Q * I = Q, meaning Q is actually equal to A. The upper triangular matrix R is the identity matrix (I)
I hope this will help!

Categories

Find more on Linear Algebra in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!