As of May 31, 2023, we have updated our Code of Conduct.

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.

Filter by
Sorted by
Tagged with
3 votes
2 answers
116 views

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 ...
sg1234's user avatar
  • 195
1 vote
1 answer
36 views

How to delay evaluation of Tuples[list,n] when n is a variable to be optimized through NMinimize?

I am trying to do a linear optimization on a variable i where an intermediate variable v is needed: ...
WaterFox's user avatar
  • 185
4 votes
3 answers
161 views

HoldForm not working with Map

I am debugging a ListPlot implementation and I need to see the command. To avoid huge list of numbers, i just need the ListPlot ...
atapaka's user avatar
  • 3,609
1 vote
0 answers
33 views

Hold around SetDelayed with Graphics [duplicate]

Minimum Working Example I've defined my own plot function, which does a lot of stuff to the inputs before passing it into the Graphics function. Because of that, I'...
Travis Bemrose's user avatar
2 votes
1 answer
49 views

How to modify the argument of a specific function below?

I would like to change the values of a and b in the following function: ...
TobiR's user avatar
  • 232
5 votes
2 answers
221 views

Do not understand evaluation order of ReplaceAll [duplicate]

{x, x^2, Length@x, Subsets[x]} /. x -> {1, 2, 3} (* {{1, 2, 3}, {1, 4, 9}, 0, {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}} *) with error What ...
lesobrod's user avatar
  • 859
5 votes
0 answers
58 views

Why does MatchQ[Hold[c + b + a], Hold[x_ + b + a]] return False?

Can anyone explain why the following pattern matches: [In1]:MatchQ[Hold[a + c + b], Hold[x_ + b + a]] [Out1]:True But this one fails: ...
user61796's user avatar
7 votes
2 answers
172 views

Map function with evaluated and unevaluated parameters

Let's consider a function with evaluated and unevaluated arguments inside: list1 = {1,2,3} list2 = {x,y,z} fun[list_]:={list,ToString@Unevaluated@list} When I use ...
Lechuu's user avatar
  • 383
2 votes
0 answers
30 views

Replacement rule evaluates before substitution [closed]

I have found similar issues in other questions, but none of the answers I found quite do what I want. I have a list of the form list={{x, a}, {y, b}, {z,c}} and ...
Bedge's user avatar
  • 121
0 votes
1 answer
56 views

Using Unevaluated to get a list of symbol names

The official documentation of Unevaluated contains the following example: ...
Shredderroy's user avatar
  • 4,957
0 votes
0 answers
32 views

How do I prevent, or get rid of the <code>Abs^\[Prime]</code> in the output of a partial of a Normalize[vector]? 12.0.0 for Microsoft Windows [duplicate]

12.0.0 for Microsoft Windows How do I prevent, or get rid of the Abs^[Prime] in the output of a partial of a Normalize[vector]? The code below shows the problematic ...
Steven Thomas Hatton's user avatar
4 votes
1 answer
59 views

another problem with context using package and association when using Inactivate

This problem is similar to this problem using package to verify solution of ode with Association, Naming scope/context handling but when I used the solution/trick given there, I still get a problem. I ...
Nasser's user avatar
  • 130k
4 votes
1 answer
157 views

Why is Evaluate[] in Plot[] not necessary in some cases?

after reading some related materials(Why do I have to put Evaluate[] here), in my understanding, BecauseAttributes[Plot] has ...
Aerterliusi's user avatar
0 votes
0 answers
39 views

Some confusions about Evaluate[] and HoldAll in Plot[] [duplicate]

i can't understand the outputs of the three commands in the following picture. question1: In my understanding, command one Plot[Table[a*x^2,{a,3}],{x,-3,3}] is ...
Aerterliusi's user avatar
2 votes
2 answers
61 views

Pattern matching in Association fails in `Set` assignment

I want to define a symbolic-valued function using Set to memoize the result. However, I get different results when using an ...
Phro's user avatar
  • 131
1 vote
2 answers
105 views

Symbolic manipulations of predefined variables without numerical substitution

As a novice in Mathematica I would like to expand an expression without substituting its variables so that x = 4; y = 4; Expand[(x^2 + y^2)/x^2] generates the same ...
Joost Keuskamp's user avatar
0 votes
1 answer
71 views

Preventing evaluation of $Exp[\pm i\pi]$ until the end of a calculation

I'd like to prevent Mathematica from evaluating $Exp[\pm i\ \pi]$=-1 until I tell it to, at the very end of a calculation. I have a lengthy expression that involves things like (-x+y)^(n), and I know ...
Ali's user avatar
  • 1
