# Evaluation of Extract and use the result in a Sum

I am experiencing a problem in the evaluation of a sum. I hope that someone can help me, I am not an expert Mathematica programmer. I'm posting just the portion of code that gives problems, I know that this is silly but it is embedded in a more complicated function.

Module[{r = Extract[{0, 0, x, y, 0}, 3],
inf = Extract[{0, 0, x, y, 0}, 5],
sp = x + y},
Sum[t^sp, {r, inf, Infinity},
Assumptions -> {t < 1 && t > 0}]
]


I need to select the index of the Sum from a list of symbols, for example x or y. While the evaluation of the lower and upper bounds of the Sum is done as expected, I cannot see the way of selecting the index and I obtain that the sum does not converge:

Sum[t^(x + y), {r\$42458, 0, Infinity},
Assumptions -> {t < 1 && t > 0}]


Thanks for the help.

If I understand your question correctly, you're asking how to replace the iteration variable in sum with some other selected variable.

The reason your code doesn't work is that, in Sum the iteration variable is localised by making use of Block. You can use With to replace all occurrences of a symbol inside an expression with another value (even inside held expressions) So

With[{r = Extract[{0, 0, x, y, 0}, 3],
inf = Extract[{0, 0, x, y, 0}, 5],
sp = x + y},
Sum[t^sp, {r, inf, Infinity},
Assumptions -> {t < 1 && t > 0}]]


will give what you expect.

$$\frac{t^y}{(1 - t)}$$