How to make the positions of eigenvalues consistently in Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter kaizen.moto
  • Start date Start date
  • Tags Tags
    Eigenvalues Mathematica
Click For Summary

Discussion Overview

The discussion revolves around the issue of obtaining consistent positions for eigenvalues in Mathematica, particularly for varying parameters m and n. Participants explore methods to ensure that eigenvalues follow a specific pattern regardless of the input values.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant expresses concern that the positions of eigenvalues vary with different values of m and n, seeking a method to ensure specific relationships among the eigenvalues (e.g., λ1 = -λ2, λ3 = -λ4, etc.).
  • Another participant suggests a modification to the eigenvalue function to sort the eigenvalues by absolute value and sign, proposing a potential solution.
  • A later reply indicates that the initial code does not work for certain parameter values, highlighting inconsistencies in sign conventions and reiterating the desired eigenvalue relationships.
  • One participant notes that the matrix is real, leading to complex conjugate pairs of eigenvalues, and discusses sorting methods that could maintain the desired pairing of eigenvalues.
  • Another participant proposes a sorting method based on the real part of the eigenvalues, suggesting a different order that still meets the criteria outlined by the original poster.
  • The original poster expresses satisfaction with a final code solution provided by another participant, indicating that it works as intended.

Areas of Agreement / Disagreement

Participants do not reach a consensus on a single method for achieving the desired eigenvalue positions, as multiple approaches are proposed and discussed. There is acknowledgment of the complexity involved in sorting eigenvalues consistently.

Contextual Notes

Participants note that the eigenvalues come in complex conjugate pairs, and the discussion includes various assumptions about the nature of the eigenvalues (real, complex, or combinations). The proposed solutions involve different sorting strategies that may depend on the specific characteristics of the eigenvalues.

Who May Find This Useful

This discussion may be useful for Mathematica users dealing with eigenvalue problems, particularly those interested in ensuring specific relationships among eigenvalues in their computations.

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 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 52 ·
2
Replies
52
Views
13K