How to make the positions of eigenvalues consistently in Mathematica

  • Topic: Mathematica 
  • Thread starter Thread starter kaizen.moto
  • Start date Start date
  • Tags Tags
    Eigenvalues Mathematica
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
5 replies · 4K views
kaizen.moto
Messages
94
Reaction score
0
Hi there,

Iam just wondering that at different values of m and n, the position of eigenvalues are always varies accordingly. I mean, the outputs positions of eigenvalues are not consistent given by mathematica.

Please see attached file for reference.

My question is that how to fix this problem so that the values of lamda1 = -lamda2, lamda3 = -lamda4 and lamda5 = -lamda6 on no matter the values of m and n are.

For instance, Iam looking for a method so that at any values of m and n, values of lamda's are always as follows:
lamda1 = -a;
lamda2 = a;
lamda3 = -b;
lamda4 = b;
lamda5 = -c;
lamda6 = c;

Thanks in advance for any response.
 
Attachments
Physics news on Phys.org
A quick fix might be replacing your

Code:
lamda[m_, n_] := Eigenvalues[D0[m, n]]

with

Code:
lamda[m_, n_] := SortBy[Eigenvalues[D0[m, n]], 
                            {Abs[# /. a -> 1.] &, Sign[# /. a -> 1.] &}]

which sorts the eigenvalues according to their absolute value and sign at the point a=1.
 
I just found out that the code does not work for lamda[7,3], lamda[59,79] etc.

The sign conventions are not consistent. Iam looking for a method in such a way that lamda1 = -a;
lamda2 = a;
lamda3 = -b;
lamda4 = b;
lamda5 = -c;
lamda6 = c;

where a, b and c can be complex numbers or real or combination of both.

Please help me to solve this matter.

many thanks for any feedback.
 
You matrix is real, so the eigenvalues will come in complex conjugate pairs.
Breaking up the c.c. pairs like you want to do, is a little unusual.
If you wanted to sort by Abs[] then Arg[] then you'd get things in complex conjugate pairs. If you want in +- pairs, then you need to flip the quadrants around a little:

Code:
lambda[m_, n_] := 
 SortBy[Eigenvalues[D0[m, n]], {Abs[# /. a -> 1.] &, 
   If[0 < # < Pi, Mod[# + Pi/2, Pi], #] &@
       If[Pi/2 < # < Pi/2, -#, #] &@Arg[# /. a -> 1.] &}]

The above will return things sorted by absolute value. Then terms in the -Pi to -Pi/2 quadrant followed by its negative term. Then things in the Pi/2 to Pi quadrant followed by its negative.

The fact things always occur in +- pairs in your system, probably means that there's some symmetry/structure you should be exploiting. If you find it, then you can just calculate half the number of eigenvalues then add in their negatives...

The other way to maybe sort you list is just by the Real part. Then it will be
{-a,-b,-c,c,b,a} and you can fold it back in on itself:

Code:
lambda[m_, n_] := 
 SortBy[Eigenvalues[D0[m, n]], {Re[# /. a -> 1.] &, 
    Im[# /. a -> 1.] &}][[{1, 6, 2, 5, 3, 4}]]

it's not the same order as above, but it does fit your criteria.
 
you are genius... The last code that Iam looking for and it really works.

thanks a lot and I really appreciate it. Have a nice day..