Hello,

On Thu, Mar 5, 2009 at 11:24 AM, Bob <gotw...@gmail.com> wrote:
>
> I need to find the roots of this polynomial, where are coefficients
> are in this matrix:
>
> coef=matrix([[1],[-1],[-1],[0]])

First, you should construct a polynomial.  A matrix of coefficients is
not the preferred way to work with polynomials in Sage.

sage: coef=matrix([[1],[-1],[-1],[0]])
sage: R.<x> = QQ[]; R
sage: f = R( list(coef.column(0)) ); f
-x^2 - x + 1

Above, I created the polynomial ring R (in the variable x), and then I
created the polynomial by passing in the 0th column of the matrix in
as a list.

Next, you use the .roots() method to get the roots.  If you don't
specify an additional ring, it will default to the one that the
polynomial is defined over.

sage: f.roots()
[]
sage: f.roots(QQ)
[]

The above says that the polynomial has no rational roots.  You
probably want floating point complex numbers (which is what polyroots
in MathCAD gives).

sage: CDF
Complex Double Field
sage: f.roots(CDF)
[(-1.61803398875, 1), (0.61803398875, 1)]

--Mike

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to