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.


sage: vs = var('x y')
sage: R = PolynomialRing(QQ,vs)
sage: R.inject_variables()
Defining x, y
sage: f = x -y
sage: type(f)
<type
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
sage: type(x)


Thanks again for the quick helps

On Sep 7, 12:03 pm, Jason Grout <[email protected]> wrote:
> On 9/7/10 12:47 PM, tvn wrote:
>
> > Hi, given a list of variable names as strings (e.g.,  l =
> > ['a','b','c','d'])  I try to make those become variables in a
> > Polynomial Ring.  One way is to do something like
> > R.<a,b,c,d>=CC['a','b','c','d'] ,  after this the type of a or b or c
> > or d is<class
> > 'sage.rings.polynomial.multi_polynomial_element.MPolynomial_polydict'>  .
>
> > How can I do this in a more automatic way  that can take in the list l
> > and do the same thing as above (e.g., make a,b,c,d of type<class
> > 'sage.rings.polynomial.multi_polynomial_element.MPolynomial_polydict'>)
> > without having to manually type  R.<a,b,c,d>  ?
>
> > Thanks  in advance
>
> Something like this?
>
> sage: R=CC[','.join('x{0}'.format(i) for i in range(20))]
> sage: R.inject_variables()
> Defining x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13,
> x14, x15, x16, x17, x18, x19
> sage: type(x0)
> <class
> 'sage.rings.polynomial.multi_polynomial_element.MPolynomial_polydict'>
>
> 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