% exercise 1.1 in Tref&Bau B = 6*hilb(4) % make a convenient 4x4 example; % many other ways o.k. but rand() is inconvenient---why? % part (a) % MATRIX: ACTION ON B: M1 = diag([2 1 1 1]); B*M1 M2 = diag([1 1 .5 1]); M2*B*M1 M3 = [1 0 1 0; 0 1 0 0; 0 0 1 0; 0 0 0 1]; M3*M2*B*M1 M4 = [0 0 0 1; 0 1 0 0; 0 0 1 0; 1 0 0 0]; M3*M2*B*M1*M4 M5 = [1 -1 0 0; 0 1 0 0; 0 -1 1 0; 0 -1 0 1]; M5*M3*M2*B*M1*M4 M6 = [1 0 0 0; 0 1 0 0; 0 0 1 1; 0 0 0 0]; M5*M3*M2*B*M1*M4*M6 M7 = [0 0 0; 1 0 0; 0 1 0; 0 0 1]; M5*M3*M2*B*M1*M4*M6*M7 % part (b) A = M5*M3*M2; C = M1*M4*M6*M7; A*B*C % morals drawn from exercise 1.1: % 1. All seven operations *can* be written as matrix multiplication. % 2. Matrix multiplication is associative so I don't need lots % of parentheses (though initially I had them ...). % 3. Column ops on the right, row ops on the left. % 4. It is nice to both use the command line *and* have a script % to do a job of even this modest complexity.