How to obtain eigenvalues as functions of a variable?

18 views (last 30 days)
I want to solve an eigenvalue problem as such:
In which the matrix B is constant, and the matrix A varies with the term u. My objective is to analyze the variation of each eigenvalue with u (for example):
u=0:100;
B=[1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16];
lambda=zeros(size(B,1),size(u,2));
for i=1:size(u,2)
A=[u(i)*5 7 u(i)*10 9;10 15 17 20;11 13 12 20;3 7 1 9];
lambda(:,i)=eig(A,B);
end
If I am not wrong, I believe that each time MATLAB solves the eigenvalue problem, the order in which it places each eigenvalue in the output column vector is completely random (please correct me if I am wrong). For me, this is a problem because I want to determine how each eigenvalue varies, so I would like the '"same" eigenvalue to be placed (or sorted) in the same position (row) every time. Because I am working with big matrices, with complex eigenvalues, in which the variations are very unpredictable, I have no criteria to use the function sort().
I have also tried to use symbolic computation, defining u as a symbolic variable, and trying to obtain each eigenvalue as symbolic expressions, functions of u (for example):
syms u
B=[1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16];
B=sym(B);
A=[u*5 7 u*10 9;10 15 17 20;11 13 12 20;3 7 1 9];
S=B\A;
lambda=eig(S);
But this solution proved to be unsustainable, due to my computer's poor memory (I don't know if there is any way to improve this approach).
Is there any way to keep track of each eigenvalue and know to which eigenvalue it "corresponds"? (sorry if I am not very clear)
  3 Comments
Pedro Camacho
Pedro Camacho on 31 Mar 2020
What I meant is that the order in which they appear in the output vector is not important, but it has to be consistent. So, there is no appearent reason to use sort().
Because each eigenvalue is a root of the characteristic polynomial, what is important is that all the eigenvalues in the same row corresponds to the "same" root. That is why I tried the symbolic approach.
David Goodmanson
David Goodmanson on 31 Mar 2020
Hi Ameer,
You can sort the eigenvalues with, say, sort(eigvalues,'abs') and get a dependable order. But if you want to follow the eigenvalues by continuity in the variable u, you might have to use small steps for u. That works, but it is of course a time comsuming process .

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 31 Mar 2020
Edited: the cyclist on 31 Mar 2020
Take a look at John D'Errico's eigenshuffle function in the File Exchange. I believe it does what you want (and there is some theoretical discussion there as well).

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!