# Symbolic function that sums over variable sequence

How do I define a symbolic function that takes a sum of variables as value?

I have tried the following:

```
k=var('k')
f(x)=sum(x[k], k, 1, 5)
```

But I get the following error:

```
TypeError: unable to convert k to an integer
```

I want to be able to symbolically differentiate `f`

with regards to e.g. `x[3]`

.