# Construct a sum that evaluates its arguments but doesn't evaluate further

I'm trying to construct a sum like this:

Sum[body, range]


where body is

$$\frac{1}{\sqrt{n!}}+\frac{1}{\sqrt{(n+1)!}}+\frac{1}{\sqrt{(n+2)!}}+\frac{1}{\sqrt{(n+3)!}}$$

and range is $\{n,0,\infty \}$.

body = 1/Sqrt[n!] + 1/Sqrt[(1 + n)!] + 1/Sqrt[(2 + n)!] + 1/Sqrt[(3 + n)!];
range = {n, 0, Infinity};


This can be done by

Sum[Evaluate@body, Evaluate@range]


Out==>$$\sum _{n=0}^{\infty } \left(\frac{1}{\sqrt{n!}}+\frac{1}{\sqrt{(n+1)!}}+\frac{1}{\sqrt{(n+2)!}}+\frac{1}{\sqrt{(n+3)!}}\right)$$

But Mathematica takes a long time attempting to compute the sum, which I don't need it to do. Is there a way to prevent the computation of the sum but still evaluate the body and range parts?

I tried the Trott-Strzebonski in-place evaluation trick:

HoldForm[Sum[body, range]] /. Sequence[x__] :> RuleCondition[Evaluate[x]]


But it didn't work. Where did I do wrong?

-

This will just display but not calculate anything:

Defer[Sum[1/Sqrt[n!] + 1/Sqrt[(1 + n)!] + 1/Sqrt[(2 + n)!] +
1/Sqrt[(3 + n)!], {n, 0, Infinity}]]


Or,

Defer[Evaluate[Hold[Sum][body, range]]] /. Hold[Sum] -> Sum


-
thanks, but the if you define body and range like in the question and do Defer[Sum[body,range]], it will not work. Since in my code the "body" and "range" are generated from other function, so I have to define a variable form them. –  xslittlegrass Mar 3 '13 at 22:41
That's cool, thanks! –  xslittlegrass Mar 3 '13 at 22:50
Actually, I sometimes wished "6.2 Nouns and Verbs" from here would make it into Mathematica one day ... –  Rolf Mertig Mar 3 '13 at 22:51
body = 1/Sqrt[n!] + 1/Sqrt[(1 + n)!] + 1/Sqrt[(2 + n)!] +
1/Sqrt[(3 + n)!];
range = {n, 0, Infinity};


Perhaps, if you want something more or less general

HoldForm@Sum[body, range] /.
s_Symbol /; Context[s] != "System" :> Block[{}, s /; True]


though the typical injection is

With[{body = body, range = range},
HoldForm@Sum[body, range]
]


Defer` would work too if you want an evaluatable output.

-