Why does the SVDS function in MATLAB return different results each time it is called?

3 views (last 30 days)
I execute the following code to find the largest singular value of a matrix:
x=randn(3)+j*randn(3);
[u,s,v]=svds(x,1)
[u2,s2,v2]=svds(x,1)
The outputs of the second and third lines are different.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This is expected behavior. Singular vectors are unique only up to multiplication by a scalar of magnitude 1:
u2\u
v2\v
abs(u2\u)
The above code demonstrates that u2 and v2 can be formed by multiplying u and v respectively by the same scalar, and that scalar has magnitude 1. Therefore, both [u,s,v] and [u2,s2,v2] are correct answers, although s and s2 differ in the last few decimal places. This is due to the iterative method used in SVDS.
The SVDS function calls the EIGS function. The EIGS function uses an iterative approach to finding the singular values and singular vectors. The initial guess is randomly generated, which is why different singular vectors are computed each time and why slightly different singular values are calculated each time. To guarantee the same answer each time, specify an initial vector as part of the options structure, which is the fourth argument to SVDS. The documentation for EIGS also documents the options structure.
For more information on the EIGS function, please type "help eigs" or "doc eigs" (without quotes) at the MATLAB command prompt.

More Answers (0)

Categories

Find more on Eigenvalues in Help Center and File Exchange

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!