<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, Eigenvectors - What is the Ordering</title>
    <link>http://www.mapleprimes.com/posts/41915-Eigenvectors--What-Is-The-Ordering</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Thu, 11 Jun 2026 07:32:32 GMT</lastBuildDate>
    <pubDate>Thu, 11 Jun 2026 07:32:32 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, Eigenvectors - What is the Ordering</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, Eigenvectors - What is the Ordering</title>
      <link>http://www.mapleprimes.com/posts/41915-Eigenvectors--What-Is-The-Ordering</link>
    </image>
    <item>
      <title>Depends on the algorithm that is used</title>
      <link>http://www.mapleprimes.com/posts/41915-Eigenvectors--What-Is-The-Ordering?ref=Feed:MaplePrimes:Eigenvectors - What is the Ordering:Comments#comment78320</link>
      <itunes:summary>Maple has different algorithms for computing eigenvalues, and each gives a definite ordering to the eigenvalues/eigenvectors it produces [but the ordering is not the same amongst all the algorithms, as that could impede their efficiency!].  In particular, if you tell Maple that your matrix has a particular structure, special algorithms will be used which have very predictable behaviour on the order of their output.  In the most general cases, a little bit of numerical noise can cause ordering differences.

In other words, without seeing fairly exact details of your matrices, it will be hard to tell you exactly what the ordering guarantees will/will not be.</itunes:summary>
      <description>The latest comments added to the Post, Eigenvectors - What is the Ordering</description>
      <guid>78320</guid>
      <pubDate>Fri, 02 Feb 2007 21:37:38 Z</pubDate>
      <itunes:author>JacquesC</itunes:author>
      <author>JacquesC</author>
    </item>
    <item>
      <title>Eigenvector schemes</title>
      <link>http://www.mapleprimes.com/posts/41915-Eigenvectors--What-Is-The-Ordering?ref=Feed:MaplePrimes:Eigenvectors - What is the Ordering:Comments#comment78319</link>
      <itunes:summary>You mentioned Matrices with complex floats. I gather that you're interested in Matrices with floating-point entries (and all numeric).

If you set  infolevel[LinearAlgebra]:=1  then you should see displayed some mention of the external routine that gets used. Here's part of the breakdown in Maple 10, where by "hermitian" below I mean that the Matrix was created with shape=hermitian,

float[8], symmetric   : CLAPACK dspevd
float[8], no shape    : CLAPACK dgeevx
complex[8], hermitian : CLAPACK zhpevd
complex[8], no shape  : CLAPACK zgeevx

You may have noticed that zhpevd orders the (necessarily) real eigenvalues. Yet zgeevx does not.

Here is some code which (I believe) will order the eigenvalues and eigenvectors by descending value of the argument of the eigenvalues.

with(LinearAlgebra):

A := RandomMatrix(50,outputoptions=[datatype=float[8]]):
B := RandomMatrix(50,outputoptions=[datatype=float[8]]):
C := A+B*I:

evls,evcs := Eigenvectors(C):

temp := Vector(Dimension(evls),(i)-&gt;[evls[i],i]):
temp := sort(temp,(a,b)-&gt;argument(a[1])&gt;=argument(b[1])):
new_evls := Vector(Dimension(evls),(i)-&gt;temp[i][1],datatype=complex(float)):
new_evcs := Matrix(Dimension(evls),(i,j)-&gt;evcs[i,temp[j][2]],datatype=complex(float)):

Norm( C.new_evcs - new_evcs.DiagonalMatrix(new_evls) );
seq(argument(new_evls[i]),i=1..Dimension(evls));

You could modify the sort() call above, to order them in some other way. Note that it does not further order eigenvalues which might happen to have the same argument.

The code could be simpler, were it to only order the eigenvalues. The purpose of the temp Vector is to store the ordering index information for use in ordering the eigenvectors. There are doubtless more efficient ways to go about it, but that might appear more complicated.

