[sage-support] Re: substitute values into a muttivariate polynomial

2009-06-07 Thread Justin C. Walker
On Jun 7, 2009, at 15:53 , amps wrote: > > When I say that n is not predetermined, I mean that I want my script > to work for any n. So before I define the polynomial ring, n is > determined, but I want this to work for all n. So my question is how > do I do the following. > > n=6 > R=Polynomi

[sage-support] Re: substitute values into a muttivariate polynomial

2009-06-07 Thread Mike Hansen
This works: sage: n=6 sage: R=PolynomialRing(QQ,n,'z') sage: z=R.gens() sage: g=sum(z[i] for i in range(n)) sage: g.subs(dict((z[i], i) for i in range(n))) 15 --Mike --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsub

[sage-support] Re: substitute values into a muttivariate polynomial

2009-06-07 Thread Justin C. Walker
On Jun 7, 2009, at 15:23 , amps wrote: > > sorry, i meant > > g.subs({z[1]:value1...}) > > I am not sure why you call this intriguing syntax, but it is what > works. My turn to say sorry. I just mentally wiped out the '.subs' part. > My problem is that I don't know how to do this if the numbe

[sage-support] Re: substitute values into a muttivariate polynomial

2009-06-07 Thread amps
When I say that n is not predetermined, I mean that I want my script to work for any n. So before I define the polynomial ring, n is determined, but I want this to work for all n. So my question is how do I do the following. n=6 R=PolynomialRing(QQ,n,'z') z=R.gens() g=sum(z[i] for i in range(n)

[sage-support] Re: substitute values into a muttivariate polynomial

2009-06-07 Thread amps
sorry, i meant g.subs({z[1]:value1...}) I am not sure why you call this intriguing syntax, but it is what works. Example: g=x+y g.subs({x:2,y:4}) 6 My problem is that I don't know how to do this if the number of variables is not predetermined. I tried to make a list with a=list() for i in rang

[sage-support] Re: substitute values into a muttivariate polynomial

2009-06-07 Thread Justin C. Walker
On Jun 7, 2009, at 13:03 , amps wrote: > > I want to substitute n values into polynomial with n variables. > > I guess the syntax to do this is (if g is my polynomial with > indeterminates z[1], ..., z[n]). > > f.subs({z[1]:value1, z[2]:value2, ..., z[n]:valuen}) > > but how do I actually do thi