Mathematica How to make the positions of eigenvalues consistently in Mathematica

AI Thread Summary
The discussion revolves around the inconsistency in the positioning of eigenvalues generated by Mathematica for varying values of m and n. The user seeks a method to ensure that the eigenvalues follow a specific pattern: λ1 = -a, λ2 = a, λ3 = -b, λ4 = b, λ5 = -c, and λ6 = c, regardless of m and n. A proposed solution involves modifying the eigenvalue function to sort the eigenvalues by their absolute values and signs. However, the initial fix did not work for certain values, leading to further suggestions for sorting based on both absolute value and argument to maintain the desired pairing of eigenvalues. The conversation highlights the importance of exploiting symmetry in the matrix system to simplify eigenvalue calculations, with additional sorting methods provided to achieve the required format. The user expresses gratitude for the effective solutions offered.
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.
 
Thank you.
 
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..
 

Similar threads

Replies
6
Views
4K
Replies
1
Views
2K
Replies
2
Views
3K
Replies
2
Views
2K
Replies
1
Views
3K
Replies
2
Views
2K
Replies
52
Views
12K
Back
Top