why do I get the following result with Matlab's SVD?

71 Views Asked by At

I am doing an SVD on a random matrix in Matlab $A = U S V'$.

Then, I do calculate $B = U V'$.

Finally, I do SVD on $B = U_2 S_2 V_2'$.

I would expect $U_2 = U$ and $V_2 = V$ up to a permutation and sign. However, that's not what I get?

>> A = rand(4);        
>> [U,S,V] = svd(A);
>> B = U*V';
>> [U2,S2,V2] = svd(B);
>> [U,S,V]             

ans =

   -0.4301   -0.3017   -0.7235   -0.4478    1.9145         0         0         0   -0.2728    0.2536   -0.8063   -0.4595
   -0.5740   -0.2789    0.6804   -0.3602         0    0.9968         0         0   -0.5691    0.4038    0.5682   -0.4361
   -0.4518   -0.3479   -0.0916    0.8164         0         0    0.4182         0   -0.6488   -0.7554   -0.0585    0.0709
   -0.5305    0.8427   -0.0716    0.0576         0         0         0    0.1975   -0.4251    0.4494   -0.1539    0.7705

>> [U2,S2,V2]

ans =

    0.2675   -0.4769    0.1102   -0.8300    1.0000         0         0         0         0         0         0   -1.0000
   -0.2428   -0.7709   -0.5083    0.2972         0    1.0000         0         0   -0.6667   -0.3333   -0.6667         0
   -0.2210   -0.3903    0.8532    0.2663         0         0    1.0000         0    0.1333   -0.9333    0.3333         0
   -0.9059    0.1610   -0.0393   -0.3897         0         0         0    1.0000   -0.7333    0.1333    0.6667         0

EDIT: If my comment below is true, and that's related to singular value uniqueness, why the following still doesn't recover U and V? In here, instead of computing $B = U V'$ I compute $B = U Z V'$ for some diagonal matrix $Z$.

>> A = rand(4);
>> [U,S,V] = svd(A);
>> Sig = eye(4);
>> Sig(1,1) = 0.1; Sig(2,2) = 0.2; Sig(3,3) = 0.3; Sig(4,4) = 0.4;
>> [U2,S2,V2] = svd(U*Sig*V');
>> [U2,S2,V2]

ans =

   -0.6462    0.2155   -0.3590    0.6380    0.4000         0         0         0    0.7196   -0.1621    0.3613    0.5705
    0.1069   -0.8111    0.2451    0.5202         0    0.3000         0         0    0.0416    0.9401   -0.1444    0.3061
    0.6373    0.0083   -0.7358    0.2287         0         0    0.2000         0   -0.6924   -0.1247    0.3268    0.6310
    0.4059    0.5436    0.5193    0.5197         0         0         0    0.1000    0.0321   -0.2729   -0.8613    0.4274

>> [U,S,V]

ans =

   -0.6380    0.3590    0.2155   -0.6462    2.6201         0         0         0   -0.5705   -0.3613   -0.1621    0.7196
   -0.5202   -0.2451   -0.8111    0.1069         0    0.8590         0         0   -0.3061    0.1444    0.9401    0.0416
   -0.2287    0.7358    0.0083    0.6373         0         0    0.3796         0   -0.6310   -0.3268   -0.1247   -0.6924
   -0.5197   -0.5193    0.5436    0.4059         0         0         0    0.0306   -0.4274    0.8613   -0.2729    0.0321
1

There are 1 best solutions below

5
On BEST ANSWER

When $B = U S V^t$, it says that wrt the $U$ basis of the codomain and the $V$ basis of the domain, the transformation $B$ looks like the identity.

Since this is true, altering the $U$ basis by post multiplication by any rotation $R$ (and multiplying $V$ by the same thing) will still give a basis in which the transformation looks like the identity. In short:

$$ B = U I V^t $$ implies that $$ B = (UR) I (VR)^t $$ for any orthogonal matrix $R$. So the SVD has lots of freedom in picking the SVD for your second matrix.