Precision in SVD calculation through eigenvalues/eigenvectors

46 views Asked by At

In octave I used eigendecomposition to calculate svd instead of svd fuction istelfand compare the results.

Errors are following using exiting SVD function

[U2,S2,V2] = svd(A2);
errU2U2t = max(max((U2*U2')-eye(size(U2,1)))) = 3.1086e-15 
errU2tU2 = max(max((U2'*U2)-eye(size(U2,1)))) = 1.3767e-14
errU2V2t = max(max((V2*V2')-eye(size(V2,1)))) = 2.6645e-15
errV2tV2 = max(max((V2'*V2)-eye(size(V2,1)))) = 1.4433e-14
errA2= max(max(A2-U2*S2*V2'))                 = 9.7056e-13

For the alternative approach (twice faster) I used eigendecomposition

A2tA2 = A2'*A2;
[V22,SV22,W22] = eig(A2tA2);
%U22 = A2*V22/(sqrt(SV22)); % optional, increase calculation time
U22sig = A2(1,:)*V22/(sqrt(SV22));
for spin=1:size(U22,2) % sign correct
  if sign(W22(1,spin))!=sign(U22sig(1,spin))
    W22(:,spin) = - W22(:,spin);
  end
end

Errors are

errU22U22t = max(max(U22*U22t-eye(size(U22,1)))) = 1.9185e-10
errU22tU22 = max(max(U22t*U22-eye(size(U22,1)))) = 5.6592e-09
errW22W22t = max(max(W22*W22t-eye(size(W22,1)))) = 2.8866e-15
errW22tW22 = max(max(W22t*W22-eye(size(W22,1)))) = 1.1324e-14
errV22V22t = max(max(V22*V22t-eye(size(V22,1)))) = 2.8866e-15
errV22tV22 = max(max(V22t*V22-eye(size(V22,1)))) = 1.1324e-14
errA22u    = max(max(A2-U22*sqrt(SV22)*V22'))    = 1.4655e-13
errA22w    = max(max(A2-W22*sqrt(SV22)*V22'))    = 2.1129e-08

It looks like that

If I use U22 its accuracy is bad (on transpose mult error) but reconstructed A22u is good

If I use W22 its accuracy is good (on transpose mult error) but reconstructed A22w is bad

Does someone knows how to improve the calculation of U22 without loosing accuracy on A22u ? Or where this error comes from ?

0

There are 0 answers