Properties of Set and Eigenvalues

by
Rolf Sulanke

April 18, 2010

$LicenseID

The notebook is generated with Mathematica v.7.0 under SuSe Linux v. 11.1

Summary

We  define  functions of  Eigenvalues and Eigenvectors of  a specific matrix containing parameters k,h using Set and SetDelayed. 0ne has to consider the fact that the order in which the eigenvalues of a numerically given matrix appear depend on their  values.  If one desires that the order of the eigenvalues is fixed by the shape of the matrix depending  on parameters k, h,..., one should proceed as follows:
Evaluate Eigenvalues[matrix[k,h,...]] symbolically and define the function eval[k_,h_,...]  by Set  (=) (and not by  SetDelayed (:=)) to get  the set of eigenvalues in the specific order not depending on their values.  The notebook shows the difference of this definition with the analogous definition using SetDelayed (:=)) by an example.
I thank  Michael Trott for a deciding hint which cleared the situation.

EVALUATE THE NOTEBOOK!

The Example

We consider  the 5x5  matrix depending on the parameters k, h:

cc[k_, h_] := {{0, k, 1, 0, 0}, {1, 0, 0, 0, k}, 
   {0, 0, 0, -h, 1}, {0, 0, h, 0, 0}, {0, 1, 0, 0, 0}}

cc[k,h]//MatrixForm

Mathematica calculates the Eigenvalues symbolically; we use SetDelayed and Set to define the functions

Eigenvalues[cc[k,h]]

eigenval[k_,h_] := Eigenvalues[cc[k,h]]

eigenval[k,h]

eval[k_,h_] = Eigenvalues[cc[k,h]]

Numerically, the order of eval[k,h] differs from the order of eigenval[k,h];

k=RandomReal[10]; h = RandomReal[10];Print[Chop[eval[k,h]],Chop[eigenval[k,h]]];Clear[k,h]

The 5-th eigenvalue under symbolical evaluation is given by the function

ff5[k_,h_] = eval[k,h][[5]]

The real part of ff5[k,h]  is

Plot3D[Re[ff5[k,h]],{k,-10,10},{h,-10,10}]

The numerical evaluation yields  the zero function with numerical disturbances

Plot3D[Re[eigenval[k,h][[5]]],{k,-10,10},{h,-10,10}]

Plot3D[Chop[Re[eigenval[k,h][[5]]]],{k,-10,10},{h,-10,10}]

Indeed, we have

k=RandomReal[{-10,10}];h=RandomReal[{-10,10}];Print[{k,h}];
Print[Chop[eigenval[k,h][[5]]]]; Clear[k,h]

Now we consider the eigenvectors the same way:

ev[k_,h_] = Eigenvectors[cc[k,h]]

eigenvec[k_,h_] := Eigenvectors[cc[k,h]]

Symbolically, both definitions yield the same result:

Simplify[eigenvec[k,h]-ev[k,h]]

Numerically, this is not the case

k=RandomReal[10]; h = RandomReal[10];Print[Chop[ev[k,h]]-eigenvec[k,h]];Clear[k,h]

Symbolically, using eigenvec,  the eigenvector equation is fulfilled  for eigenval and for eval:

Simplify[cc[k,h].eigenvec[k,h][[5]]== eigenval[k,h][[5]]*eigenvec[k,h][[5]]]

Simplify[cc[k,h].eigenvec[k,h][[5]]==eval[k,h][[5]]*eigenvec[k,h][[5]]]

Numerically, using eigenvec,  the eigenvector equation is fulfilled  for eigenval and not for eval:

k=RandomReal[10]; h=RandomReal[10];Print[Simplify[Chop[cc[k,h].eigenvec[k,h][[5]]- eigenval[k,h][[5]]*eigenvec[k,h][[5]]]]];Clear[k,h]

k=RandomReal[10]; h=RandomReal[10];Print[Simplify[Chop[cc[k,h].eigenvec[k,h][[5]]- eval[k,h][[5]]*eigenvec[k,h][[5]]]]];Clear[k,h]

Symbolically, using ev,  the eigenvector equation is fulfilled  for eigenval and for eval:

Simplify[cc[k,h].ev[k,h][[5]]== eigenval[k,h][[5]]*ev[k,h][[5]]]

Simplify[cc[k,h].ev[k,h][[5]]==eval[k,h][[5]]*ev[k,h][[5]]]

Numerically, using ev,  the eigenvector equation is not fulfilled  for eigenval and fulfilled for eval:

k=RandomReal[10]; h=RandomReal[10];Print[Simplify[Chop[cc[k,h].ev[k,h][[5]]- eigenval[k,h][[5]]*ev[k,h][[5]]]]];Clear[k,h]

k=RandomReal[10]; h=RandomReal[10];Print[Simplify[Chop[cc[k,h].ev[k,h][[5]]- eval[k,h][[5]]*ev[k,h][[5]]]]];Clear[k,h]

Please, send  your comments to sulanke@mathematik.hu-berlin.de

For other Mathematica items click 
http://www2.mathematik.hu-berlin.de/~sulanke/sulanke-MuM.html