Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm using Mathematica to compare some constants. Before playing around with those constants, I would like to check that I didn't make any mistake in typing them. So my question is the following: "What is the command that return the expression I typed?"

Just to be clear. The expression

4*Sum[Log[Gamma[k]], {k, 3, IntegerPart[n] + 2*(n - IntegerPart[n])}]

returns:

enter image description here

And that is what I want. On the other hand, the expression

Sum[(2*n - 2*m - 1)*Log[n*(m + 1)], {m, 0, IntegerPart[n] - 1}]

returns:

enter image description here

and that is what I want to avoid!

share|improve this question
1  
You can use Hold and its variants. –  b.gatessucks Mar 25 '13 at 10:58
1  
And it's best to post code, so people can copy/paste and try for themselves. –  b.gatessucks Mar 25 '13 at 10:59
    
Thank you for the fast reply! I'm sorry for non-posting code. I'll keep it in mind for next questions. –  Giovanni De Gaetano Mar 25 '13 at 11:02
    
Just edit the question and paste in the actual code. This makes for a better question and a better site. –  Jagra Mar 25 '13 at 11:58
    
@Jagra You're definitely right! I edited my question, is it fine now? :) –  Giovanni De Gaetano Mar 25 '13 at 13:38

2 Answers 2

up vote 5 down vote accepted

What you want is probably HoldForm but I don't understand why you cannot just check what you typed and why you need it to be printed again:

HoldForm[Sum[(2 n - 2 m - 1)*Log[n (m + 1)], {m, 0, IntegerPart[n] - 1}]]

Mathematica graphics

share|improve this answer
    
Yes, this is exactly what I was looking for! At the beginning I was trying to do that because it's just simpler to check long expression in the form I'm used to do that. After I while I was just refusing to believe that there wasn't a proper command on Mathematica (I could't find it googling around)! –  Giovanni De Gaetano Mar 25 '13 at 13:32
1  
Welcome to the 20K club. Congratulations! :-) –  Mr.Wizard Mar 25 '13 at 19:11

What you could do is

SetOptions[Sum, Method -> None]

Then

Sum[(2 n - 2 m - 1)*Log[n (m + 1)], {m, 0, IntegerPart[n] - 1}]

does not evaluate, similar to like @halirutans solution. The advantage is that you can control this globally and do not have to put HoldForm everywhere.

share|improve this answer
    
Thanks for the answer! In this specific case I'm fine with the "local" solution, but it's good to have another tool at disposal if needed. –  Giovanni De Gaetano Mar 25 '13 at 15:43

Your Answer

 
discard

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.