(*Q3, TUT 2C*)
A={{9,1,4,0,1},{2,5,0,1,0},{7,0,3,0,-1}};
H={1,3,-1};
X={x1,x2,x3,x4,x5};
aug={{9,1,4,0,1,1},{2,5,0,1,0,3},{7,0,3,0,-1,-1}};
Print["A is ",A//MatrixForm];
Print["H is ",H//MatrixForm];
Print["AX=H is ",A.X//MatrixForm,"=",H//MatrixForm];
Print["Rank[A]=",MatrixRank[A]];
Print["Rank[A|H]=",MatrixRank[aug]];
Print["particular solution,X_p = ",LinearSolve[A,H]//MatrixForm];
Print["A.X_p=",MatrixForm[A.LinearSolve[A,H]]];
Print["For homegeneous solutions:"];
Print["n-r=",5-MatrixRank[A]," hence we exepct two linearly independent solutions for AX=0"];
Print["A.X=",A//MatrixForm,X//MatrixForm,"=",{0,0,0}//MatrixForm];
Print["≡RREF[A].X=",
RowReduce[A]//MatrixForm,X//MatrixForm,"=",
RowReduce[A].X//MatrixForm,"=",MatrixForm[{0,0,0}]];
x4=a;x5=b;
Print["Let x4=a,x5=b"];
x1=(1/11)(-3x4+35x5);
x2=(1/11)(-1x4-14x5);
x3=(1/11)(7x4-78x5);
Print["Hence, X_h=",{x1,x2,x3,x4,x5}//MatrixForm,"=a", MatrixForm[{-3/11,-1/11,7/11,1,0}],"+b",MatrixForm[{35/11,-14/11,-78/11,0,1}]];
Print["The complete solutions is X_p + X_h"];