@sym: [Q, R] = qr (A) ¶@sym: [Q, R] = qr (A, 0) ¶@sym: R = qr (A) ¶Symbolic QR factorization of a matrix.
Example:
A = sym([1 1; 1 0]);
[Q, R] = qr (A)
⇒ Q = (sym 2×2 matrix)
⎡√2 √2 ⎤
⎢── ── ⎥
⎢2 2 ⎥
⎢ ⎥
⎢√2 -√2 ⎥
⎢── ────⎥
⎣2 2 ⎦
⇒ R = (sym 2×2 matrix)
⎡ √2⎤
⎢√2 ──⎥
⎢ 2 ⎥
⎢ ⎥
⎢ √2⎥
⎢0 ──⎥
⎣ 2 ⎦
Passing an extra argument of 0 gives an “economy-sized”
factorization. This is currently the default behaviour even without
the extra argument. In fact the result may even more minimal than
the double precision ‘qr’; when the input has low rank, a
rectangular rank-revealing result is returned:
[Q, R] = qr (sym ([6 2; 6 2]))
⇒ Q = (sym 2×1 matrix)
⎡√2⎤
⎢──⎥
⎢2 ⎥
⎢ ⎥
⎢√2⎥
⎢──⎥
⎣2 ⎦
⇒ R = (sym) [6⋅√2 2⋅√2] (1×2 matrix)
We have one column in Q because the original matrix had
rank one:
Q*R
⇒ ans = (sym 2×2 matrix)
⎡6 2⎤
⎢ ⎥
⎣6 2⎦
But what of the extreme case of a zero matrix?
[Q, R] = qr (sym (zeros (2, 2))) ⇒ Q = (sym) [] (empty 2×0 matrix) ⇒ R = (sym) [] (empty 0×2 matrix)
Q*R
⇒ ans = (sym 2×2 matrix)
⎡0 0⎤
⎢ ⎥
⎣0 0⎦
Magic? Not really but don’t let anyone tell you the dimensions of empty matrices are unimportant!
See also: qr, @@sym/lu.
Package: symbolic