0 votes
1 answer
102 views

Replacing a term according to a given criterion in an expression with non-commutative multiplication (for any sign and location)

There is the following expression: ...
dtn's user avatar
  • 2,344
0 votes
0 answers
32 views

DisableFormatting for a single instance of Grid, but format expressions inside that Grid

I have an expression like: Grid[{{ HoldForm[ ... Grid[...] ... ] },{ ... Grid[...] ... }}] This almost gives what ...
Travis Bemrose's user avatar
4 votes
1 answer
93 views

Holds, Defers, Unevaluated & Inactive

I can program well enough in the Wolfram Language & ignore the nuisances that can pop up... Except Holds, Defers, Unevaluated & Inactive. I never did learn the subtleties of the functions &...
Tempus Nomen's user avatar
2 votes
1 answer
91 views

Evaluate a double sum using Mathematica

I am evaluating using Mathematica, the double sum $\sum_{u=0}^\infty \lbrace \sum_{k= u+1}^{u+y}[\dfrac{(1-a)}{4} (3/4)^k + 3a[(\dfrac{1}{2})^{k-1} - (\dfrac{3}{4})^{k-1} ]\rbrace $, where $'a' $ is a ...
Rosy's user avatar
  • 53
4 votes
1 answer
129 views

How to construct the HoldAll version of Information[]?

When building other functions I need the HoldAll version of Information, and the usual method seems not to work. Firstly as a ...
Lacia's user avatar
  • 1,663
3 votes
2 answers
119 views

Understanding HoldAll?

Suppose I try to run the following code: f[x_] := Cos[x] F[X_] := Normal[Series[f[x], {x, X, 5}]] Plot[Table[F[n], {n, -5, 5, 1}], {x, -Pi, Pi}] Mathematica will ...
Red Banana's user avatar
  • 5,111
10 votes
1 answer
201 views

How to programmatically construct a function or a compiled function?

I'd like to programmatically construct a function from a long expression with many duplicate terms. The objective is to programmatically create a set of compiled functions with expressions that were ...
Craig Carter's user avatar
  • 3,597
1 vote
0 answers
52 views

Plot functions don't allow postfix function execution?

I'm confused about syntax of using // for postfix function execution. It fails in some situations where I would expect it to work. For example, it works with both <...
yirenng's user avatar
  • 21
2 votes
0 answers
43 views

Automatically iconize all Associations in output cells

I work with expressions containing large associations (<|…|>) as subexpressions, and I want to automatically iconize all such subexpressions in all output ...
Vladimir Reshetnikov's user avatar
4 votes
1 answer
109 views

How can I preserve parentheses enclosing a dot product in a HoldForm[]?

I am having a problem with keeping the parentheses enclosing a dot product in HoldForm[]. I want to keep them in my equations since they indicate important grouping ...
AlbertLew's user avatar
  • 453
2 votes
1 answer
73 views

Visualizing order of operations

TreeForm[HoldForm[ (9-2^2+10 8)/9]] produces this: Is there a way to use Divide instead of ...
Geremia's user avatar
  • 458
3 votes
1 answer
92 views

Terms of expressions with non-commutative multiplication that meet the given criteria

There is the following expression: expr=a^3**x**Transpose[x]**y+x+y**Transpose[y]**x**a^3+x**Transpose[y] It is necessary to apply the ...
dtn's user avatar
  • 2,344
3 votes
3 answers
259 views

Different evaluation control inside of `Integrate` than outside of it

I want to keep inside of a integral evaluated after some replacement inside it, but at the same time the integral itself unevaluated. I start with: ...
azerbajdzan's user avatar
  • 5,935
6 votes
3 answers
266 views

HoldForm is not working as I would expect

Why HoldForm do this? HoldForm[a/b \[Integral]f[x] \[DifferentialD]x] Output is this ugly looking formula: $$\frac{a \int f(x) ...
azerbajdzan's user avatar
  • 5,935
2 votes
3 answers
100 views

Holding after evaluation

Given this little piece of code: ...
DrSvanHay's user avatar
  • 165
0 votes
1 answer
80 views

How to construct the local variables for Block automatically (somewhere in the code)

I am working on the fancy abstraction for Block function. The idea is to use rules to specify which local variable will be used, even if it already defined in the global context like this ...
Kirill Vasin's user avatar
4 votes
5 answers
262 views

How to define functions using a list of polynomials?

I feel stupid for not being able to do this and I think it is just a syntax error. Let's say i have the following list: L={x,xy,x^2+y,xyz,x^2} How do I define 5 ...
2132123's user avatar
  • 647
3 votes
3 answers
241 views

Seemingly identical expressions, only one evaluates! [closed]

I am having difficulty using NMaximize with a user-defined function that involves NSolve. Stack Trace shows trouble at the ...
FNia's user avatar
  • 153
6 votes
1 answer
197 views

Getting terms and only evaluate specific parts of a series

How to write the first five terms of this series in the following form by MMA code? $\sum_{n=1}^{\infty} \frac{1 \cdot 3 \cdot \cdots \cdot(2 n-1)}{2 \cdot 4 \cdot \cdots \cdot 2 n}= \frac{1}{2}+\frac{...
lotus2019's user avatar
  • 1,729
2 votes
0 answers
82 views

Why does Plot function have HoldAll attribute?

I had an odd issue where my plot wasn't drawn correctly when I called it via Plot[Join[fs,gs], (*..*)]. However, these two versions worked: ...
Niklas Vest's user avatar
1 vote
0 answers
72 views

Why does equal remain unevaluated in this case? [closed]

This is not really an issue but rather a curiosity. Why does -1 + 1/2 (-1 - Sqrt[5 - 20/9 (-43 + Sqrt[1885])]) + 1/2 (1 + Sqrt[5 - 20/9 (-43 + Sqrt[1885])]) == -1 ...
2132123's user avatar
  • 647
0 votes
0 answers
83 views

How to Hold a Form function

For Example Hold[HoldForm[FullForm[x]]] ...
Rainb's user avatar
  • 285
3 votes
3 answers
116 views

Apply HoldForm on only a part of an expression

This expression: Det[Array[a, {3, 3}]] is evaluated as: $-a(1,3) a(2,2) a(3,1)+a(1,2) a(2,3) a(3,1)+a(1,3) a(2,1) a(3,2)-a(1,1) a(2,3)a(3,2)-a(1,2) a(2,1) a(3,3)+a(...
Lai Yu-Hsuan's user avatar
0 votes
1 answer
146 views

Variable dimension tables with variable ranges

I need to construct a table that has variable dimension and variable ranges (see for tables with variable dimensions and constant ranges, e.g., this question). Suppose there is a list ...
Keyspire's user avatar
  • 327
3 votes
1 answer
87 views

A possible issue in combination of the Infix operator ~ with Sequence [closed]

There are other similar questions on this site about using the Infix operator for more than two arguments, which I have read. But there is one thing that I wasn't able to understand and couldn't ...
polfosol's user avatar
  • 835
5 votes
3 answers
279 views

Apply Plus as a new head to a list but prevent evaluation

I would like to illustrate to users the use of Apply with an example. Plus@@Range[5] (*15*) To display what is happening I'm ...
Whelp's user avatar
  • 1,643
3 votes
1 answer
197 views

How to substitute a random function into a solution of a differential equation?

I would like to solve a differential equation including a source term. The source term is a random variable and I model this by creating a list of RandomReal and ...
Uwe.Schneider's user avatar
0 votes
0 answers
55 views

Create a function from another by substituting arguments

Suppose I have a function f[x, coeff] ...
Max's user avatar
  • 291
3 votes
1 answer
42 views

Removing conditions on patterns from LHS of a rule

Let's consider a rule which takes conditions on the patterns specified on the LHS: In[1]:= rule = j[n1_?NonPositive,n2_?Positive,n3_?Positive]:>AAA I would like ...
dzejkob's user avatar
  • 501
1 vote
0 answers
98 views

Can't Export string made with StringForm?

This works. It returns "acb". StringForm["a``b", "c"] This doesn't work. ...
ppm's user avatar
  • 61
0 votes
1 answer
139 views

Derivative with respect to a variable is leaving unevaluated derivatives of functions

I have the following ...
GaussStrife's user avatar
2 votes
1 answer
74 views

Different Latex is generated when changing a number from 2 to 1. Using HoldForm

This is the most bizzar thing I saw with Mathematica TeXForm. Could someone please explain why it happens and if there is a workaround? First, will show screen shot. I have an expression, when I have ...
Nasser's user avatar
  • 130k
1 vote
0 answers
44 views

Generalised Hold pattern for currying

Let myFun[a_][b_] := myFun[a[b]] . The HoldFirst attribute will prevent evaluation of a. Is ...
user3257842's user avatar

1
2 3 4 5
8