Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

referencing polynomial variables

Suppose I have a polynomial $f$ in the variables $x_1, \dots, x_5$ defined by something like

f = 0 
for counter in range(1,5): 
    f += mylist[counter] * var('x' + str(counter))

where mylist is some list of integers. Then I can evaluate $f$ by e.g.


Question: How do I do this evaluation when $f$ is in $n>>0$ variables?

I want to write something like

for counter in range(1,n):
    f = f.subs(var('x' + str(counter))=counter)

but this isn't a valid argument for subs. This must be some way to coerce this to work.