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
1answer
38 views

Mathematica Documentation for `HoldAll`: `Unevaluated` doesn't do anything?

I'm trying to understand the difference between HoldAll and Unevaluated. The documentation for ...
1
vote
1answer
53 views

Control evaluation for functional constraints

I'm trying to understand how to use Mathematica to find a solution subject to constraints, where one of the constraints is specified as a predicate function. But I don't know how to control evaluation ...
0
votes
0answers
28 views

Evaluating function of two variables inside NMinimize with respect to second argument

Consider three functions: f[t_, 1] := {Cos[t], 1, 0} f[t_, 2] := {Sin[2 t], 1, 0} f[t_, 3] := {Cos[t - 2], 1, 0} For each $k=1,2,3$, let $g(\cdot,k)$ be the ...
0
votes
0answers
20 views

How to set attributes for f[x_][y_]? [duplicate]

This doesn't hold expr: ...
4
votes
1answer
69 views

Refer to OptionValue externally without a specific function name

I want to refer to the actual option values of a function f outside of f, using OptionValue. ...
3
votes
1answer
91 views

How does MMA return an unevaluated expression on errors without going into an infinite loop? [duplicate]

Post-answer note: this question is (understandably) marked as a duplicate, and indeed has a similar solution, but is subtly different in focus: the linked question is about returning a function call ...
0
votes
0answers
54 views

A function that maps Held symbol to string

Rougly my question is about constructing a function that maps Hold[var] to "var" even when var has an assigned value. In details : ...
1
vote
2answers
114 views

Making an expression to Iceberg-like object?

Can we construct a function Iceberg, which maps a given expression X to Iceberg[X] satisfying 1. and 2. and 3. ? 1. From Iceberg[X], it is not possible to inspect/extract a part of X with usual ...
0
votes
0answers
44 views

Best way to simplify a polynomial before making it the body of a function?

So, I'm dealing with iterated polynomials of a single variable—say they're anonymous functions labeled as $p_i$, i.e. p[1], p[2],...
0
votes
0answers
35 views

Inactivate Prints inside function?

If one has a piece of code with some prints, he can inactivate them using inactivate, like Inactivate[Print["test"];,Print]; (*returns nothing*) Hower, I ...
0
votes
1answer
76 views

Is it possible that the following pde be NDSolve-d?

I am working on an HJB recently and wish to get a numerical result. Can NDSolve on Mathematica 12.2 handle this? $$ V_t+(e^{-\sqrt{t}}+0.4e^{-2.5t}+0.01x)V_{x}+1.12e^{-2t}V_{xx}=\frac{1}{2}e^{-3t}\...
7
votes
1answer
148 views

How to write a simple interpreter / DSL with Wolfram Language?

I am specifically trying to write an interpreter for Mathematica predicates to MongoDB aggregation stages, but I wanted to phrase the question a bit more generically because I can see many times one ...
1
vote
1answer
56 views

Inactive and simplify does not work [duplicate]

Consider the following code: Simplify[Conjugate[Inactive[cn][n, nAvg]], Assumptions -> Inactive[cn][__] > 0] If you run it, it will not simplify, i.e ...
1
vote
0answers
77 views

Speeding up value reassignments in ParallelTable

I am solving a differential equation of two closed functions using ParallelTable. For the attached code, I thought the computation time should be approximately proportional to ...
6
votes
2answers
162 views

Extract held value from Association

Consider an association which contains a key which must not be prematurely evaluated. assoc = <| key :> value |> For example, a value of ...
7
votes
1answer
126 views

How to define a version of Table[] which localizes iteration variable by Module[]?

For reusable code it's good practice to use Module[] to localize iteration variables used by Table[], as explained by this post. ...
2
votes
0answers
40 views

Hold parents of ArcTan

If this question is beating a dead horse about Hold, Inactivate etc., a close vote is fair enough. That being said, I'm curious ...
1
vote
2answers
49 views

Applying a particular rule to a held (or unevaluated) function

I am a very novice Mathematica user and still can't get my head around its evaluation control, all possible constructs related to it (e.g. Hold, ...
1
vote
3answers
59 views

How to set a value to the symbol denoted by a given string? [duplicate]

The code setString[name_String, value_]:= Evaluate[Symbol[name]] = value fails whenever Symbol[name] has already been assigned ...
5
votes
1answer
98 views

Extracting n-th part of an expression without any evaluation

Is it possible to extract n-th part of an expression as a string, without any evaluation? For example, ...
0
votes
1answer
124 views

ReplaceThen and ReplaceAt - Cross between ReplacePart, Replace, and Extract — Request for Comment

REWRITE: Multiple edits were hurting clarity Overview: I'm doing some work involving injecting code into held expressions, and found that I was repeating myself in a couple areas related to the ...
4
votes
0answers
99 views

DynamicModule Error when assigning Nothing to variable

Assigning Nothing to a variable inside Module works as expected: ...
0
votes
1answer
82 views

Combination of Block and With - Unexpected results

I'm trying to use Block to prevent a function from executing. In this example, the function I'm trying to block will simply be ...
0
votes
2answers
69 views

Hold `outermost layer` of expression

