function ShowSVD2(A)
% A is a 2-by-2 matrix. Displays the image of the unit circle
% and the bounding box.
% 
close all
figure
axis equal off
hold on
n = 200;
theta = linspace(0,2*pi,n);
Z = A*[cos(theta);sin(theta)];
x = Z(1,:);
y = Z(2,:);
fill(x,y,'y')


% Semiaxis computations...
[U,S,V] = svd(A);
F = U*S;
plot([F(1,1) -F(1,1)],[F(2,1) -F(2,1)],'r')
plot([F(1,2) -F(1,2)],[F(2,2) -F(2,2)],'g')

% Bounding box computations...
% Let z be a unit vector and note that Az = [A(1,:)z ; A(2:,z)].
% Following the hint, the numerator is max'd with z = A(1,:)'/norm(A(1,:)).
% This gives the top the bounding box. Similar reasoning for the other
% three sides...
a = norm(A(1,:));
b = norm(A(2,:));

% -1 if you takes max's and mins of the plot points
plot([a -a -a a a],[b b -b -b b])

title(sprintf('Major = %6.3f  Minor = %6.3f  (a,b) = (%6.3f,%6.3f)',S(1,1),S(2,2),a,b))