MATLAB: Error with eigenvalues of unitary matrix

diagonalizationeigenvalues

I am trying to diagonalize a unitary matrix, but am getting an error message:
"flag = processEUPDinfo(nargout<3);"
This is surprising, as unitary matrices are very well behaved.
The code is quite simple:
A=randn(100);
B=randn(100);
Z=A+B*1i;
[U,S,V]=svd(Z);
eigs(U)
What is the matter??

Best Answer

As mentioned in the comments above, if you are intending to compute all eigenvalues, it's best to call EIG, not EIGS. In fact, even if you only need a subset, for a matrix of size 100 it's probably cheaper to just call EIG.
Now why is EIGS having a hard time with this specific matrix? This is a well-conditioned problem, as you say, but in fact, it's computing a subset that is making it hard for EIGS.
The algorithm used by eigs(A) is based on an iteration that moves a set of 20 vectors closer to the eigenvectors with eigenvalues of largest magnitude. The problem is that for matrix U, all eigenvalues have the same magnitude:
plot(eig(U), 'x')
Because of this, the algorithm gets locked up trying to decide which are the 6 largest eigenvalues of this matrix, and unable to commit to any one set.
For a small dense matrix, you should definitely just compute all eigenvalues with EIG. If you have a larger matrix, the best thing is probably to rethink what subset of eigenvalues you are looking for. For example, searching for the 6 eigenvalues closest to 1 converges easily:
eigs(U, 6, 1)
Related Question