FF505/FY505 – Computational Science
Week 6, Spring 2013 [pdf format]

Contents:

MATLAB Exercises

Work in small groups at the computer to solve the following exercises.

  1. Find the matrix for reflection in the plane orthogonal to the vector (1,2,−2,1,0) in ℝ5.
  2. Are magic squares nonsingular? Use the MATLAB command det(magic(n)) to compute the determinants of the magic squares matrices in the cases n=3,4,…, 10. What seems to be happening? Check the cases n=24 and n=25 to see if the pattern still holds.
  3. Rank-1 Updates of Linesr Systems:
    1. Set A=round(10*rand(8)), b=round(10*rand(8,1)) and M=inv(A). Use the matrix M to solve the system Ax=b for y.
    2. Consider now the new system Cx=b, where C is constructed as follows:
      u=round(10*rand(8,1)), v=round(10*rand(8,1)), E=u*v′, C=A+E.
      The matrices C and A differ by the rank 1 matrix E. Use MATLAB to verify that the rank of E is one. Use MATLAB’s "\" operation to solve the system Cx=b and then compute the residual vector r=bCx.
    3. Let us now solve Cx=b by a new method that takes advantage of the fact that A and C differ by a rank-1 matrix. This new procedure is called rank-1 update method.
      Set z=M*u, c=v′*y, d=v′*z, e=c/(1+d) and then compute the solution x by x=ye*z. Compute the residual vector bCx and compare it with the residual vector in part (b). This new method may seem more complicated, but it actually is much more computationally efficient.
    4. To see why the rank-1 update method works, use MATLAB to compute and compare Cy and b+cu. Also compute Cz and (1+d)u. Use the observed identities to prove Cx=b.
    5. Assuming that A is nonsingular, will the rank-1 update method always work? Under what conditions could it fail? Explain.
  4. Use MATLAB to generate a matrix W and a vector x by setting W=triu(ones(5)) and x=[1:5]′. The columns of W form an ordered basis F={ w1, w2, …, w5}. Let L:ℝ5 → ℝ5 be a linear operator such that L(w1)+w2, L(w2)=w3, L(w3)=w4, and L(w4)=4w1+3w2+2w3+w4, L(w5)=w1+w2+w3+3w4+w5.
    1. Determine the matrix A representing L with respect to F, and enter it in MATLAB.
    2. Use MATLAB to compute the coordinate vector y=W−1x of x with respect to F.
    3. Use A to compute the coordinate vector z of L(x) with respect to F.
    4. W is the transition matrix from F to the standard basis for ℝ5. Use W to compute the coordinate vector of L(x) with respect to the standard basis.