Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Are the eigenvalues of a real symmetric matrix sorted?

41 views
Skip to first unread message

Yang

unread,
Feb 23, 2007, 5:45:25 PM2/23/07
to
My question is whether the MATLAB function eig will sort the
eigenvalues of a real symmetric matrix to an ascending order by
default.

I am interested in finding out the maximum or minimum eigenvalue of a
real symmetric matrix. If I know the eigenvalues are automatically
sorted by eig, I do not have to use any max or min function after
executing eig.

In the following example, the eigenvalues (the diagonal of the
diagonal matrix D) are always sorted.

K = randn(4,4);
K = K + K';
[U,D] = eig (K);

However, if I define
K2 = U*abs(D)*U';
then eig(K2) will not do any sorting.

For instance, if D = diag([-5,-4,1,2]) in the example, eig(K2) will
simply return 5, 4, 1, 2.

It seems that different subroutines have been invoked for K and K2.
How can I know what they are?

Michael Hosea

unread,
Feb 23, 2007, 6:03:53 PM2/23/07
to
I think you're right. The second case will often fail to be symmetric due
to roundoff, so the second case is probably handled by the non-symmetric
algorithm. Since you know that it was supposed to be symmetric
mathematically, you can use k2 = (k2 + k2')/2 to enforce symmetry. As for
the eigenvalues being sorted coming from the symmetric algorithm, I haven't
checked it for some time, so I'm not sure, but just throwing some problems
at it, the results were always sorted.

Having said all of that, max and min should be pretty cheap. Life's short,
maybe too short to depend on something like that never changing, unless it's
a documented feature. SVD, for example, guarantees sorted singular values.
--
Mike

"Yang" <yan...@hotmail.com> wrote in message
news:ef4eb...@webcrossing.raydaftYaTP...

Michael Hosea

unread,
Feb 23, 2007, 6:12:33 PM2/23/07
to
I just checked, and for the symmetric case, we use DSYEV, which, in turn, is
documented to return the eigenvalues in ascending order. However, as you
can see, if the input matrix fails to be exactly symmetric, the result might
be correct but without the eigenvalues sorted.
--
Mike

"Michael Hosea" <mho...@mathworks.com> wrote in message
news:ernrsp$nhn$1...@fred.mathworks.com...

Yang

unread,
Feb 23, 2007, 8:31:51 PM2/23/07
to
Michael,

Thanks. You answered my question perfectly. I did not realize that
the matrix K2 = U*abs(D)*U' was considered asymmetric by the
interface function eig simply because of the round-off errors and I
did not expect the answer was so simple.

Thanks again,

Yang

0 new messages