MATH547: Linear algebra for applications in data scienceMay 29, 2020

Final Examination

Solve the following problems (5 course points each). Present a brief motivation of your method of solution. Explicitly state any conditions that must be met for solution procedure to be valid. Organize your computation and writing so the solution you present is readily legible. No credit is awarded for statement of the final answer to a problem without presentation of solution procedure.

This is an open-book test, and you are free to consult the textbook or use software to check your solution. Your submission must however reflect your individual effort with no aid from any other person. If you studied the course material and understood solutions to the homework assignments, drafting examination question solutions in TeXmacs should take about 2 hours. The allotted time is 3:10 hours, thus also providing flexibility for internet connection interruption.

Draft your solution in TeXmacs in this file. Upload your answer into Sakai both as a TeXmacs, and pdf. Allow at least 10 minutes before the submission cut-off time to ensure you can upload your file.

Problem 1 (theory)

Two matrices 𝑨,𝑩m×m are said to be similar, denoted as 𝑨𝑩 if there exists some invertible matrix 𝑻 such that 𝑩=𝑻-1𝑨𝑻. Prove that matrix similarity is an equivalence relation.

Solution. Verify equivalence relation properties for 𝑨,𝑩,𝑪m×m:

Reflection

𝑨𝑨 holds with 𝑻=𝑰, 𝑨=𝑰-1𝑨𝑰.

Symmetry

𝑨𝑩𝑩𝑨. If 𝑨𝑩, then 𝑻 such that 𝑩=𝑻-1𝑨𝑻. Multiply on left by 𝑻, on right by 𝑻-1 to obtain 𝑨=𝑻𝑩𝑻-1=(𝑻-1)-1𝑩(𝑻-1)=𝑺-1𝑩𝑺, hence 𝑨𝑩.

Transitivity

𝑨𝑩𝑩𝑪𝑨𝑪. If 𝑨𝑩𝑩𝑪, then 𝑻,𝑼 such that 𝑩=𝑻-1𝑨𝑻 and 𝑪=𝑼-1𝑩𝑼. Replace 𝑩 to obtain

𝑪=𝑼-1𝑻-1𝑨𝑻𝑼=(𝑻𝑼)-1𝑨𝑻𝑼=𝑺𝑨𝑺,

with 𝑺=𝑻𝑼, hence 𝑪𝑨.

Matrix similarity is verified to be an equivalence relation.

Problem 2 (theory)

A matrix 𝑨m×m is said to be skew-symmetric if 𝑨=-𝑨T.

  1. Are skew-symmetric matrices a vector subspace of the vector space of matrices (m×m,,+,)?

  2. Compute 𝒙T𝑨𝒙 when 𝑨 is skew-symmetric.

Solution.

  1. Verify closure for α𝑨+β𝑩, with α,β scalars, 𝑨,𝑩m×m. Compute (α𝑨+β𝑩)T=α𝑨T+β𝑩T=-(α𝑨+β𝑩), verified as skew-symmetric, hence a subspace of (m×m,,+,).

  2. Compute transpose (𝒙T𝑨𝒙)T=𝒙T𝑨T(𝒙T)T=-𝒙T𝑨𝒙. Since α=𝒙T𝑨𝒙 is a scalar, αT=α=-α, hence α=0.

Problem 3 (theory)

Consider for 𝒗m, ||𝒗||2=1, the matrix 𝑯=𝑰-2𝒗𝒗T.

  1. Show that 𝑯 is orthogonal.

  2. Can 𝒗 be chosen such that 𝑯 is a projector?

Solution.

  1. Compute

    𝑯𝑯T=(𝑰-2𝒗𝒗T)(𝑰-2𝒗𝒗T)T=(𝑰-2𝒗𝒗T)(𝑰T-(2𝒗𝒗T)T)=(𝑰-2𝒗𝒗T)(𝑰-2𝒗𝒗T)=

    Since ||𝒗||2=𝒗T𝒗=1, obtain

    𝑯𝑯T=𝑰-2𝒗𝒗T-2𝒗𝒗T+4𝒗(𝒗T𝒗)𝒗T=𝑰-4𝒗𝒗T+4𝒗𝒗T=𝑰.

    And since 𝑯T=(𝑰-2𝒗𝒗T)T=𝑰-2𝒗𝒗T=𝑯, replacing in above gives 𝑯T𝑯=𝑰, hence 𝑯 is orthogonal.

  2. For 𝑯 to be a projector 𝑯2=𝑯, must hold. Compute

    𝑯2=𝑯𝑯=𝑯𝑯T=𝑰=𝑰-2𝒗𝒗T,

    implying 𝒗𝒗T=𝟎 or 𝒗=𝟎, contradicting ||𝒗||2=1, hence 𝑯 cannot be a projector.

