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
4
votes
2answers
25 views

Evaluated vs. unevaluated Association

This question might have a remote connection to my older question, it is also about sameness of expressions and subtle differences observable only in certain forms. I encountered this strange ...
4
votes
1answer
43 views

Evaluate calls my function multiple times when the function generates an error

If I execute a line of code with Evaluate I find some unexpected behavior when the code returns an error. Here is a minimal example. Let ...
1
vote
2answers
40 views

InputField with Boxes-held formatting fails inside Dynamic

This is an outgrowth of an earlier question. I have an extensive user interface that has InputFields that I want to hold their specific structure as input by the user (e.g., keeping scientific ...
5
votes
1answer
79 views

Hold[Expression] (or similar) in InputField that truly holds the input unmodified

I am trying to design a user interface where the specific form that the user enters in InputFields are left unchanged. For example, if the user puts in a number in scientific notation, it would be ...
2
votes
0answers
69 views

Non constant coefficient in heat equation

I have to solve the following heat equation over a cylindrical domain. In cylindrical coordinates the PDE Equation reads: ...
5
votes
2answers
83 views

Obtaining head and parts without evaluation

I have been trying to write a routine MyHead and MyPart which would have the following properties. MyHead[2+3] evaluates to Plus ...
1
vote
1answer
66 views

Unnecessary error messages

...
2
votes
1answer
31 views

Element of list not evaluating derivative after I define function

I have the following code ...
2
votes
3answers
102 views

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 ...
0
votes
1answer
37 views

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'...
2
votes
1answer
36 views

How can I properly use Catch[] to prevent my program from quitting?

I am getting an error depicting an Uncaught Throw, with the accompanying code being returned: Hold[Throw[$Failed, CURLLink`Utilities`Exception]] I have managed ...
0
votes
1answer
64 views

Evaluating function before its plotting

Suppose I want to plot a function $f(x,y)$ but first need to calculate its symbolic expression. An easy solution is to copy the output of my calculation by hand and then paste into ...
0
votes
0answers
57 views

Replace Integrate with NIntegrate

I have a symbolic integral with a pretty complex expression. I need it in symbolic form because I want to compute its derivative. ...
0
votes
1answer
46 views

Evaluation Control for Equation Input to NDSolve

I am trying to numerically integrate a system of equations using NDSolve and am having issues with symbolic matrix inversion taking a long time. The actual system is much more complicated, but I have ...
1
vote
1answer
54 views

Function returning a pattern with condition - how to prevent condition to evaluate prematurely?

I figured it would be convenient to have a function that returns a pattern, that match equally nested brackets, of the specified type. Such a pattern is easy to create, but I get some error messages, ...
0
votes
2answers
116 views

Mathematica puts function with certain constants on hold, why? [closed]

Here, I probably have a trivial case on how to use functions in Mathematica but I can't figure it out with the help of the Mathematica pages. I define the following function: ...
8
votes
2answers
186 views

How to explain the behaviour of TreeForm?

Just try this: g=1;a=1;TreeForm[Hold[g[a]]] The weird thing in the outcome is that the node of g displays 1 ,and a is still a. I do not know how to explain ...
4
votes
1answer
95 views

Sign of conservative convection coefficient in a formal (Inactive) PDE

Consider the PDE $$\nabla \cdot ( - \color{blue}{\texttt{c}} \;\nabla u - \color{blue}{\texttt{alpha}} \; u) = 0 \tag{std}\label{std} $$ where ...
0
votes
2answers
52 views

How to show the answer in terms of another variable

if we have A = 1; B = 44 + 1 output :: B = 45 how we can show B like this output :: B = 44 + A
2
votes
2answers
83 views

Extract unevaluated definition of function

Say I have a function f[x_]:=a x + b. Now I want to get the a x + b part from the function to use in e.g. ...
0
votes
1answer
27 views

Keep only bit of an expression unevaluated for display

Consider the code ...
1
vote
0answers
41 views

Differentiating functions of Set expressions

There are so many things in Mathematica I think I will never understand. Perhaps today there will be one fewer... B'[y]/.B->Function[y,y^2] Outputs ...
2
votes
2answers
70 views

How do you change from Traditional form to Input form?

I have something like this: Hold[TraditionalForm[1/2 + x^2]] And wish to change it to Input form with the use of code (that is, without clicking Cell > Convert ...
2
votes
1answer
45 views

Strange behaviour (or issue?) in using evaluation of held argument inside a table in Mathematica

I encountered a very strange behaviour on Mathematica using Evaluate on a held argument. Could anyone explain to me what is the subtlety (or is it a bug?) Here is the expression: ...
10
votes
3answers
179 views

Perform localized, evaluation-leak free replacements

Consider the following expression: expr = Hold[ { f[ {1, {Print@1}} ], g[ {{{Print@1}}} ] } ]; I'm looking for a way to ...
1
vote
0answers
38 views

How to use Evaluate inside function definitions? [duplicate]

How to use Evaluate inside function definition so that is acts as Evaluate only whet function is called? This is toy exampl, where I want to define function inside another function: ...
6
votes
5answers
399 views

What is the the proper way to define a function from an expression?

Say after some long computation we get an expression expr=x^2 We do not know what the value of expr beforehand. Now we want ...
3
votes
2answers
119 views

Display elementary math without evaluating

Given a list of operators and integers, for instance oper = {Subtract, Times, Plus} {a, b, c, d} = {3, 5, 4, 9} I would like to print ...
1
vote
1answer
73 views

How to stop evaluation of Zeta with even arguments

It could be a duplicate question. However I could not find much after a huge searching. I have a huge expression in mathematica involving many Zetas. I want not to evaluate the even Zetas which ...
9
votes
3answers
252 views

HoldForm: Display exactly as entered?

Sometimes, Mathematica's internal representation of expressions can give somewhat surprising results. Specifically, I noticed this when I tried to preserve products of fractions for display. E.g. ...
0
votes
2answers
54 views

Evaluation control - Hold (?) argument name not argument values

I wanted to produce a list of statistics labelled with the statistic name, for exchange with a database. I defined ...
2
votes
3answers
92 views

Globally Defining a Variable that Depends on Arguments of Functions [duplicate]

I have many delayed-defined functions of many variables, and all the functions share a term containing some of these variables. Thus, I would like to just call the term ...
3
votes
1answer
52 views

Apply on Message resolves MessageName before applying

I want to make a Message from a List. Message[LibraryFunction::argx, 1, 3] ...
2
votes
1answer
130 views

Unwanted Hold from recursive function

I am literally copying an example from a tutorial in Mathematica documentation of a recursive function, but when I evaluate I get a Hold. I don't understand why I ...
4
votes
3answers
42 views

Controlling HoldForm while mapping

If I execute A = {Sin, Cos, Tan} B = {ArcSin, ArcCos, ArcTan} #[[1]]@#[[2]]@x & /@ Transpose[{A, B}] the output is ...
3
votes
1answer
42 views

InitializationFunction for TemplateObject

Shortly, I want something like this to work: ...
1
vote
1answer
52 views

RegionPlot: building a list of inequalities

I have a function like this: Myfunction[x_,y_]:={Max[1, Min[x, 2]], Max[1, Min[y, 2]]} and I need to do a RegionPlot like ...
3
votes
2answers
87 views

Expanding powers in an expression and Hold

Let an expression like -(1/2) + (3 x^5)/2 be given. How can this be turned into -(1/2) + (3 x x x x x)/2? All powers of ...
4
votes
1answer
69 views

How to extract part of a held expression without evaluating it

How can I extract part of a held expression without evaluating it? Clear[w] Part[HoldForm[w = 3],1,1] (* w *) w = 4 Part[HoldForm[w = 3],1,1] (* 4 *) Here I ...
1
vote
1answer
89 views

Replacing one of the integrals in the multiple integral with an analytical solution

Problem consist in simplifying complicated multiple numerical integral, where I know analytical solution for a subset of them. Integrand is of the form ...
4
votes
2answers
143 views

How to customize traditional form for inactive functions?

Let's say I define Lg[n_]:=Log[2,n]. How do I make Inactive[Lg][x]//TraditionalForm output ...
0
votes
0answers
42 views

Editing the function argument

I'd like to construct a function, that changes its own input. The code ...
2
votes
2answers
62 views

Correct way to see domain of function using DownValues?

Here's a simple function g defined for the natural numbers 1 through 10: Table[g[i] = i^2, {i, 1, 10}] I now want to find the ...
4
votes
1answer
127 views

How do I make LinearModelFit flexible to number of parameters using FromLetterNumber?

I want to run LinearModelFit where the number of parameters is not fixed. For example, the following ...
0
votes
1answer
58 views

How to delay a function definition in NestList [closed]

I have a code like this. The algorithm is that the original number, 2, has some chance to either be constant 3 or to be 10 times ...
1
vote
1answer
74 views

Evaluate arguments in a curried function left to right

I have an inner pattern f[g, n_] := inner and I want to define an outer curried pattern f[h, m_][f[g, n_]] := ... which ...
3
votes
3answers
226 views

How to take a part from a list without evaluating it

Consider I have a list l ...
0
votes
0answers
53 views

Button action evaluation [duplicate]

An example of the problem I am encountering: ...
2
votes
1answer
45 views

Hold Evaluation in a MenuView or TabView

Suppose I wish to create a MenuView where the evaluation of the rules is time consuming. How would I delay evaluation of the right-hand-side of the arguments to <...
3
votes
1answer
90 views

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\}}\...