%% Datta, page 595, Ex 25 % Demo_L2_3, check (insensitivities of the singular values % Module 2, Lecture 2, Demo no. 1, SVD disp(' ----------- Singular Vale Decomosition: Demo no 3: -----------') disp(' ---------------- (In)Sensitivities of the SVD ----------------') disp(' ') disp('Maya has to sow a slide again... ') disp(' ') wait eeps=0.99; epss = 1e-5; disp('eeps=0.99; epss = 1e-5;') for n=[4,50] %A=[1 1 1 1;0 eeps 1 1;0 0 eeps 1; 0 0 0 eeps]; %E=[0 0 0 0;0 0 0 0;0 0 0 0; epss 0 0 0]; A=ones(n); A=triu(A); dd=(1-eeps)*ones(n,1); A=A-diag(dd); A(1,1) = 1; E = zeros(n); E(n,1) = epss; AE = A+E; [U,S,V] = svd(A); [UE,SE,VE] = svd(AE); EigA = eig(A); EigAE = eig(AE); if n<8, disp(A),waitt('The matrix A') disp(E),waitt('The permutation matrix E') disp(A+E),waitt('The permuted matrix A+E') disp('The eigenvalues of A') format long disp(EigA) disp('The eigenvalues of A+E') disp(EigAE) disp('They are complex'),wait disp('_________________________________') disp('What about the sigular values?'),wait disp('Print those of A, of A+E and the difference') [diag(S) diag(SE) diag(S)-diag(SE)] else figure(2),clf,mesh(A) % figure(3),clf,spy(A) waitt('.....') figure(2),clf,mesh(E) figure(4),clf, plot(EigA,'o'), title('The eigenvalues of A') figure(5),clf, plot(EigAE,'o'),title('The eigenvalues of A+E') figure(6),clf, plot(diag(S)-diag(SE),'o'),title('The difference in the singular values') end wait end disp('... end demo') %