# Which algorithm does SVD function take?

20 Ansichten (letzte 30 Tage)
Bin am 29 Jan. 2024
Bearbeitet: Matt J am 30 Jan. 2024
Hi Matlab supporter,
Could I you tell me which algorithm (algorithm name and basic description) does Matlab SVD function take for svd decomposion? (In Matlab 2020b). When I compared Matlab decomposition results with Scilab decomposition results, I find they are different, all meet SVD decomposion definition, but they have different U,V. ([U S V]=svd(A), U*S*V'=A)
Hope to get help from you.
Thank you,
Regards,
Bin
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Matt J am 29 Jan. 2024
Bearbeitet: Matt J am 29 Jan. 2024
The SVD algorithm is not disclosed by MathWorks, but even if you could be sure the same algorithms were used by both Matlab and SciLab, it would not help you avoid or understand differences in the results. Since you have a matrix with non-unique SVDs, the SVD computation is unstable, and can result in large differences from one implementation to another, merely from the fact that the code implementations are different.
##### 13 Kommentare11 ältere Kommentare anzeigen11 ältere Kommentare ausblenden
Bruno Luong am 30 Jan. 2024
Bearbeitet: Bruno Luong am 30 Jan. 2024
Bruno Luong am 30 Jan. 2024
Bearbeitet: Bruno Luong am 30 Jan. 2024
@Bin " I would like to get 'same' U, V in Scilab like that in Matlab to make our calculation results identical."
You waste your time. The signs of eigen vectors are unpreditable. You could however force the sign to your own specification (*), but they come out of the algorithm almost arbitray.
(*) for example pick the largest element in absolute value of an singular vector, then set the sign so that this element is positive (assuming there no draw with opposite sign). Also you cannot change the signs of the odd number of eigen vectors, since U and V must be unitary matrices (det = 1) by convention of SVD.

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (2)

Catalytic am 29 Jan. 2024
Comparing results showed that max difference in S and S1 reached 1e-14, but for U and U1 or for V and V1, max difference reached 0.xxx.
We would have to see S and S1, so you might wish to attach them for us in a .mat file. If all the S(i) are distinct, as I would expect for a random matrix A, the singular vectors are unique up to a difference in sign. So, when you calculate the max difference, you should make sure you accounted for a sign flip.
If some singular values S(i) are repeated, then the singular vectors are unstable and, as @Matt J mentions, you can expect to see all kinds of numerical differences for all kinds of reasons.
##### 3 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Catalytic am 29 Jan. 2024
@Bruno Luong I'm very pleased you consider my answer to merit +1 (but you didn't actually upvote it) :-)
Bruno Luong am 29 Jan. 2024
I didn't because it actually does not answer the question "which algorithm", but I think you are right on on the diagnostic.

Melden Sie sich an, um zu kommentieren.

Torsten am 29 Jan. 2024
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Eigenvalues finden Sie in Help Center und File Exchange

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by