On Jun 21, 2010, at 10:53 PM, Matthias Meulien wrote:
I guess that the problem comes from the type of p1, not
being an Expression. So is it possible to cast this p1 to the
Expression class?
A direct conversion like the following works:
sage: p3 = 0
sage: for c in p1.coeffs():
....: p3 = x*p3 + c
....:
sage: p3
-3/4*pi + 7/4*pi*x
sage: type(p3)
<type 'sage.symbolic.expression.Expression'>
sage: p3.roots(x)
[(3/7, 1)]
You could evaluate p1 at the symbolic variable x.
sage: basering = PolynomialRing(SR, 'x')
sage: p1 = basering.lagrange_polynomial([(0,0), (1,pi), (2, pi/2)])
sage: expr = p1(var('x'))
sage: type(expr)
<type 'sage.symbolic.expression.Expression'>
sage: expr.roots(x)
[(7/3, 1), (0, 1)]
- Robert
--
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
URL: http://www.sagemath.org