On 9/7/10 3:34 PM, tvn wrote:
Hi John and Jason,  thanks  --  the inject_variables() did what I
want.

I have another question below and hope you can help

what if I already have create a function call f = x - y as below


sage: vs = var('x y')
sage: f = x - y
sage: type(f)
<type 'sage.symbolic.expression.Expression'>


now I want to convert f to
sage.rings.polynomial.multi_polynomial_element.MPolynomial_polydict  ,
is there any convenient way to do so ?    One way is to define
variables x,y in PolynomialRing QQ and then redefine f = x-y  but it's
quite inconvenient.




Try the .polynomial() method:

sage: var('x,y')
(x, y)
sage: f=x-y
sage: g=f.polynomial(QQ)
sage: g
x - y
sage: type(g)
<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
sage: g.variables()
(x, y)
sage: g.parent()
Multivariate Polynomial Ring in x, y over Rational Field

Jason

--
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-support
URL: http://www.sagemath.org

Reply via email to