# 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:

$$ r_k(x_1, x_2, x_3, x_4) = \left( \sum_{i=k+1}^{4} x_i^2 \right)^{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?