Questions tagged [hold]

Questions about functions which maintain an expression in unevaluated form, including the use and behavior of Unevaluated, Hold~ functions, Inactive related functions or Hold~ attributes.

Symbols covered:

  • Unevaluated, Hold, HoldForm, HoldPattern, HoldComplete

  • Inactive, Inactivate, Activate

  • HoldAll, HoldFirst, HoldRest, HoldAllComplete

Useful Links:

381 questions
10
votes
4 answers

Hold expression with RandomInteger

One more question for today: I'm trying to show two random integers with a plus (+) sign between them, in an unevaluated form. I know how Hold and HoldForm work, but they hold everything, including the RandomInteger: Hold[RandomInteger[100] +…
Gabriel
  • 1,877
  • 12
  • 22
4
votes
1 answer

HoldForm/Inactivate and exchange operators

I would like to know, how to change parts of a formula in HoldForm. I have the formula $$ \underbrace{\prod_{i=1}^N}_{\text{level 4}} \sum_{\sigma_i\in \{-1,1\}}\underbrace{\sum_{\lambda\in \{-1,1\}}}_{\text{level…
Uwe.Schneider
  • 251
  • 1
  • 6
3
votes
2 answers

Showing both the analytical and numerical versions of a matrix

I have found that the Defer function, among others such as HoldForm or Inactive, seems to be the key to something I want to do, but I have been unable to figure out. If I calculate the value of a variable and then print it using Defer, it correctly…
sg1234
  • 289
  • 1
  • 7
3
votes
2 answers

Print without evaluating

I want to print, for example Print[a + b], but first a = RandomChoice[{-3, -2, -1, 1, 2, 3}]; b = RandomChoice[{-3, -2, -1, 1, 2, 3}]; And every time you calculate the random value, I can see 2 + 3 or -3 + 1 without evaluating.
user54300
  • 31
  • 1
3
votes
4 answers

Make function return unevaluated equation

I have made this function which outputs the equation of a nth degree polynomial: polynomial[degree_] := ( result = 0; For[count = 1, count <= degree, result += ToExpression[FromCharacterCode[96 + count]]*x^(degree - count); …
Tyilo
  • 1,545
  • 13
  • 25
2
votes
1 answer

Element of list not evaluating derivative after I define function

I have the following code Clear[AdomTrunctest, AdomPolyNtest, ListPolytest, y]; AdomTrunctest = 3; ExDtest := Sum[D[y[n, t], t], {n, 0, AdomTrunctest}]; Ntest = Expand[(y'[t])^2 /. y'[t] -> ExDtest ]; ListPolytest = Reverse[MonomialList[ …
Decebalus
  • 115
  • 7
2
votes
3 answers

Preventing evaluation of $e^{2i \pi}$

I want to prevent Mathematica from using the identity $e^{2i \pi} = 1$ because at a later step I will evaluating something like $\left(e^{2i \pi}\right)^\alpha$ for some non integer $\alpha$. I wish for it to return $e^{2i\pi\alpha}$ instead of $1$.…
nGlacTOwnS
  • 123
  • 6
1
vote
1 answer

Prevent evaluation of function result

Forgive my ignorance, I'm new to Mathematica/the Wolfram Language. I'm looking for a way to apply HoldForm or some equivalent to the result of a function, as well as its arguments. For example, I would like to modify Sort[Unevaluated[n+1+2]]] so…
mm716783
  • 19
  • 2
0
votes
1 answer

Expression evaluation

I have got the following solution to an equation: {{xc -> (2.54648*10^-6 (-555.653 Sqrt[-3306.94 + Exp] Sqrt[Exp] - 9.00829 Exp))/Exp}, {xc -> (2.54648*10^-6 (555.653 Sqrt[-3306.94 + Exp] Sqrt[Exp] - 9.00829 Exp))/Exp}} How I can put…
0
votes
1 answer

Unevaluated form of an expresion

I have two matrices - s1 and s2. I want their sum to remain unevaluated. For instance, the command s1 + s2 // MatrixForm should result to two separate matrices joined by the plus operator. I guess that I have to wrap s1 + s2 inside a function like…
Dimitris
  • 4,794
  • 22
  • 50
0
votes
1 answer

Is there anyway to shut down inactive PC automatically as soon as computation finishes?

Instead of running PC whole night when computation stops somewhere in middle of night, is there anyway to shut down PC automatically few moments after computation running completes.
0
votes
1 answer

Hold the value of a variable

This is my code xyzzy = 1; Hold[xyzzy] // ToString // StringLength The output is 11. This 2nd one below. ClearAll[xyzzy] ToString[xyzzy] // StringLength] The output is 5. Why is this? I think these 2 codes will be the same output
kile
  • 1,671
  • 5
  • 10
0
votes
2 answers

Inactive / Activate : basic question of how it works

I would like to understand how Inactive and Activate function works because I'm disturbed. If I need to inactivate a function and then re activate it how to do it ? I tried the following which doesn't work : hh[x_] := x^2 hh[2] 4 hh =…
StarBucK
  • 2,164
  • 1
  • 10
  • 33
0
votes
1 answer

Keep only bit of an expression unevaluated for display

Consider the code h[x_, y_, n_] := x^2 + (y - (x^2)^(1/n))^2 g[u_] := ContourPlot[h[x, y, u] == 1, {x, -1, 1}, {y, -1, 2}, PlotLabel -> StandardForm[h[x, y, u]] == 1] g[3.1] which gives I would like 1/3.1 to be displayed in the PlotLabel…
frapadingue
  • 103
  • 2