Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
I am still using MC v.11.x.
From a matrix I needed to extract the eigenvalues and eigenvectors, and re-order them (starting from the eigenvalues) in a decreasing manner. Accordingly I needed to change column order to the eigenvectors, so they correspond to the new order of the eigenvalues. I used the function eigenvec(M,z) for this. Yet without success.
The Figure I hope explains the problem, in its essence (there is no re-ordering here). It shows that the connected eigenvector to its eigenvalue (captured with "eigenvec" function), is not the same of the one that appears in the function "eigenvecs(M)".
I understand (or to say better, I realized, see the Figure) that the same eigenvalue may have multiple eigenvectors. But now:
1. How can I extract the same eigenvector that appers in the "eigenvecs" function, by recalling its own eigenvalue?
2. And more in general, is there a way to see the multiplicity of eigenvectors connected to a given eigenvalue?
Thanks.
From the Mathcad 11 help: "eigenvecs(M) Returns a matrix containing the normalized eigenvectors corresponding to the eigenvalues of the matrix M. The nth column of the matrix returned is an eigenvector corresponding to the nth eigenvalue returned by eigenvals.".
So just use the eigenvals and eigenvecs functions, and you have what you want (or am I missing something?)
1. You can't. There (probably) is a difference in implementation to determine the eigenvectors between 'eigenvecs' and 'eigenvec'. See this old post:
In your example the eigenvectors found with either function for the first two eigenvalues ar all normalized (|V|=1). Their ratio is a (complex!) number with a magnitude of 1.
2. What do you mean with multiplicity? One eigenvalue (v) of a matrix A is associated with an unlimited number of eigenvectors (V):
A*V=v*V.
You can multiply V with any number k to get A*(k*V)=v*(k*V).
I assume you meant to reply to Anthony.
Anyway,
One eigenvalue (v) of a matrix A is associated with an unlimited number of eigenvectors (V):
A*V=v*V.
You can multiply V with any number k to get A*(k*V)=v*(k*V).
But then you do not have the same eigenvalue. You have a new eigenvalue, v*k, and a new eigenvector V*k. So there are an unlimited number of pairs of eigenvalues and eigenvectors that differ only by a scaling factor (which is why it makes sense to normalize the eigenvector), but that's not the same as having an unlimited number of eigenvectors for one eigenvalue.
Thanks Richard and LucMeekes.
a) For multiplicity I do not mean that the same eigenvector can be scaled up and down. But that the same eigenvalue can be connected to two or more completely different eigenvectors. The most trivial case is the identity matrix 2x2: eigenvalue 1 with two eigenvectors which are the two columns of the matrix itself.
b) Richard: I also read the help file, but as I said I re-ordered the eigenvalues, from maximum to minimum. So for instance in the example given the third eigenvalue (the max) has become the first eigenvalue, etc. My aim was (is) to re-order accordingly the eigenvectors. I thought to use the eigenvec function for this, but I found the unexpected results of this post.
c) I am not familiar with complex numbers but the two eigenvectors used in the blue and green part of the Figure appear to me different in their structure. So much so, that one eigenvector contains an element that is only real, while the other shows all three elements with an imaginary part. Given that, I assumed that the two eigenvectors were different in their structure, and not just for a scaling factor. Am I wrong?
b). So there are two possible solutions. One is to get both the eigenvalues and eigenvectors, and then when you reorder the eigenvalues, reorder the eigenvectors at the same time so that they still match (edit: by this I mean you should reorder by keeping track of the row/column indexing). The other is to get the eigenvalues only, reorder them, and then get the eigenvectors using the eigenvec function, and not worry about the fact that they are different to the ones from the eigenvecs function. They are still valid eigenvectors (as you have shown).
c) They are indeed different, and you are correct that there can be more than one eigenvector for a given eigenvalue. But I think there are only an infinite number of eigenvectors for a given eigenvalue in the case of the identity matrix.
Thanks Richard again.
Richard Jackson ha scritto:
b). So there are two possible solutions. One is to get both the eigenvalues and eigenvectors, and then when you reorder the eigenvalues, reorder the eigenvectors at the same time ......
The only problem in this first "solution" is that I ordered the eigenvalues with csort(EVal,0) and then inverted the order upside down. The function worked well also with complex eigenvalues (the signs ≤ or ≥ do not work with complex numbers when the real part is the same). So I need now to find another way to record how the columns of the eigenvalues did change, after sorting them. I do not know why, but I trust more the eigenvecs function: it seems in fact to me correct that also a row (besides to one column) in the Eigenvector matrix should be made up of real positive values (from Perron Fobrenius theorems of positive matrix I guess). This does not occur with the eigenvec function. In any case I need to think a way to record the new order or to use a different function instead of csort. Any help or suggestion here will be appreciated.
c) They are indeed different, and you are correct that there can be more than one eigenvector for a given eigenvalue. But I think there are only an infinite number of eigenvectors for a given eigenvalue in the case of the identity matrix.
True. But all the other eigenvectors are not linearly independent (remaining with a 2x2 matrix) from the two I mentioned in the previous reply: and this is by definition since they are the standard bases!
Probably a good answer to my problem and doubts comes from an old post by @TomGutman:
Eigenvectors, Eigenvals, Matrix
I quote the relevant passages in italics, with in bold something I mentioned above or that seems helpful for my task:
There is a function (eigenvec) that takes a matrix and an eigenvalue and returns an eigenvector associated with that eigenvalue. But unless the eigenvalues are well separated it is not reliable, and cannot return more than one eigenvector for an eigenvalue that is repeated.
Eigenvals and eigenvecs are defined to return the eigenvalues and eigenvectors in the same order (this may not work with the symbolic processor, which tends to have its own ideas of how to do things). If you want to sort the eigenvalues you should stack them onto the eigenvector matrix and then sort the matrix on the resulting eigenvalues row. That keeps them together.
Therefore the solution could be the following:
1. use eigenvecs and eigenvals
2. stack the Transpose eigenvalue vector onto the eigenvector matrix
3. use now csort rsort in the augmented matrix of point 2. (in the example above would be a 4x3 matrix), taken the column last row of eigenvalues as reference
4. in my case I need from high to low values, so revert the order: I use a diagonal matrix
5.extract the new ordered eivenvectors (and eigenvalues) with submatrix
Still somewhat puzzled by the eigenvec function: the eigenvector result, that it gives in the example, should be a linear combination of the ones given by eigenvecs function. But that it is a bit confusing since one expects linear independent eigenvectors.
That works . The only thing I can suggest changing is to transpose Q_Evec and augment it with EVal. Then use csort, followed by the reverse function to reverse the rows. I think it's a little neater to use the reverse function rather than multiplying by the diagonal matrix.
Still somewhat puzzled by the eigenvec function: the eigenvector result, that it gives in the example, should be a linear combination of the ones given by eigenvecs function. But that it is a bit confusing since one expects linear independent eigenvectors.
I'm not sure what you mean. Given three linearly independent vectors, I can generate an infinite number of other sets of equivalent linearly independent vectors by creating linear combinations of the ones I have.
Many thanks Richard for your suggestions. That makes a cleaner result.
As far as eigenvec function, yes it is possible to offer other sets of independent eigenvectors, but as things stand - and as I understood it - they cannot be mixed up with the set that comes from eigenvecs function. IMHO this is somewhat confusing.
As far as eigenvec function, yes it is possible to offer other sets of independent eigenvectors, but as things stand - and as I understood it - they cannot be mixed up with the set that comes from eigenvecs function.
That's true, they can't. And I agree that the function usage is somewhat confusing, and it's not well explained in the help.
You're right, I meant to reply to Anthony.
On your other point I'm afraid I have to disagree:
You don't get a new eigenvalue/eigenvector pair of matrix A by multiplying the eigenvalue with k.
If that were true, and v'=k*v would give you a new eigenvector V'=k*V, then, using the definition of eigenvalues/vectors:
A*V'=v'*V' => A*k*V=k*v*k*V => k=k^2, which is only true for k=0 or k=1.