# Sums with index expressions instead of variables

Often I replace $k$ with, say, $m-k^2$ in a sum, obtaining something like this: $$\sum_{0\leq m-k^2\leq n} f(k)$$ Is there a way to input these without manually solving the inequalities?

• maybe Sum[f[k] Boole[0 <= m - k^2 <= n], {k, -Infinity, Infinity}]? – kglr Apr 19 '16 at 20:06
• @kgir Is mathematica able to work with that, though? – Elliot Gorokhovsky Apr 19 '16 at 20:07
• Rene, it seems to work; please check if the answer i posted is what you had in mind. – kglr Apr 19 '16 at 20:14
• @kglr No, what I mean is does that mess up Mathematica's ability to try to find a closed form? – Elliot Gorokhovsky Apr 19 '16 at 20:15
• When I tried Sum[i^2 Boole[0 <= m - i^2 <= n], {i, 1, n}], it took some time but did give an output in closed form. – kglr Apr 19 '16 at 20:24

sumF = Sum[f[k] Boole[#], {k, -Infinity, Infinity}] &;
sumF[m <= 100 - k^2 <= n] sumF[0 <= 100 - k^2 <= 50]


f[-10] + f[-9] + f[-8] + f + f + f

sumF[0 <= 100 - k^2 <= 50] /. f -> (#^2 &)


490

Sum[i^2 Boole[0 <= m - i^2 <= n], {i, -Infinity, Infinity}] 