# doc QR decomposition error

7 visualizzazioni (ultimi 30 giorni)
robin tournemenne il 20 Ott 2023
Commentato: Christine Tobler il 20 Ott 2023
Dear Mathwork support,
the qr function doc has a mistake in it: R is a n by n triangular matrix (and not a m by n) and Q is a m by n orthogonal matrix. Consequently the correct sentence should be :
The factor R is an n-by-n upper-triangular matrix, and the factor Q is an m-by-n orthogonal matrix.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Christine Tobler il 20 Ott 2023
Hi,
As you can see here, R is an m by n matrix and Q is an m by m matrix in the default behavior of the qr function:
A = randn(4, 3);
[m, n] = size(A)
m = 4
n = 3
[Q, R] = qr(A)
Q = 4×4
-0.0508 0.1227 0.8744 0.4668 0.1335 -0.3968 -0.3775 0.8260 -0.0578 0.9026 -0.2946 0.3084 0.9881 0.1128 0.0787 -0.0695
R = 4×3
1.5827 0.4303 1.0701 0 -1.0597 0.8078 0 0 2.3270 0 0 0
You may have been thinking about the "economy" syntax, where for the case of m >= n, Q is m by n and R is n by n.
[Q, R] = qr(A, "econ")
Q = 4×3
-0.0508 0.1227 0.8744 0.1335 -0.3968 -0.3775 -0.0578 0.9026 -0.2946 0.9881 0.1128 0.0787
R = 3×3
1.5827 0.4303 1.0701 0 -1.0597 0.8078 0 0 2.3270
##### 2 CommentiMostra NessunoNascondi Nessuno
robin tournemenne il 20 Ott 2023
Spostato: Steven Lord il 20 Ott 2023
Indeed you are right, such a tricky function to use. It took me a long time to understand the result of some pieces of code because of it. I think the doc should be more precise. Rectangular triangular matrices are not common to encounter to my point of view. It seems almost counter intuitive (after a certain column Q is not seen by R).
Christine Tobler il 20 Ott 2023
It's certainly very common in some applications to always think of QR as the economy-size one, and in others to always think of it as the "complete" version, so it's easy to make assumptions of it always being one or the other.
Keep in mind that R can also be rectangular in the "economy" format, if the original matrix (A of size m-by-n) has fewer rows than columns (m<n). The only case where R is guaranteed to be square for a rectangular input matrix is when m>=n.

Accedi per commentare.

### Categorie

Scopri di più su Logical in Help Center e File Exchange

R2023b

### Community Treasure Hunt

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

Start Hunting!

Translated by