9.3. How SVD Changes VectorsΒΆ

With the exception of rotation matrices and eigenvectors, we normally see both rotation and stretching when a point or vector is multiplied by a matrix. When the matrix is represented by its SVD factors, we see rotation, stretching, and again rotation when we multiply sequentially by \mathbf{V}^T, \mathbf{\Sigma}, and \mathbf{U}. The showSVD function may be used to experiment with several 2{\times}2 matrices to see the rotation, stretching, and rotation. The demonstration starts with a set of points on a circle. In the end, the circle pattern will be changed to show a rotated ellipse. Figures Fig. 9.4, and Fig. 9.5 show example plots. The plots will be different for each matrix supplied.

function show_SVD(A)
% SHOW_SVD - A demonstration of how the U, S, and V matrices
%   from SVD rotate, stretch, and rotate vectors making a circle.
%   Try several 2x2 matrices to see how each behaves.

theta = linspace(0, 2*pi, 30);
x = [cos(theta); sin(theta)];

[U,S,V] = svd(A);

Vx = V'*x;
figure, plot(x(1,:), x(2,:), '*')
hold on
scatter(Vx(1,:), Vx(2,:))
for z = 1:30
    line([x(1,z), Vx(1,z)], [x(2,z), Vx(2,z)], 'Color', 'k')
end
title('Rotation by V^T Matrix')
hold off

svx = S*Vx;
figure, scatter(svx(1,:), svx(2,:), '*')
daspect([1 1 1])
usvx = U*svx;
hold on
scatter(usvx(1,:), usvx(2,:), 'o')
title('Stretch by /Sigma and rotation by U')
hold off
../_images/SVDrotV.png

Fig. 9.4 When each point is multiplied by \mathbf{V}^T the points rotate around the circle. The lines show the initial and final positions of the points.

../_images/SVDrotSigU.png

Fig. 9.5 When each point is multiplied by \mathbf{\Sigma}, the points around the circle are moved out from the center to form an ellipse. Then the ellipse is rotated when the points are multiplied by \bf{U}.