Complex Orders

Roger Germundsson, Wolfram Research, 1/15/2003

Orders

Some orderings of complex numbers used in Mathematica ...

EigenSort[ l_ ]  :=  
        Eigenvalues[ DiagonalMatrix[ l ] ];

Also all examples will be generated through the ordering used by Root, so that is the default ordering.

l  =  
      Table[ N[ Root[ #^5 + 11 #  +  3 &,  i]],  {i, 5}]

Sort[ l ]

EigenSort[ l ]

Visualization

This will allow us to visualize the order through arrows ..

<< Graphics`Arrow`

OrderPlot[ 
        l_ ]  :=  
Module[ {i = 
            1}, 
Show @ 
          Graphics[
{
Apply[
                Arrow[{Re[#1],  Im[#1]},  {Re[#2],  Im[#2]}] &, 
                Partition[ l,  2,  
                  1 ],  {1} ],  
PointSize[ 
                0.02],  
Map[ 
                If[ Im[ #]  == 
                      0,  
{RGBColor[1, 0, 0], 
                      Point[ {Re[#],  Im[#]} ],  
                      Text[i++, {Re[#],  
                          Im[#]},  {-1, -1}]},  {Point[ {Re[#],  
                          Im[#]} ], 
                      Text[i++, {Re[#],  
                          Im[#]},  {-1, -1}]}] &,  
                l ],  
Map[ 
                Circle[ {0, 0},  Abs[#] ] &,  
                l ]
}, 
Frame  ->  True,  
AspectRatio  ->  
              Automatic
]
]

Examples

Example 1

This is more or less a random example ...

l  =  
      Table[ N[ Root[ #^5 + 11 #  +  3 &,  i]],  {i, 5}]

Root sorts, real first, then complex conjugate pairs lexicographically.

OrderPlot[ l]

Sort appears to do purely lexicographically.

OrderPlot[ Sort[ l ] ]

Eigenvalues appear to order by magnitude and then break ties in inverse lexicographic order.

OrderPlot[ EigenSort[ l ] ]

Example 2

Another example ..

l  =  
      Table[ N[ Root[ #^5 + #^4 + #^3 + #^2 + #  -  1 &,  i]],  {i, 
          5}]

OrderPlot[ l ]

OrderPlot[ Sort[ l ] ]

OrderPlot[ EigenSort[ l ] ]

Example 3

This shows that all ordering attempts to group conjugate pairs next to each other.

Times @@  (x - { -(Sqrt[2]) I,  (Sqrt[2]) I,  -(Sqrt[3]) I,  (Sqrt[3]) 
              I})

Expand[ % ]

l  =  
      Table[ N@ Root[Function[x, 6 + 5 (x^2) + (x^4)],  i],  {i,  1,  
          4}]

OrderPlot[ l ]

OrderPlot[ Sort[ l ] ]

OrderPlot[ EigenSort[ l ] ]