It is noted that the Matlab syntax for qr decomposition (https://www.mathworks.com/help/symbolic/qr.html#d120e152496):

[Q,R,P] = qr(A) returns an upper triangular matrix R, a unitary matrix Q, and a permutation matrix P, such that A*P = Q*R. If all elements of A can be approximated by the floating-point numbers, then this syntax chooses the column permutation P so that abs(diag(R)) is decreasing.

For example: A = [12 -51 4; 6 167 -68; -4 24 -41]

Then, [Q,R, P] = qr(A)

`Q = -0.2894 -0.4682 -0.8349 0.9475 -0.0160 -0.3194 0.1362 -0.8835 0.4483R = 176.2555 -71.1694 1.6680 0 35.4389 -2.1809 0 0 -13.7281P = 2 3 1`

What's the physcial meaning of the fact that the diagnoal elements of R matrix are decreasing in magnitude? Without the output P, the resulting Q and R occurs in a different order in its column vectors.

I am not clear of how these different demposition behaviors occur. What's the specific algorithm Matlab is using for qr? Householder reflections (https://blogs.mathworks.com/cleve/2016/10/03/householder-reflections-and-the-qr-decomposition/)? Any relevant resources are welcome.

## Best Answer