help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with consistency of root finding and sorting


From: Ben Abbott
Subject: Re: problem with consistency of root finding and sorting
Date: Wed, 10 Oct 2007 08:26:52 -0400


On Oct 10, 2007, at 7:55 AM, David Bateman wrote:

Ben Abbott wrote:

On Oct 10, 2007, at 3:45 AM, David Bateman wrote:

Ben Abbott wrote:

Thanks David,

another attempt, if you don't mind

p = roots([1 0 18 0 81])
p =

  -0.0000 + 3.0000i
  -0.0000 - 3.0000i
   0.0000 + 3.0000i
   0.0000 - 3.0000i

octave:1> p = roots([1 0 18 0 81])
p =

   0.0000 + 3.0000i
   0.0000 - 3.0000i
  -0.0000 + 3.0000i
  -0.0000 - 3.0000i

[e, indx] = mpoles (p)
e =

   1
   2
   1
   2

indx =

   1
   3
   2
   4

octave:2> [e, indx] = mpoles (p)
e =

   1
   2
   1
   2

indx =

   2
   4
   1
   3


p(indx)
ans =

  -0.0000 + 3.0000i
   0.0000 + 3.0000i
  -0.0000 - 3.0000i
   0.0000 - 3.0000i

octave:3> p(indx)
ans =

   0.0000 - 3.0000i
  -0.0000 - 3.0000i
   0.0000 + 3.0000i
  -0.0000 + 3.0000i


Thanks again. I believe I've found the bug ... and it is mine :-(

Using the attached mpoles.m, I get

p = roots([1 0 18 0 81])
p =

  -0.0000 + 3.0000i
  -0.0000 - 3.0000i
   0.0000 + 3.0000i
   0.0000 - 3.0000i

[e, indx] = mpoles(p)
e =

   1
   2
   1
   2

indx =

   1
   3
   2
   4

I assume you will get the same.



Ok with the attached mpoles at the latest CVS I get

octave:1> p = roots([1 0 18 0 81])
p =

   0.0000 + 3.0000i
   0.0000 - 3.0000i
  -0.0000 + 3.0000i
  -0.0000 - 3.0000i

octave:2> [e, indx] = mpoles(p)
e =

   1
   2
   1
   2

indx =

   3
   1
   4
   2

octave:3> p(indx)
ans =

  -0.0000 + 3.0000i
   0.0000 + 3.0000i
  -0.0000 - 3.0000i
   0.0000 - 3.0000i


D.


Thanks for anticipating the last part

 p(indx)
ans =

  -0.0000 + 3.0000i
   0.0000 + 3.0000i
  -0.0000 - 3.0000i
   0.0000 - 3.0000i

The problem appears to have been solved!

Thanks David
(and Henry too)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]