Suppose I have defined a function f(x)=x^2 and a list x=[0,1,2,3,4]
Now I can calculate the product x[2]*f(x[2]). But: If I use the command
k=var('k') sum(x[k]*f(x[k]),k,0,4)
I will get the message: "TypeError: unable to convert x (=k) to an integer"
How can I realize such a summation?