>
> On 3/7/07, Kyle Schalm <[EMAIL PROTECTED]> wrote:
>
>> . the question is: how do i evaluate w while leaving z untouched?
>> (i actually want to do this when R1 is a multivariable ring, but i imagine
>> it works the same way.)
>>
>
> Can't you just work with all the variables together, like:
>
> sage: P.<z,w>=QQ['z','w']
> sage: P
> _2 = Polynomial Ring in z, w over Rational Field
> sage: f=z*w
> sage: f(z,2)
> _4 = 2*z
i suppose i could if necessary. it's not ideal for at least two reasons i
can think of:
1. if i want to evaluate just z (the most common case), then i have to
write f(z,_,_,_,...).
2. separating the other variables into a base ring causes the polynomial
to group terms by powers of z, which i also like.
>
> If, not, you can always make a little function to evaluate (if there
> is no "built-in" way).
>
> sage: R1.<w> = QQ['w']
> sage: R2.<z> = R1['z']
> sage: f = z*w
> sage: def my_eval(f,a):
> ...: coef=f.coeffs()
> ...: res=0
> ...: for i in range(len(coef)):
> ...: res+=coef[i](a)*z^i
> ...: return res
> ...:
> sage: f = z*w
> sage: my_eval(f,2)
> _5 = 2*z
> sage: g=(w+1)+w^2*z+3*z^3
> sage: my_eval(g,2)
> _7 = 3*z^3 + 4*z + 3
hmm, this looks useful and i think that is what i will do. much thanks.
-kyle
--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---