title 'Assignment 4: Green & Carroll problems'; * -------------------------------------- ; proc iml; reset print log fuzz fw=6; %include iml(matlib); *-- Chapter 3, #7; X = t({ 1 2 3, 3 0 2, 3 1 1}); Z = X; Z[,2] = X[,2] - proj(X[,2], Z[,1]); Z[,3] = X[,3] - proj(X[,3], Z[,1]) - proj(X[,3], Z[,2]); *-- normalize the columns to make lengths = 1; Z = Z * diag( 1 / len(Z) ) ; *-- verify that it is orthonormal; print (t(Z) * Z); *-- compare with gsorth() result; call gsorth(Z,T,flag,X); *-- 4.7b,c ; A = { 3 2 4, 2 0 2, 4 2 3}; r = echelon(A); rank = r(A); A = { 4 3 2 18, 2 1 3 10, 5 7 2 29}; r = echelon(A); rank = r(A); *-- Only 3 columns are linearly independent; * so, we can solve for one as linear comb of other three; * e.g., solve A[,{1 2 3}] * x = A[,4]; x = solve(A[,1:3], A[,4]); print (A[,4]) '=' (A[,1:3] * x); *-- 4.9a; A = {2 1 4, 1 -1 1, 1 2 3}; b = {13, 2, 10}; r = echelon(A); r = echelon(A||b); *-- Inconsistent: No exact solution; *-- 4.9b; A = {1 2 6, 1 3 -1, 1 2 0}; b = {16, 12, 10}; r = echelon(A); r = echelon(A||b); *-- Unique solution; x = solve(A, b); print (A * x) '=' b; quit;