Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Defining a function of the form $f(x_1,x_2,...,x_n)=\sum_{i=0}^n x_i$

How can I define a function of the form $$f(x_1,x_2,...,x_n)=\sum_{i=0}^n x_i$$ I tried the following
sage: n = 2
sage: x = [ var('x_%d' % i) for i in range(n) ]
sage: f(x)=sum(x[i],i,0,n)
The last line gives me the error
"TypeError: 'sage.symbolic.expression.Expression' object does not support indexing".