Avoiding automatic sorting of eigenvalues

44 ビュー (過去 30 日間)
Neelesh Kumar Vij
Neelesh Kumar Vij 2019 年 8 月 10 日
コメント済み: John D'Errico 2019 年 8 月 10 日
I have been trying to find and plot the eigenvalues of a matrix with the following code:
hbar = 6.58211*10^-4;
wph = linspace(0.5/hbar, 1.5/hbar,10000);
w1 = 2000/hbar;
w2 = 2001/hbar;
g = 0;
pump = 50;
clear eigen
for i=numel(wph):-1:1
h= [0 0 pump 0 0;
0 0 0 pump 0;
pump 0 0 0 0;
0 pump 0 0 g;
0 0 0 g w2-w1-wph(i)];
eigen(:,i)=eig(h)*hbar;
end
figure;
plot(wph*hbar, eigen(2,:), '-','Linewidth',2);
hold on;
plot(wph*hbar, eigen(1,:), '--','Linewidth',2);
plot(wph*hbar, eigen(3,:), ':','Linewidth',2);
plot(wph*hbar, eigen(5,:),'Linewidth',2);
plot(wph*hbar, eigen(4,:), '--','Linewidth',2);
xlabel('\omega_{ph}(meV)');
ylabel('Energy (meV)');
grid on;
Symbolically, the eigenvalues obtained are:
pump
pump
-pump
-pump
w2 - w1 - wph
As the value of the variable wph varies, the value of the last eigenvalue changes and it becomes the greatest valued to the least.
Using the above mentioned code, the plot obtained was:
The plot is wrong. The eigenvalues are sorted in between and thus the above result is obtained. Is there any way to stop this?

採用された回答

dpb
dpb 2019 年 8 月 10 日
編集済み: dpb 2019 年 8 月 10 日
EIG() does NOT return sorted values; it returns them to the user in the order in which the underlying LAPACK routine calculates them. That they often happen to appear to have been numerically sorted is simply a result of that routine applied to the input array.
In general, there is no such thing as "sorted" or "unsorted" order of the eigenvalues that eig() can know of -- they are merely the set of polynomial roots in the complex plane.
That there is a physical problem associated with the particular array is unknown to eig() and that there is a sequence to come even further from its knowledge base. However, there is a File Exchange submission that may help resolve the problem you're trying to solve -- it isn't unique but there isn't necessarily a hard and fast manner in which it can be solved.
Try John d'Errico's eigenshuffle()
  3 件のコメント
dpb
dpb 2019 年 8 月 10 日
I recalled (vaguely) some of conversation a couple years ago that led to your developing eigenshuffle so that was aware of it already. I looked at some of the OPs results; he gets a symmetric reversal of eigenvalue magnitudes. I looked at just 10 steps instead of 1000 and he'll have to recast to use the array outputs to use eigenshuffle() instead of just saving the vector of eigenvalues presently done.
John D'Errico
John D'Errico 2019 年 8 月 10 日
Yes. If all you save is the vector of eigenvalues, this is not sufficient. You cannot untangle them without also knowing the eigenvectors.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by