I prefer Polynomials than symbolic expression :

sage: R.<x> = PolynomialRing(QQ, 'x')
sage: P = (x^2 + 1) * (x^2 - x - 1)
sage: P.roots()  # no root in QQ
[]
sage: P.roots(RR)  # two roots in RR
[(-0.618033988749895, 1), (1.61803398874989, 1)]
sage: P.roots(CC) #  four roots in CC
[(-0.618033988749895, 1), (1.61803398874989, 1),
(-8.79016911342623e-17 - 1.00000000000000*I, 1),
(-8.79016911342623e-17 + 1.00000000000000*I, 1)]


But it can also be done with symbolics

sage: x = var('x')
sage: P = (x^2 + 1) * (x^2 - x - 1)
sage: P.roots(x, ring=QQ)
[]
sage: P.roots(x, ring=RR)  # two roots in RR
[(-0.618033988749895, 1), (1.61803398874989, 1)]
sage: P.roots(x, ring=CC) #  four roots in CC
[(-0.618033988749895, 1), (1.61803398874989, 1),
(-8.79016911342623e-17 - 1.00000000000000*I, 1),
(-8.79016911342623e-17 + 1.00000000000000*I, 1)]
sage: P.roots(x, ring=SR) # the symbolic ring
[(-1/2*sqrt(5) + 1/2, 1), (1/2*sqrt(5) + 1/2, 1), (-I, 1), (I, 1)]

--

You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en.


Reply via email to