Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to construct a sum like this:

Sum[body, range]

where body is


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?

share|improve this question
up vote 6 down vote accepted

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}]]


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

Mathematica graphics

share|improve this answer
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.