Dave Linder
Mathematical Software, Maplesoft
</itunes:summary>
      <description>The latest comments added to the Post, Eigenvectors - What is the Ordering</description>
      <guid>78319</guid>
      <pubDate>Sat, 03 Feb 2007 00:45:20 Z</pubDate>
      <itunes:author>Dave L</itunes:author>
      <author>Dave L</author>
    </item>
    <item>
      <title>Eigenvector ordering: 2x2 Hermitian matrices</title>
      <link>http://www.mapleprimes.com/posts/41915-Eigenvectors--What-Is-The-Ordering?ref=Feed:MaplePrimes:Eigenvectors - What is the Ordering:Comments#comment81728</link>
      <itunes:summary>I ran into the ordering problem when using Eigenvectors procedure to diagonalise a 2x2 Hermitian matrix J(t) parameterised by time t.  At a certain time J(t) was such that the labelling/ordering of the eigenvectors and eigenvalues would swap, so introducing discontinuity in themasa function of time. 

I wrote the following procedure to get around the problem, using the same inputs and outputs as for Eigenvectors. While it has worked well for me, no guarantees are given as to its correctness. 

&gt;EigenHerm2b2:=proc(Mi::Matrix)
description "Determine the eigenvectors and eigenvalues of the 2 x 2 Hermitian matrix Input: Mi - Hermitian matrix; Output:(eigenvalues [column], eigenvectors [col1, col2])";
&gt; local mtol,a,b,c,d,V1k,V2k,V,sroot,v,k,vnorm;
&gt; mtol:=1.0e-9;
&gt; if( not (is( is(Im(Mi[1,1]+Mi[2,2])&lt; mtol) and is(abs(Mi[1,2]-Mi[2,1]^*) &lt; mtol) ) ) ) then
&gt; print(`Matrix not Hermitian in EigenHerm2b2 =&gt;`);print(Mi);return;
&gt; end if;
&gt; a:=(Mi[1,1]+Mi[2,2])/2;b:=(Mi[1,2]+Mi[2,1])/2;c:=(Mi[2,1]-Mi[1,2])/2/I;d:=(Mi[1,1]-Mi[2,2])/2;
&gt; sroot:=sqrt(b^2+c^2+d^2);
&gt; v[1]:=a+sroot;v[2]:=a-sroot;
&gt; for k from 1 by 1 to 2 do
&gt;    V1k:=(v[k]-(a-d))/(b+I*c);
&gt;    vnorm:=1/sqrt(1+(abs(V1k))^2);
&gt;    V[k]:=[V1k*vnorm, vnorm];
&gt; end do;
&gt; (Vector(2,[v[1],v[2]]),(Matrix(2, 2,[V[1],V[2]]))^+);
&gt; end proc:

MRB
  </itunes:summary>
      <description>The latest comments added to the Post, Eigenvectors - What is the Ordering</description>
      <guid>81728</guid>
      <pubDate>Thu, 18 Mar 2010 02:41:46 Z</pubDate>
      <itunes:author>MelvinBrown</itunes:author>
      <author>MelvinBrown</author>
    </item>
    <item>
      <title>Eigenvector ordering</title>
      <link>http://www.mapleprimes.com/posts/41915-Eigenvectors--What-Is-The-Ordering?ref=Feed:MaplePrimes:Eigenvectors - What is the Ordering:Comments#comment94382</link>
      <itunes:summary>&lt;p&gt;For a square Matrix with float or complex float entries and shape=hermitian, it seems to me that the eigenvalues are always in increasing order.&amp;nbsp; You do need to make the shape hermitian (or symmetric in the real case), not just have the entries satisfying M[i,j] = conjugate(M[j,i]), so that Maple knows it should use an algorithm for hermitian matrices.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Eigenvectors - What is the Ordering</description>
      <guid>94382</guid>
      <pubDate>Thu, 18 Mar 2010 03:58:18 Z</pubDate>
      <itunes:author>Robert Israel</itunes:author>
      <author>Robert Israel</author>
    </item>
    <item>
      <title>right</title>
      <link>http://www.mapleprimes.com/posts/41915-Eigenvectors--What-Is-The-Ordering?ref=Feed:MaplePrimes:Eigenvectors - What is the Ordering:Comments#comment94383</link>
      <itunes:summary>&lt;p&gt;It is mostly explained &lt;a href="http://www.mapleprimes.com/forum/eigenvectors-what-is-the-ordering#comment-5117"&gt;above&lt;/a&gt;. If the Matrix has the &lt;b&gt;symmetric&lt;/b&gt; or &lt;b&gt;hermitian&lt;/b&gt; indexing function, and if the data is all of type &lt;b&gt;complex(numeric)&lt;/b&gt; with some float present (or &lt;b&gt;complex[8&lt;/b&gt;] or&lt;b&gt; float[8]&lt;/b&gt; datatype, etc), then the underlying method used by the &lt;b&gt;Eigenvectors&lt;/b&gt; command will sort the eigenvalues in the returned Vector.&lt;/p&gt;
