qr-decomposition.mw

Finding the QR decomposition of A, it exists because the columns of A are linearly independent. 

> with( LinearAlgebra ):
with( VectorCalculus ):
 

Warning, the names `&x`, CrossProduct and DotProduct have been rebound
 

Warning, the assigned names `<,>` and `<|>` now have a global binding
 

Warning, these protected names have been redefined and unprotected: `*`, `+`, `.`, D, Vector, diff, int, limit, series 

> A := Matrix( [[1,1,0,1],[-1,0,1,1],[1,1,1,1]]);
 

A := Matrix(%id = 2988744) 

Q is constructed from the orthnormalized columns of A using Gram Schmidt. 

> orthonormCols := GramSchmidt( [Column( A, 1..4 )], normalized ):
Q := Matrix( orthonormCols );
 

Q := Matrix(%id = 7432348) 

R = Q^T * A 

> R := Transpose( Q ) . A;
 

R := Matrix(%id = 16838512) 

Since A = Q * R, we should be able to regenerate the original matrix. 

> Q . R;
 

Matrix(%id = 2475996) 

Just for demonstration purposes, here's how to accomplish the decomposition using a native maple call. 

> (mQ,mR) := QRDecomposition(A, fullspan);
mQ . mR;
 

mQ, mR := Matrix(%id = 7506028), Matrix(%id = 7506324) 

Matrix(%id = 7517952) 

>
 

>