Problem 4 (computation)

The matrix 𝑨 contains surveying data (https://math.nist.gov/MatrixMarket/data/Harwell-Boeing/lsq/well1033.html), and its singular value decomposition is 𝑨=𝑼𝚺𝑽T.

octave] 
cd /home/student/courses/MATH547ML/data/lsq; load well1033
octave] 
A=Expression1;
octave] 

  1. Construct a vector 𝒃=𝑼𝒛, with 𝒛 a unit vector of random numbers (||𝒛||=1).

  2. Solve the least squares problem min𝒙||𝑨𝒙-𝒃||.

  3. What is the error e=||𝑨𝒙-𝒃||?

    Remember to briefly comment the solution you present. Presentation of Octave commands without explanation of what you are doing does not received full credit.

Solution.

  1. Compute SVD and generate random numbers

    octave] 
    [U,S,V]=svd(A); [m,n]=size(A); z=rand(m,1); z=z/norm(z); b=U*z;
    disp([norm(z) norm(b)])

    1.0000 1.0000

    octave] 

  2. The solution is the projection of 𝒃 onto C(𝑨), 𝑨𝒙=𝑷C(𝑨)𝒃=𝒚. The projector can be computed from the QR-decomposition, 𝑨=𝑸𝑹 as 𝑷C(𝑨)=𝑸𝑸T.

    octave] 
    [Q,R]=qr(A); y=Q*Q'*b; x=A\y;
    octave] 

    The projector can also be computed from the SVD, 𝑷C(𝑨)=𝑼r𝑼rT with 𝑼r the first r columns of 𝑨, and r=rank(𝑨).

    octave] 
    r=rank(A); u=U(:,1:r)*U(:,1:r)'*b; w=A\u; disp(norm(x-w)); 

    1.2416e-14

    octave] 

  3. Compute error

    octave] 
    err=norm(A*x-b)

    err = 0.81930

    octave] 

Problem 5 (computation)

For the same data as in Problem 4:

  1. Construct a reduced matrix 𝑹=𝑪T𝑨𝑩, that contains the first k singular modes of 𝑨, such that σk/σ110-1, with 𝑩,𝑪 orthogonal matrices.

  2. Find the projection 𝒗 of 𝒃 from problem 4 onto the column space of 𝑪, 𝒗C(𝑪).

  3. Solve the problem 𝑹𝒖=𝒗.

  4. Compare 𝑩𝒖 to least squares solution from Problem 4.

Remember to briefly comment the solution you present. Presentation of Octave commands without explanation of what you are doing does not received full credit.

Solution.

  1. Extract the singular values, check condition σk/σ110-1 to find k.

    octave] 
    s=diag(S); k=310; s(k)/s(1)

    ans = 0.073165

    octave] 

    Define 𝑩,𝑪 from singular vectors of 𝑨

    octave] 
    C=U(:,1:k); B=V(:,1:k); R=C'*A*B;
    octave] 

  2. Since 𝑪 has orthonormal columns, the projection is solution of 𝑷C(𝑪)𝒃=𝑪𝑪T=𝑪𝒗, or 𝒗=𝑪T𝒃

    octave] 
    v=C'*b;
    octave] 

  3. Find solution

    octave] 
    u=R\v;
    octave] 

  4. Compute the relative error ||𝑩𝒖-𝒙||/||𝒙||

    octave] 
    norm(B*u-x)/norm(x)

    ans = 0.99360

    octave] 

    The above relative error is large. Define a function to carry above steps for some k

    octave] 
    function [rerr,Aerr]=ReducedModel(k,A,x,b,s,U,V)
      C=U(:,1:k); B=V(:,1:k); R=C'*A*B;
      v=C'*b; u=R\v;
      rerr = norm(B*u-x)/norm(x);
      Aerr=norm(A-U(:,1:k)*diag(s(1:k))*V(:,1:k)');
    end
    octave] 
    [rerr,Aerr]=ReducedModel(310,A,x,b,s,U,V)

    rerr = 0.99360

    Aerr = 0.099048

    octave] 
    [rerr,Aerr]=ReducedModel(315,A,x,b,s,U,V)

    rerr = 0.96736

    Aerr = 0.028965

    octave] 
    [rerr,Aerr]=ReducedModel(319,A,x,b,s,U,V)

    rerr = 0.74059

    Aerr = 0.010874

    octave] 
    [rerr,Aerr]=ReducedModel(320,A,x,b,s,U,V)

    rerr = 1.1217e-14

    Aerr = 2.5645e-14

    octave] 

    From the above, there is no benefit from model reduction in this case.