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 this? n is not set, so I just can't type
> this out.
That's intriguing syntax, but I don't think it will work.
Assuming that, at the call site, you know all your values, you can
cobble up a tuple or list, something like the following:
L = [f(i+1) for i in range(n)]
print g(L)
You can do this to determine 'n', assuming you don't know it at the
call site:
n = len(g.variables())
HTH
Justin
--
Justin C. Walker, Curmudgeon-At-Large
Director
Institute for the Enhancement of the Director's Income
--------
"Weaseling out of things is what separates us from the animals.
Well, except the weasel."
- Homer J Simpson
--------
--~--~---------~--~----~------------~-------~--~----~
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---