# ordering of functional eigenvalues

Is there any order to the symbolic eigenvalues of a matrix returned by the command Eigenvalues[...]?

While numerical eigenvalues are listed in descending order (i.e., $\lambda_1 \ge \lambda_2 \ge \cdots \ge \lambda_N$), this is not the case for functional eigenvalues (see two examples below). The examples suggest that the ordering may be the reverse, although this cannot be positively inferred from two examples. Do functional eigenvalues have the order $\lambda_1 \le \lambda_2 \le \cdots \lambda_N$, another ordering (based on eigenvectors, for instance), or no ordering at all?

Examples showing that functional eigenvalues are not sorted in descending order.

(1) As a trivial example,

Eigenvalues[{{Exp[x], Exp[x]}, {Exp[x], Exp[x]}}]


returns $\left\{0,2 e^x\right\}$. For real inputs, the latter is always greater than or equal to the former.

(2) As another example, consider

Eigenvalues[{{Exp[x], Exp[x]}, {Exp[x], Exp[x/2]}}]


which returns

$$\left\{\frac{1}{2} \left(e^{x/2}+e^x-e^{x/2} \sqrt{1-2 e^{x/2}+5 e^x}\right),\frac{1}{2} \left(e^{x/2}+e^x+e^{x/2} \sqrt{1-2 e^{x/2}+5 e^x}\right)\right\}.$$

Again, for real inputs, the latter is always greater than or equal to the former:

Plot[%, {x, -10, 10}]


-
Is this a duplicate? mathematica.stackexchange.com/q/1831/121 –  Mr.Wizard Mar 20 '12 at 18:05
How can they have any order if they are still symbolical? –  Rojo Mar 20 '12 at 18:11
The eigenvalues are functions. But they could still have an order. For instance, $\log 3x \ge \log 2x \ge \log x$. –  user001 Mar 20 '12 at 18:18
But what if they were Sin[x] and Cos[x]? You'd have to use OrderedQ, like Sort does, which would sort them as {Cos[x], Sin[x]}. But then if you define x to be some number, the list will not be ordered for around half the possible values of x. –  acl Mar 20 '12 at 20:51
@acl: Right, in such a case, ordering by magnitude would not make any sense. But in cases like those posited above, there is clearly a function that is greater than or equal to the other. –  user001 Mar 20 '12 at 20:53

My strong hunch is that when the eigenvalues cannot be treated as numbers, the eigenvalues are always ordered according to "Sort". Thus, they are sorted in MMA's "canonical" order, some of which is described in this question: http://mathematica.stackexchange.com/a/2730/360.

In[48]:= Sort[{Log[x], Log[2 x], Log[3 x]}]

Out[48]= {Log[x], Log[2 x], Log[3 x]}

In[49]:= Sort@Eigenvalues[{{Exp[x], Exp[x]}, {Exp[x], Exp[x/2]}}] ==
Eigenvalues[{{Exp[x], Exp[x]}, {Exp[x], Exp[x/2]}}]

Out[49]= True


For mixed eigenvalues, the numeric ones are listed first:

In[63]:= m = ({{1000, 0, 1}, {1, Log[3 x], 0}, {0, 0, Log[2 x]}});
Eigenvalues[m]

Out[64]= {1000, Log[2 x], Log[3 x]}

-
That's what I thought too, but didn't answer because I couldn't convincingly explain why this list: {Log[x] - Exp[x], Log[99 x], Log[x]} is sorted as {Log[x], Log[x] - Exp[x], Log[99 x]} — i.e., why isn't Log[x] - Exp[x] the last? Looking at TreeForm, Length and LeafCount of the list above all remain unconvincing thus far (to me)... –  The Toad Mar 20 '12 at 19:26
Well, if it compares depth first, Log[x] only has x at the deepest level. Then it compares {e,x} and {99,x} and e<99 so it goes first. At least that would be my argument. But that is more of a post-hoc argument, since I thought that it compares at the same level. –  tkott Mar 20 '12 at 19:32
But that's not what the Sort documentation says... it says it sorts by length first and then, in case of a tie, it compares depth first. "Sort usually orders expressions by putting shorter ones first, and then comparing parts in a depth-first manner" –  The Toad Mar 20 '12 at 19:39
@R.M oops missed that caveat. I guess my only defense is the "usually" in there :) –  tkott Mar 20 '12 at 19:41
ha, that "usually" is a stinker — WRI's get-out-of-jail card ;) –  The Toad Mar 20 '12 at 19:46

From Documentation:

http://reference.wolfram.com/mathematica/ref/Eigenvalues.html

"If they are numeric, eigenvalues are sorted in order of decreasing absolute value."

Even when we have "exact" form (perhaps what you mean by symbolic) the are still sorted in decreasing order:

m = Partition[Sin[#] & /@ Range[9], 3]; m // MatrixForm


Eigenvalues[m] // FullSimplify // Column


In[1]:=N[%]

0.21897
Out[1]:= 0.0756954
0.


Your specific case is easy to check:

m = ({{Log[3 x], 0, 1},{1, Log[x], 0},{0, 0, Log[2 x]}}); m // MatrixForm


In[1]:= ev = Eigenvalues[m]

Out[1]= {Log[x], Log[2 x], Log[3 x]}


So, you see, - it does not hold. It sorts them differently.

-
How about for symbolic eigenvalues that are functions? –  user001 Mar 20 '12 at 18:19
@user001: Functions of what? And what do you mean when you ask in this case about sorting in descending order? –  murray Mar 20 '12 at 18:25
@murray: Suppose the eigenvalues were $\log x$, $\log 2x$, and $\log 3x$. I wish to know if the order returned by Mathematica would necessarily be $\log 3x$, $\log 2x$, $\log x$. –  user001 Mar 20 '12 at 18:27
@VitaliyKaurov: The example you provided is still numerical, even if it is in symbolic form. –  user001 Mar 20 '12 at 18:36
@user001: No, expressions such as Log[3x] are $not$ numeric, as you can directly check by using NumericQ. –  murray Mar 21 '12 at 20:07