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
7answers
206 views

Obtaining the terms of a summation alongside the result

I have a Sum expression: s := Sum[2x,{x,0,3}] As an exercise to explore the rewriting capabilities of the Wolfram Language, I ...
0
votes
1answer
43 views

Through does not have hold attribute?

Possibly Related to Unexpected behavior of KeyTake. Consider the following example, where I input #11 (last) is the misbehaving one. Am I missing something or do you agree there is a bug? ...
1
vote
1answer
25 views

Import expressions from a file without it getting evaluated?

How can I import a file without its expressions being evaluated ? E.g. assume that the file "test.m" contains just the list {a, a + b + b + c, d} If I use <...
0
votes
0answers
36 views

After activating, inactive integral, output is coming same as input

I am trying to plot s w.r.t r (0,10). But because of inactive integral I am not able to. When I activate inactive integral, output is coming same as input. When I am trying to plot graph w.r.t r(0 to ...
3
votes
1answer
35 views

Prevent argument substitution in held expression when injecting into unevaluated code

I want to write a custom sow/reap pair to wrap any piece of code in sow[code] and call reap ...
0
votes
0answers
43 views

Evaluation control inside Compile

I have the following function ...
3
votes
2answers
84 views

Construct a function that maps strings to functions

The main question is the last 5 lines (including codes) of this article. A[x_, y_] := Evaluate[ToExpression["x^2+y^2"]] A[3,4] Then the output becomes ...
2
votes
2answers
37 views

Plot[Evaluate[compiled functions… causes problems

I'm sure there is an easy solution to this, but I have beaten my head against a wall for a couple of days, so I hope someone can help. I have compiled functions. For a minimal example let's take: <...
14
votes
3answers
279 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
47 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
54 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
91 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
85 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
84 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
69 views

Unnecessary error messages

...
2
votes
1answer
32 views

Element of list not evaluating derivative after I define function

I have the following code ...
2
votes
3answers
103 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
42 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
38 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
76 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
61 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
48 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
2answers
78 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
124 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: ...
10
votes
2answers
211 views

How to explain the behaviour of TreeForm? [duplicate]

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
98 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
53 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
84 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
28 views

Keep only bit of an expression unevaluated for display

Consider the code ...
1
vote
0answers
43 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
95 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
180 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
44 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: ...
7
votes
5answers
423 views

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

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
123 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
84 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
258 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
55 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
102 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
181 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
43 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
48 views

InitializationFunction for TemplateObject

Shortly, I want something like this to work: ...
1
vote
1answer
60 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
99 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
86 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
105 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
149 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 ...