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.

382 questions
Filter by
Sorted by
Tagged with
95 views

How to Block built-in functions conditionally in a single Block statement? [closed]

I have used the following method and it seems to be working. Just posting here since this way seems hacky. So if anyone can point a better way. ...
• 9,443
44 views

Plot and HoldAll [duplicate]

Can someone explain why the following works, despite Plot having the attribute HoldAll: tmp = {x, x^2}; Plot[tmp, {x, 0, 1}]
• 52.7k
110 views

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.
1 vote
56 views

Force certain operations to evaluate last

I have an integral of a term which first needs some massaging, e.g. (EDIT: Made the integral in such a way that it cannot be pulled out) ...
128 views

Evaluation control in function definition: Total interferes with Evaluate

Here is a simple example to illustrate my problem: ...
• 387
1 vote
73 views

Understanding HoldFirst in QuickSort algorithm

I have read the implementation of QuickSort algorithm in WL from Roman Maeder's Computer Science with Mathematica (2000). The implementation is shown below. ...
1 vote
41 views

Maintaining form of Manipulate to find the formula area of a projected cuboid

I am experimentally trying to solve this problem about the projected area of a cuboid. I sense patterns when I run the below code, but it is difficult for me to compare them. Here is the code: ...
106 views

Can't get TagSetDelayed to match LHS when the latter has a Hold attribute set

I'm following this example here; Code Readability and Object-Oriented Code ...
125 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 ...
• 289
1 vote
40 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: ...
• 185
174 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 ...
• 3,960
1 vote
35 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'...
53 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: ...
• 254
236 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 ...
• 1,729
59 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: ...
213 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 ...
• 534
32 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 ...
• 131
72 views

Using Unevaluated to get a list of symbol names

The official documentation of Unevaluated contains the following example: ...
• 5,251
33 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 ...
• 1,457
62 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 ...
• 145k
233 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 ...
• 353
41 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 ...
• 353
68 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 ...
• 131
1 vote
112 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 ...
106 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 ...
• 1
106 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: ...
• 2,404
33 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 ...
105 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 &...
• 181
105 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 ...
• 53
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 ...
• 2,323
152 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 ...
• 5,401
240 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 ...
• 4,510
1 vote
58 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 <...
• 21
49 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 ...
• 7,253
156 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 ...
• 483
86 views

Visualizing order of operations

TreeForm[HoldForm[ (9-2^2+10 8)/9]] produces this: Is there a way to use Divide instead of ...
• 478
94 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 ...
• 2,404
306 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: ...
• 18.9k
292 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) ...
• 18.9k
111 views

Holding after evaluation

Given this little piece of code: ...
• 167
114 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 ...
• 1,245
269 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 ...
• 657
242 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 ...
• 153
215 views

• 184
242 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 ...
• 359