summing over a list of variables?
Hi all,
I'm new to SAGE (I'm trying to move over from Mathematica), and I was wondering if someone could help me define the following function:
rk(x1,x2,x3,x4)=(4∑i=k+1x2i)1/2
I figured I could do something like:
var('k,j', domain=NN)
x = [var('x_{index}'.format(index=i)) for i in range(4)]
r(k,x) = sqrt( sum( x[j]^2, j, k, 3 ) )
But this returns the error:
TypeError: unable to convert x (=j) to an integer
Worse yet, when I enter sage:x, it returns x, and forgets x was a list of variables. And to complicate things, when I try
y = [1,2,3]
sum( y[j], j, 0, 1)
I get the error
TypeError: unable to convert x (=j) to an integer
even after I do "clear_vars()" and try everything all over again.
Can anyone tell me what's going on?