[R] R function that duplicates Octave's poly function?

Jason Rupert jasonkrupert at yahoo.com
Sat Nov 28 15:33:40 CET 2009


By any chance is anyone aware of an R function that duplicates Octave's poly function? 

Here is a description of Octave's poly function:

Function File:  poly (A)
     If A is a square N-by-N matrix, `poly (A)' is the row vector of
     the coefficients of `det (z * eye (N) - a)', the characteristic
     polynomial of A.  As an example we can use this to find the
     eigenvalues of A as the roots of `poly (A)'.
          roots(poly(eye(3)))
          => 1.00000 + 0.00000i
          => 1.00000 - 0.00000i
          => 1.00000 + 0.00000i
     In real-life examples you should, however, use the `eig'
     function for computing eigenvalues.

     If X is a vector, `poly (X)' is a vector of coefficients of the
     polynomial whose roots are the elements of X.  That is, of C is a
     polynomial, then the elements of `D = roots (poly (C))' are
     contained in C.  The vectors C andD are, however, not equal due
     to sorting and numerical errors.

Thanks again for any insights and feedback.




More information about the R-help mailing list