Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
f[k_] = {{-0.001 - 2 I k, 1, -0.001, -0.501}, {0.001, -0.5 - I k, 0.001, 0.001},
     {-0.001, -0.501, -0.001 + 2 I k, 1.}, {0.001, 0.001, 0.001, -0.5 + I k}};

y[k_] = Im[Eigenvalues[f[k]][[3]]];
Plot[y[k], {k, -1, 1}]

3rd and 4th eigenvalues are complex conjugates, as we can see from the graph the program mixed them, there are lots of jump discontinuities from the one with negative imaginary part to the one with positive. I suspect that the program sometimes takes as the 3rd eigenvalue (or root) the one with positive "Im" and sometime the one with negative "Im".

Please help me to resolve this problem by a general approach (of course for this case one can take the Max of two as k>0 and Min otherwise to obtain the imaginary part of the desired eigenvalue).

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I'm not sure exactly which eigenvalues you wish to display, but you can sort them in order to choose. For instance, to plot the largest eigenvalue, you can

f[k_] := {{-0.001 - 2 I k, 1, -0.001, -0.501}, {0.001, -0.5 - I k, 
    0.001, 0.001}, {-0.001, -0.501, -0.001 + 2 I k, 1.}, {0.001, 
    0.001, 0.001, -0.5 + I k}};

y[k_] := Sort[Im[Eigenvalues[f[k]]]][[3]];
Plot[y[k], {k, -1, 1}]

which gives

enter image description here

Sort also takes an optional second argument which can be used to pick out which of the eigenvalues you want plotted.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.