Numerical Linear Algebra (MTH 451)
Homework 3 (100 points)
Due: Wednesday, October 18, 2006 at 10am in class
I (45 points) The MATLAB command svd computes the SVD of a ma-
trix, e.g., [U,S,V]=svd(A). Type help svd to see the syntax and doc
svd for an example. Consider the following matrices:
1 0 0
(a) A =
0 1 1
(b) A is the 3 × 3 Hilbert matrix (see hilb in MATLAB).
(c) A is the 3 × 3 matrix defined by Ai,j = i + j − 1 (Hint: try
1./hilb(3))
Answer the following:
(1) For each of the matrices in (a), (b) and (c), compute the SVD in
MATLAB. (Note: You can check if the SVD worked by typing
B=U*S*V.’ where V. is the conjugate transpose of V and make
sure that B = A).
(2) The 2-norm condition number of a matrix is defined to be
κ(A) = σ1 /σp
where σ1 = the largest singular value, and σp = is the smallest
singular value. Calculate the 2-norm condition number of the
three matrices in (a), (b) and (c) above.
II (25 points) Do 4.3 on page 31 of Trefethen and Bau.
III (30 points) The SVD can be used to compress matrices. As an illustra-
tion we shall look at compressing an image (just a matrix giving entries
in a color map).
• Load the clown image and show the image as follows:
>>clear all
>>whos
>>load clown
>>whos
Here we cleared the workspace of all data, loaded the image and
then used whos to see what is in the workspace. You should see
the image X and the colormap map, both described as matrices.
• To plot the image, type the following:
1
>>image(X); colormap(map)
• Now compute the SVD
>>[U,S,V]=svd(X);
• You can plot the normalized singular values (so the largest value
is 1) by
>>plot(diag(S)/max(diag(S)))
You can see that some singular values are quite small compared
to 1 and so ignoring the corresponding singular vectors will not
affect the image much.
• Suppose we only use the first five singular values to store the
image X. The corresponding approximation to X is given by X5
as follows
>>X5=U(:,1:5)*S(1:5,1:5)*V(:,1:5).’;
>>image(X5); colormap(map)
(a) Repeat with 10, 15, 20 and 50 singular values. What happens
as the number of singular values are increased? Write a small
paragraph about your observations and conclusions.
(b) There is a function on the web to do the process outlined in III
(a). Get (i.e. save)
http://www.mathworks.com/moler/ncm/imagesvd.m
Run it by typing imagesvd and choose the clown image from the
left drop down menu. Experiment with different numbers of sin-
gular values using the center slider. Repeat with the mandrill
image (increase the number of singular values slowly from 1). In
your opinion, which of these two images has better SVD compres-
sion (i.e., higher percentage of singular values can be dropped)?
(c) Based on your understanding of image compression as described
in this problem, which of the three matrices in Problem I ((a),
(b), or (c)) is best suited for compression by the SVD technique?
Why?
2