&lt;p&gt;And the eigenvectors are columns in the returned Matrix which correspond to entries in that returned Vector of sorted eigenvalues, so the columns are thus sorted for these cases.&lt;/p&gt;
&lt;p&gt;This is all due to which external clapack routine is used.&lt;/p&gt;
&lt;p&gt;The key thing is that the Eigenvectors and Eigenvalues commands do not try to automatically detect symmetry -- the &lt;b&gt;symmetric &lt;/b&gt;of &lt;b&gt;hermitian &lt;/b&gt;indexing function must be specificed in the data Matrix.&lt;/p&gt;
&lt;p&gt;I think that that is ok behaviour, because with the lack of a &lt;i&gt;nonsymmetric &lt;/i&gt;indexing function there would otherwise be no way to force use of the nonsymmetric method in the case that float data only appeared close to hermitian. An automatic test would likely involve a tolerance in the float case.&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Eigenvectors - What is the Ordering</description>
      <guid>94383</guid>
      <pubDate>Thu, 18 Mar 2010 16:15:03 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>Hermitian 2x2</title>
      <link>http://www.mapleprimes.com/posts/41915-Eigenvectors--What-Is-The-Ordering?ref=Feed:MaplePrimes:Eigenvectors - What is the Ordering:Comments#comment94384</link>
      <itunes:summary>&lt;p&gt;Thanks, both.&amp;nbsp; I have added the shape=hermitian parameter in defining the matrix. &lt;/p&gt;
&lt;p&gt;Just to illustrate what seemed to be the consequences: &lt;/p&gt;
&lt;p&gt;One may, under certain conditions, see sudden polarity changes in the difference between eigenvalues.&amp;nbsp; The following code exemplifies the effect, which is not seen in EigenHerm2b2, but is observed in Eigenvectors. (This is an extreme case; in my application, in quantum mechanics, the polarity switches were far less frequent.) This was the motivation for writing EigenHerm2b2 for my application. I wish to track the dependence of the sum and difference of the eigenvalues against t, and although eigenvalues/vectors may change smoothly with t, were their ordering to swap over, while my addresses for them were fixed, might then the sum be unaffected and the difference change sign?! Still, I do have a work around for the 2x2 case. &lt;br /&gt;
&lt;br /&gt;
&amp;gt;K:=(t)-&amp;gt;evalf(Matrix(2,2,[[(cos(t)),sin(t/2)*(1-I)],[sin(t/2)*(1+I),(cos(t))]],shape=hermitian));Kperiod:=12:&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;gt;plot([(''EigenHerm2b2(K(tt))[1][1]''+''EigenHerm2b2(K(tt))[1][2]''),(''EigenHerm2b2(K(tt))[1][1]''-''EigenHerm2b2(K(tt))[1][2]''),Determinant(K(tt))], tt=0..Kperiod,legend=[&amp;quot;sum&amp;quot;,&amp;quot;difference&amp;quot;,&amp;quot;determinant&amp;quot;],numpoints=100,title=&amp;quot;sum and difference of eigenvalues (using EigenHerm2b2)&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;gt;plot([(''Eigenvectors(K(tt))[1][1]''+''Eigenvectors(K(tt))[1][2]''),(''Eigenvectors(K(tt))[1][1]''-''Eigenvectors(K(tt))[1][2]''),Determinant(K(tt))], tt=0..Kperiod,legend=[&amp;quot;sum&amp;quot;,&amp;quot;difference&amp;quot;,&amp;quot;determinant&amp;quot;],numpoints=100,title=&amp;quot;sum and difference of eigenvalues (using Eigenvectors)&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
MRB&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, Eigenvectors - What is the Ordering</description>
      <guid>94384</guid>
      <pubDate>Thu, 18 Mar 2010 22:14:02 Z</pubDate>
      <itunes:author>MelvinBrown</itunes:author>
      <author>MelvinBrown</author>
    </item>
  </channel>
</rss>