Skip to main content
1-Visitor
July 29, 2010
Question

Eigenvalues out of order

  • July 29, 2010
  • 3 replies
  • 22077 views

I have a problem with the eigenvals() function. USALLY the results are sorted from largest to smallest, but occasionally they will be out of order. I have found the following simple matrix that demonstrates this:

[A] = 1.0053 1.0053 1.0053

1.0053 2.0001 2.0001

1.0053 2.0001 3.4365

eigenvals(A) = {5.301 0.337 0.803}

This can be a tremendous problem if, for example, I have a 100x100 matrix and I only need the first 3 eigenvalues and their associated eigenvectors.

See attached mathcad sheet with demo and illustration of what I go through to sort the values and vectors properly. Surely there must be a better way!

3 replies

1-Visitor
July 30, 2010

No problem for any n x n out of "as big as can the matrix be" .

Mathcad 11 takes a size up to 4096 x 4096.

Will that be enough for your project?

jmG

dBoggs1-VisitorAuthor
1-Visitor
July 30, 2010

What???

I don't understand your answer. Perhaps you didn't understand my question.

I'm complaining that the returned eigenvalues are not sorted in order, and I would like to know if this is a bug. The eigenvalues are always sorted when I use functions in other languages or applications. I find it hard to believe that the Mathcad behavior is intentional.

Your response seems only to demonstrate a method of extracting a submatrix, and what large matrices it works with, but I don't care about that.

23-Emerald V
July 30, 2010

DARYL BOGGS wrote:

I'm complaining that the returned eigenvalues are not sorted in order, and I would like to know if this is a bug. The eigenvalues are always sorted when I use functions in other languages or applications. I find it hard to believe that the Mathcad behavior is intentional.

I'm not sure that all maths applications return sorted eigenvalues - I've got a feeling that I've seen something about Maple not sorting and I don't know that there is a 'standard' as such (I've seen a few requests for reversing the sort order in Matlab as well). I believe that GNU has functions that allow the user to specify the sort order, but I haven't checked.

However, it is deliberate and the subject has been discussed before - see here for example.

You could get round your sort problem by cheating and stacking max(eigenvals)-eigenvals before sorting and then carrying out the same operation. See attached worksheet.

19-Tanzanite
July 30, 2010

In version 15 they are in order. They do fix some things, some of the time 🙂

If you really need only the first 3 out of 100 eigenvectors the best thing is not to get all the eignvectors in the first place though. Get the eigenvalues, sort them, and then get the first 3 eignevectors using the eigenvec function. Or you could use the syntax in the attached worksheet to get all of them.

1-Visitor
July 30, 2010

I was wondering what the three highest eigenvalues could represent wrt an "n x n" system. No abstract, not even a hint ! So, I will leave it there unless more help is specified c/w a work sheet and the issue of the project. Hopefully it has nothing to do with attempting to approximate something unknown.

Cheers Stuart, Richard

19-Tanzanite
July 30, 2010

jean Giraud wrote:

I was wondering what the three highest eigenvalues could represent wrt an "n x n" system.

For one example, look in the DAEP under principle component analysis.

10-Marble
July 31, 2010

Ian Ward has a great solution to this problem in his post DynamAssist to the old collab.

I have borrowed it and found it very useful.

1-Visitor
August 3, 2010

Daryl,

Can you send me the exact details for how you want the sorting to work for both Eigenvalues and Eigenvectors, or how it works in other programs, that is not working for you in Mathcad? I can add this to suggested features.

Thanks,


Mona

10-Marble
August 3, 2010

Mona,

You've got to get this bulletin board sorted, you are talking to Daryl by 'replying' to me. If you're getting it wrong what chance is for the rest of us?

Having all the contributions in sequence timewise would be good.

Bill