MATLAB problems from Midterm Problem Set II D. Finding the 2-norm of $B$ by the formula (3): >> B = bucky; >> max(eig(B'*B)) ans = 9.0000 Hence ||B||_2 = 3. Check with MATLAB's norm function: >> norm(full(B),2) ans = 3 II F. MATLAB can compute Frobenius norms directly like this: >> norm(B,'fro') ans = 13.4164 It's not hard to see that this can also be computed directly as sqrt(sum(diag(B'*B))) (i.e. the square root of the trace of the matrix B'*B -- the sum of the diagonal entries). The inequality (3) is satisfied since 3 <= 13.4164 <= 3 sqrt{60} =~ 23.2379. III A. X is the following 2 x 7 matrix: >> X = [1.001 1; 1.002 1; 1.003 1; 1.004 1; 1.005 1; 1.006 1; 1.007 1] X = 1.0010 1.0000 1.0020 1.0000 1.0030 1.0000 1.0040 1.0000 1.0050 1.0000 1.0060 1.0000 1.0070 1.0000 >> cond(X'*X,inf) ans = 1.0121e+06 This is rather large, which indicates that the normal equations are relatively ill-conditioned. We can see this from the form of the matrix X'*X also: >> X'*X ans = 7.0561 7.0280 7.0280 7.0000 We can see that the columns are quite close to being proportional, so this matrix is "nearly singular". (This condition number is not large enough that MATLAB's default double precision floating point number system gives an inaccurate result, however.) III B. The shifted and rescaled system is >> Xprime = [-.9 1; -.6 1; -.3 1; 0 1; .3 1; .6 1; .9 1] Xprime = -0.9000 1.0000 -0.6000 1.0000 -0.3000 1.0000 0 1.0000 0.3000 1.0000 0.6000 1.0000 0.9000 1.0000 >> cond(Xprime'*Xprime,inf) ans = 2.7778 This is much smaller, so the modified normal equations will be much better conditioned. The solution is >> Y = [3.664; 3.789; 3.891; 4.022; 4.233; 5.200; 5.329] Y = 3.6640 3.7890 3.8910 4.0220 4.2330 5.2000 5.3290 >> Xprime'*Xprime \ Xprime'*Y ans = 0.9713 4.3040 This says the best-fit line is given by y = (.9713)(300(x - 1.004)) + 4.3040 = 291.39 x - 288.25 (agrees with solving the usual normal equations).