Docsity

Math 571 Homework 2: QR Factorization and Inner Product, Assignments of Mathematics

Toggle sidebar
bg1
Math 571 (Winter 2009): Homework 2
Due Date: See web page
[i] The following Matlab codes implement QR factorization using classical and modified
Gram-Schmidt methods.
function [Q, R] = clgs(A)
[m,n] = size(A);
R = zeros(n,n);
for j = 1:n
v = A(:,j);
for i = 1:j-1
R(i, j) = A(:,i)’*A(:,j);
v = v - R(i,j)*A(:,i);
end
R(j,j) = norm(v);
A(:,j) = v/norm(v);
end
Q = A;
function [Q, R] = mgs(A)
[m,n] = size(A);
R = zeros(n,n);
for j = 1:n
for i = 1:j-1
R(i,j) = A(:,i)’*A(:,j);
A(:,j) = A(:,j) - R(i,j)*A(:,i);
end
R(j,j) = norm(A(:,j));
A(:,j) = A(:,j)/R(j,j);
end
Q = A;
Using the vjand qjnotation used in class and the projectors Pj=qjq∗
j, explain what
operations are being implemented by the lines within the loops. For example, v = v -
R(i,j)*A(:,i); in clgs corresponds to the subtraction of Pjvjfrom vj. Notice that the
codes overwrite A.
Using these codes, reproduce Figure 9.1 of the textbook.
pf2

Partial preview of the text

Download Math 571 Homework 2: QR Factorization and Inner Product and more Assignments Mathematics in PDF only on Docsity!

Math 571 (Winter 2009): Homework 2

Due Date: See web page

[i] The following Matlab codes implement QR factorization using classical and modified Gram-Schmidt methods.

function [Q, R] = clgs(A)

[m,n] = size(A);

R = zeros(n,n); for j = 1:n v = A(:,j); for i = 1:j- R(i, j) = A(:,i)’A(:,j); v = v - R(i,j)A(:,i); end R(j,j) = norm(v); A(:,j) = v/norm(v); end Q = A;

function [Q, R] = mgs(A)

[m,n] = size(A); R = zeros(n,n); for j = 1:n for i = 1:j- R(i,j) = A(:,i)’A(:,j); A(:,j) = A(:,j) - R(i,j)A(:,i); end R(j,j) = norm(A(:,j)); A(:,j) = A(:,j)/R(j,j); end Q = A;

Using the vj and qj notation used in class and the projectors Pj = qj q∗ j , explain what operations are being implemented by the lines within the loops. For example, v = v - R(i,j)*A(:,i); in clgs corresponds to the subtraction of Pj vj from vj. Notice that the codes overwrite A. Using these codes, reproduce Figure 9.1 of the textbook.

[ii] Let D be the diagonal matrix (^) 

Instead of taking the inner product of 3 dimensional vectors x and y to be x∗y as usual, define their inner product to be x∗Dy. Scale the vector

v =

by a positive number α to get q = αv such that q∗Dq = 1. Now q is the unit vector in the direction v under the inner product above. Write down the orthogonal projector in the direction v under the above inner product.

[iii] Let q 1 and q 2 be orthonormal m-dimensional vectors. Consider the following projectors:

  • P = q 1 q 1 ∗ ,
  • I − P ,
  • Q = q 1 q 1 ∗ + q 2 q 2 ∗.

Determine all the eigenvalues and eigenvectors of the three matrices above.

[iv] If A is an m × n matrix of rank 1, prove that it can be written as an outer product of an m-dimensonal vector with an n-dimensional vector.