# How can I prevent Mathematica from evaluating or “simplifying” an expression?

Simple example:

k = 5;
list = {};
For[i = 1, i <= k - 2,
AppendTo[list, 1/(1 + Cos[i Pi/k])];
i = i + 2];
Print[list];

{1/(1+1/4 (1+Sqrt)),1/(1+1/4 (1-Sqrt))}


I want the expression to be kept and printed as:

{1/(1 + Cos[Pi/5]), 1/(1 + Cos[3 Pi/5])}


I have tried Hold and its several versions, but nothing seems to do the trick.

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – chris Apr 1 '13 at 7:03

k = 5;
list = {};
For[i = 1, i <= k - 2,
With[{i = i, k = k},
AppendTo[list, HoldForm[1/(1 + Cos[(i \[Pi])/k])]]];
i = i + 2];
Print[list]; • Perhaps Table[With[{i = i, k = k}, HoldForm[1/(1 + Cos[i Pi /k])]], {i, 1, k - 2, 2}] is more Mathemaica-ish – Dr. belisarius Mar 31 '13 at 23:22
• @belisarius I know, but that's not what the OP wanted. – Sjoerd C. de Vries Apr 1 '13 at 8:31
• Sjoerd: I know you know :). I was "talking" to the OP. Sorry for the confusion – Dr. belisarius Apr 1 '13 at 8:46

As stated HoldForm is your friend here. Also see Defer if you intend to reuse the output.

Equivalent methods:

Table[With[{i = i, k = k}, HoldForm[1/(1 + Cos[i Pi/k])]], {i, 1, k - 2, 2}]

Table[{i, k} /. {i_, k_} :> HoldForm[1/(1 + Cos[i Pi/k])], {i, 1, k - 2, 2}]

Table[HoldForm[1/(1 + Cos[# Pi/#2])] &[i, k], {i, 1, k - 2, 2}] 