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.

2
votes
1answer
35 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
56 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
53 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
42 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
114 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
182 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
91 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
51 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
77 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
40 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
58 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
37 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: ...
5
votes
3answers
357 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
113 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
72 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
249 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
52 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
85 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
50 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
113 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
47 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
79 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
63 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
69 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
141 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
124 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
54 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
71 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
222 views

How to take a part from a list without evaluating it

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

Button action evaluation [duplicate]

An example of the problem I am encountering: ...
2
votes
1answer
43 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
89 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\}}\...
0
votes
0answers
53 views

Trouble with UpSet(Delayed) and IgnoringInactive

I'm having problems setting an upvalue for a symbol that is supposed to ignore Inactive: IgnoringInactive[f[g[x]]] ^:= match; ...
4
votes
5answers
243 views

How do I make $0 \times (\mathsf{anything})=0$?

I have a complicated formula which is a sum of several terms. Any given term will be a product of factors: $a_1(x)\times a_2(x)\times a_3(x)\times \ldots$, in which for simplicity I have shown that ...
0
votes
1answer
28 views

HoldForm behaviour for product of a Graph and an expression

Suppose I have a list of pairs each containing an expression and an associated Graph object: ...
6
votes
1answer
185 views

Create local alias for variable

I have a function whose parameters are passed "by reference" Clear[foo] SetAttributes[foo, HoldFirst] foo[t_] := t = 10 Is it possible to create an alias for <...
3
votes
2answers
73 views

How to set a particular element of a list to a number?

I have a list {a,b,c,d}, and I want to set the 1st element and the 3rd elements equal to 5 and 8, respectively, leaving 2nd and 4th as they are (...
5
votes
2answers
333 views

Expanding a sum without evaluating it [duplicate]

I am currently trying to expand a sum without evaluating it, e.g. $$\sum_{i=0}^5 i^2 = 1^2+2^2+3^2+4^2+5^2$$ So I am trying to create a function ...
0
votes
0answers
37 views

Imitate Integrate's behavior with regard to the integrand parameter (scoping/naming)

Using Integrate, I can do any of the following: ...
0
votes
1answer
68 views

If ValueQ is buggy, what alternative is there?

The function ValueQ has been irritating me for a while. I can't find its use for anything. Inspect the following: ...
0
votes
0answers
19 views

DialogReturn evaluated too soon [duplicate]

Why does this module return 11 (as expected) when 'Accept' is clicked: ...
1
vote
2answers
91 views

How is it possible to prevent separation of negative and positive exponents when symbolic simplifying?

As parts of my computations, I use InverseLaplaceTransform for some symbolic expressions. As an example, when I have the following transformation for sum of two ...