In pursuit of a function to force unsimplified fractions forceden[x_,d_]:=Hold[Evaluate[Numerator[x]d/Denominator@x]/d]; There are many related functions (...
1
vote
1answer
72 views

Exploring curl of a gradient of a scalar function

Suppose I want to explore $\nabla \times \nabla V$ where $V$ is some scalar function. It basically results in a zero. But I would only know why if I solve it on paper. I wanted to use Mathematica for ...
0
votes
1answer
49 views

How to instruct internal function to evaluate arguments only after numerical values are plugged in?

For convenience, let me start with a simple example. The following code calculates the sorted eigenvalues of a 4x4 Hermitian matrix with a parameter x ...
3
votes
1answer
53 views

How to force Mathematica to output a function using its alternate pretty form when using Apply? [closed]

By default, Bra is an undefined function. Let's say I have defined Bra, Bra[a___]:=... such ...
3
votes
0answers
38 views

How to stop Quantity from evaluating

I'm trying to get an expression to display, without it evaluating it's internal arguments, but for some reason, when given the Quantity function, HoldForm doesn't seem to do what I expect: Code ...
1
vote
0answers
59 views

Avoiding the memory requirements of an accumulation of returned Nulls (etc)

There is an extensive but relatively old answer to a similar question here, and there are many Qs and As about avoiding using Table where possible. My problem is a mixture of the two: I have been ...
2
votes
1answer
48 views

How to “Hold” variables assigned value inside DSolve?

Consider the following ODE: a = 0.8; b = 8; v = DSolveValue[{ u[x] == a*(b* u'[x] + u''[x]), u[4.925] == 4, u'[4.925] == 0.625 }, u[x], x] which gives ...
0
votes
1answer
64 views

Hold the value of a variable

This is my code xyzzy = 1; Hold[xyzzy] // ToString // StringLength The output is 11. This 2nd one below. ...
5
votes
3answers
233 views

HoldForm does not prevent evaluation

I'm still relatively new here, and I'm not a native speaker. I hope, I don't make any obvious mistakes when asking this question. For instance, I simply had no idea how to title it accurately. I'm ...
2
votes
2answers
80 views

How to get the symbol name of a list element?

Let's say we have a list g with variable d as its element: Clear[g, d] g = {1,2,3,d} Now <...
0
votes
1answer
45 views

why mathematica Holds the Solve on the set of equations in the diagonal a matrix?

Say I have a simple function F[x_, y_, z_, r_, a_, b_, c_, d_] := (1 - a + b - (b/3) (c x + d (y + z + r))) x And I want to solve the set of equations given by: <...
1
vote
1answer
57 views

Order of evaluation

I am having a hard time figuring this out: ( sample ) I have any matrix which can have an arbitrarily large dimension. ...
1
vote
1answer
36 views

Extracting name of symbol (variable name) from within a function not working

Abstract: I use a pattern so often that I needed to make a function for constructing it. A function getName[...] for extracting name of variable and value only ...
2
votes
1answer
85 views

How to use the SymbolName of variables along with Map and pure function

I want to label each point of a Graphics3D with the simplest method as possible. I tried many solutions like this : ...
1
vote
0answers
38 views

How to return a variable name and value from within a self-contained function block?

Abstract: I have viewed other solutions on StackExchange but none actually address using a fully self-contained function to return name and value of a variable. The only function that works requires ...
5
votes
1answer
91 views

head of a sequence

Why does Head[Sequence[b, c]] return c[Symbol] and not Sequence? Why does ...
2
votes
2answers
80 views
1
vote
2answers
85 views

Releasing multiple nested Hold in a single expression simultaneously

Trivia: I need to take a coefficient list of a long list of complicated expressions of the form $\prod c_{ij} \left( p_{i,j}(x_1,x_2) \right)^n$ where $n$ is positive integer, and $i,j$ label ...
1
vote
1answer
50 views

The number 1 evaluates inside HoldForm sometimes

If I run the following code: ...
1
vote
2answers
49 views

Evaluating part of an expression, but delaying the rest

Say I have an expression g = x^2 + y^3; I tried writing this H[x_, y_] := Eigenvalues[Evaluate[{{0, g}, {g, 0}}]]; The ...
2
votes
1answer
101 views

Problem calling function defined with HoldFirst

V 12.1 on windows. I am trying to use nice function from a recent post How to directly get the TeXForm of each steps from Rubi? ps. to run MWE code below, requires Rubi package, which if you do not ...
0
votes
1answer
44 views

SetDelayed using local variables

I'm trying to define MakeBoxes for a bunch of functions all at once, but wish to do so within a loop as in the following example: ...
3
votes
1answer
56 views

Hold all the symbols from a huge list?

The two following codes work similarly: Num = 5; symbols = Hold[X1, X2, X3, X4, X5]; or ...
1
vote
0answers
35 views

How to replace expressions in a `HoldComplete` and then evaluate them? [duplicate]

Example: ...
0
votes
1answer
58 views

Keeping equations in terms of specific variable

I'm new to Mathematica and really struggling with something seemingly simple. I'm trying to do an integration and keep the results in terms of the symbol $T_1$ and $A_i$: $$ T_1=\frac{\text{pi} A_i}{...
1
vote
1answer
35 views

Help with Evaluation controll/hold all attributes?

I'm making a sort of symbolic derivator, which needs to take its formulas in unevaluated form. ...
2
votes
2answers
58 views

Evaluation Control for interpolating functions

I would like to find the root of the third component of an interpolating function, here e.g. a BezierFunction p: ...

1
2 3 4 5
7