.. _svdVectorChange: How SVD Changes Vectors ======================= Except for rotation matrices and eigenvectors, we normally see rotation and stretching when a 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 a vector sequentially by :math:`\mathbf{V}^T`, :math:`\mathbf{\Sigma}`, and :math:`\mathbf{U}`. Use the demonstration function ``showSVD`` to experiment with several :math:`2{\times}2` matrices to see the rotation, stretching, and second rotation. The demonstration starts with a set of points on a circle. Ultimately, the circle pattern will be changed to show a rotated ellipse. Figure :numref:`fig-SVDrotV`, and figure :numref:`fig-SVDrotSigU` 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 hold off, title('Rotation by V^T Matrix') svx = S*Vx; figure, scatter(svx(1,:), svx(2,:), '*') daspect([1 1 1]), usvx = U*svx; hold on, scatter(usvx(1,:), usvx(2,:), 'o'), hold off title('Stretch by \Sigma and rotation by U') .. _fig-SVDrotV: .. figure:: SVDrotV.png :figclass: center-caption :align: center :width: 30% :alt: When each point is multiplied by V transpose the points rotate around the circle. The lines show the initial and final positions of the points. When each point is multiplied by :math:`\mathbf{V}^T` the points rotate around the circle. The lines show the initial and final positions of the points. .. _fig-SVDrotSigU: .. figure:: SVDrotSigU.png :figclass: center-caption :align: center :width: 30% :alt: When each point is multiplied by 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 U. When each point is multiplied by :math:`\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 :math:`\bf{U}`.