MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE[2]: ugly Plot Eigenvalues ?

  • To: mathgroup at
  • Subject: [mg39731] RE[2]: [mg39670] ugly Plot Eigenvalues ?
  • From: "Wolf, Hartmut" <Hartmut.Wolf at>
  • Date: Mon, 3 Mar 2003 23:50:52 -0500 (EST)
  • Sender: owner-wri-mathgroup at

>-----Original Message-----
>From: Wolf, Hartmut 
To: mathgroup at
>Sent: Monday, March 03, 2003 10:03 AM
>To: 'Pavel Pokorny'; mathgroup at
>Subject: [mg39731] RE: [mg39670] ugly Plot Eigenvalues ?
>>-----Original Message-----
>>From: Pavel Pokorny [mailto:Pavel.Pokorny at]
To: mathgroup at
>>Sent: Friday, February 28, 2003 10:46 AM
>>To: mathgroup at
>>Subject: [mg39731] [mg39670] ugly Plot Eigenvalues ?
>>    Dear Mathematica friends,
>>How can I plot Re Eigenvalues as a function of a parameter
>>without unwanted ugly connections between branches?
>>In the example (computed by Mathematica 4.2 for HP-UX PA-RISC)
>>   m1={{8., 8, 7}, {0, 5, 5}, {8, 0, 0}}
>>   m2={{6., 0, 6}, {10, 8, 3}, {5, 8, 6}}
>>   Plot[Evaluate[Re[Eigenvalues[m1+w*m2]]], {w,-3,3}];
>>for w approximately -0.4 there is an unwanted vertical bar.
>>This is related to "ordering" of solutions to equation.
>>Is there a simple nice solution for this and related examples?
>>(taking exact numbers in the example above avoids the unwanted 
>>but this is not a good solution for a general machine 
>>precission problem)
>>Pavel Pokorny
>>Math Dept, Prague Institute of Chemical Technology
>A suggestion:
>ev = Re[Eigenvalues[m1 + w*m2]];
>evs := Sort[ev]
>Plot[{evs[[1]], evs[[2]], evs[[3]]}, {w, -3, 3}]
>Of course a problem of reference still remains.
>Hartmut Wolf

As I said, a problem of reference. The idea is to seperate out regions of w
were the eigenvalues (here their real parts) are smooth functions of w, and
then combine to globally smooth solutions. In this case the ordering of the
real part itself cannot be used, since we have a degenerate case for most w
for that, and numerical instabilities creap in. But the the imaginary part
does better:

Clear[ev, evs]

ev = Eigenvalues[m1 + w*m2];   (* this is better usable *)

Block[{f = Composition[Ordering, Chop, Im]}, 
  Plot[{f[ev][[1]], f[ev][[2]], f[ev][[3]]}, {w, -3, 3}, 
    PlotStyle -> {Hue[0], Hue[1/3], Hue[2/3]}]]

with that, we find

Block[{f = Composition[Ordering, Chop, Im], g = Re}, 
  Plot[{g[ev[[Min[f[ev][[1]] + f[ev][[2]], 4] - 1]]], 
      g[ev[[Min[f[ev][[1]], f[ev][[2]]]]]], g[ev[[f[ev][[3]]]]]}, {w, -3,
    PlotStyle -> {Hue[0], Hue[1/3], Hue[2/3]}, AspectRatio -> 1]]

giving a smooth numbering (or coloring) of the eigenvalues.

This of course is pure (or poor) handwork; a challenge would be to
automatically find the continuous paths when crossing the branch cuts of the
functions involved as w varies.

Hartmut Wolf

  • Prev by Date: RE: Help Providing a Module
  • Next by Date: Re: How to evaluate a NIntegrate expression properly
  • Previous by thread: RE: ugly Plot Eigenvalues ?
  • Next by thread: Re: visualizing Map, Thread, Apply, etc.