# Linked Questions

62 questions linked to/from Replacement inside held expression
2answers
1k views

### How to inject an evaluated expression into a held expression? [duplicate]

I know that there are methods to structurally manipulate held expressions (discussed e.g. here), but I failed to apply those for this particular problem: ...
1answer
1k views

### How to evaluate some parts of an expression inside Hold? [duplicate]

I want to return a Hold expression but with some parts pre-evaluated. The easiest way to explain this is probably through code example. Here is what I have ...
0answers
121 views

### How to substitute inside Hold? How to create table of summation (with Sigma symbol) expressions? [duplicate]

I would like to create table of summation expressions, which are not evaluated, but summation limits are substituted. I can't accomplish this so far. If I write I get summation expanded. If I ...
0answers
58 views

### Purpose of construct With[{var=myComputation[…]}, var/;True]? [duplicate]

Could someone please give an illustrative example showing the purpose of construct of form With[{var=myComputation[...]}, var/;True]? Also, I wonder what kind of ...
0answers
49 views

### How does the code idiom for replacing part of a held expression work? [duplicate]

I've seen this idiom used in different programs but never fully understand why it is necessary. Could someone explain? Is it still the recommended way to replace some part of a held expression to its ...
19answers
135k views

### Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
7answers
1k views

### How to display very small numbers in Mathematica?

I am trying to evaluate the function: $$f(x) = \cos(x) - \mathrm{e}^{-2.7 x}$$ at $x = 1.7 \times 10^{-25}$ and Mathematica keeps returning '0.' How do I evaluate the expression in a better way?
2answers
2k views

### What are all the “magic” Symbols in the Mathematica language?

Leonid Shifrin once wrote (excerpted): (Unevaluated) is one of a very few "magic symbols", along with Sequence and ...
5answers
629 views

### Is it possible to construct a fullform trace function

Is it possible to construct a FullFormTrace function that takes an arbitrary expression and prints a sequence (or returns a list) of the evaluation steps in full ...
3answers
871 views

### Generating assignments and transforming code inside held forms when generating code

I have been playing with slightly above trivial code manipulations in Mathematica. I thought Mathematica would be great for this kind of work because of rule replacement and expression manipulation, ...
4answers
548 views

### Replacing parts of a held expression with held parts of another expression

I'm applying the Trott-Strzebonski technique in order to replace inside a held expression. ...
2answers
1k views

### Does Set vs. SetDelayed have any effect after the definition was done?

I was always assuming that the only difference between Set (=) and SetDelayed (...
4answers
277 views

### Hold expression with RandomInteger

One more question for today: I'm trying to show two random integers with a plus (+) sign between them, in an unevaluated form. I know how Hold and HoldForm work, but they hold everything, including ...
4answers
305 views

### Is it possible to separately call the default value of a variable which isn't at the end of the sequence?

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function: ...
1answer
909 views

### Is this a bug in Replace?

Consider the following minimal examples. This one works as expected, replacing trees starting from the inside with a numerical value. ...
1answer
1k views

### How to solve the tsunami model and animate the shallow water wave?

Backslide introduced in 9.0, persisting through 11.3. Recently when I was learning differential equations, I noticed there is a shallow water wave equation to model the tsunami propagation. How to ...
3answers
569 views

### Why x = x doesn't cause an infinite loop, but f[x_] := f[x] does?

If I execute: In[1] := x = x Out[1] = x and then I evaluate the symbol x: ...
4answers
489 views

### partial numerical evaluation

Context The following is an issue I have come across many times and still do not have a satisfactory solution for. The context of it is this. Let's say we have an equation, a linear ODE for the ...
2answers
475 views

### Why can't I inject expressions in Compile using (only) With

Generally speaking, With can be used to inject into arbitrarily held expressions, for example: ...
4answers
3k views

### Replace symbols with values without evaluation

If I have assigned values to a, b and c: a=7; b=5; c=6; ...
3answers
453 views

### Obtaining the number of iterations used in ReplaceRepeated

ReplaceRepeated has an option MaxIterations which indicates Mathematica is keeping track of the number of iterations. Is there ...
3answers
389 views

### How can I break through Function's HoldAll attribute to force evaluation of a body element?

The question concerns creating a function. Let consider the following code With[{f = Function[t, Cos[t]]}, {First[#], f'[#]} & ] which returns ...
4answers
226 views

### How to Force Evaluation of Derivative in a Pure Function Definition

Let's say I have a function f1 = #^2 &; I want to calculate its derivative, perform some manipulations and make the result a pure function. I try ...
1answer
278 views

### Pattern matching to a function evaluation inside an Association

I find the following behaviour deeply counter-intuitive: <|1 -> 123.456 |> /. {x_?NumericQ -> Round[x]} (* <|1 -> Round[123.456]|> *) That ...
3answers
248 views

### why does Function have the HoldAll attribute?

Consider the following: f = 2 # & OwnValues[f] g = f[#]/2 & OwnValues[g] Since Function has the ...
3answers
229 views

### Apply function to nested associations

This seems like it should be easy but I am trying to concisely enhance some nested associations with Mathematica objects (e.g., convert things to matrices, etc) but I'm having a bit of difficulty with ...
1answer
699 views

### Free Convective Heat Transfer of Non-Newtonian Power Law Fluids from a Vertical Plate

I am trying to solve a set of PDEs mentioned in this paper with NDSolve but facing quite a few issues. The PDE system is: ...
2answers
420 views

### How to copy formatted numbers as MathML without quotation marks?

I have the following code: a = 6.08717*10^6; b = a/3; c = a*1.5; d = a^2; matrix={{a, b, c, d},{b, c, d, a},{c, d, a, b},{d, a, b, c}}; matrix // EngineeringForm ...
2answers
315 views

### How to sort arguments of Times in nonstandard order?

Is there an elegant way to sort the arguments of Times in e.g. TraditionalForm so that factors go to the front and state ...
2answers
366 views

### Evaluate Only Part of a Function

I have a list of functions, each containing none or more of the functions Plus, Times, ...
3answers
342 views

### HoldForm: how does it interact with nested evaluations?

Here's an example to illustrate the issue I'm having. right = 8 - y; left = y^2 + 6; integrand = HoldForm[Evaluate[right]] - HoldForm[Evaluate[left]] (I ...
2answers
239 views

### Puzzled regarding avoiding evaluations and using results of computations as functions

What did I do before? I seem not to be able to understand MMA's evaluation scheme. I read some posts like Preventing Evaluation or a MathGroup post where the topics of evaluation prevention are ...
2answers
218 views

...
2answers
143 views

### How to use ReplaceAll and RuleDelayed with an Association? [duplicate]

I expected that something like this ...
3answers
187 views

### Replace inside a Held expression separate context

How do I replace content inside a Held expression without local values coming through? For example if you run the following code you get g[2] instead of ...
3answers
230 views

### Replace variable with value prior to evaluating NIntegrate

The title says it all. Reading posts such as this however, I'm not seeing how to do this. This is the simplest example that can show my problem. ...
1answer
245 views

### Instability, Courant Condition and Robustness about solving 2D+1 PDE

After several discussions, I would like to focus on the robustness of solving 2D+1 PDE by considering all suggested methods from @xzczd (see here) I found that the Ratio between the convection term ...
2answers
439 views

### Condition and RuleDelayed

On this site I found, for example here, some very interesting questions and answers on the use of delayed rules with conditions. I would very much like to understand these answers, but so far I failed ...
3answers
204 views

### How I create a 'TraditionalForm' expression in which only parts are evaluated?

I have an expression for the form Subscript[W, f[a, b]][c] = ρ^f[a,b]ω[c]ρ^-f[a,b] that I want to render in TraditionalForm ...
1answer
909 views

### Collect and simplify both the coefficents and the matched patterns

(This is a far tighter version of a previous question I asked) The problem with Collect is that while Collect[exp, pattern, Simplify] will simplify the coefficients,...
1answer
197 views

### KeyValuePattern in matching and replacement in nested associations

This case revealed I am missing something in pattern matching and evaluation in case of match, or I can't grasp it due to the busy week I have. Either way, I find this problem interesting for wider ...
2answers
175 views

### Is Replace doing double work?

In an answer to this question, rm -rf used the function Replace with level spefication to do a series of replacements inside out. As far as I can see, the order of substitutions when more than one ...
1answer
1k views

### Pass unevaluated function with evaluated arguments

I am almost sure that this question has been asked somewhere. I found similar ones, but I cannot find exactly what I need, which might mean that I am on the wrong track. I search a method to pass an ...
1answer
248 views

### different situations with Compilation of ConstantArray

First, we load some tools related to Compile for analysis. ...
3answers
145 views

### How to pre-evaluate parts of a lambda or a delayed-assigned function?

I have an expression which I'd like to evaluate and use as a subexpression of a delayed-assigned expression. But I need it to be evaluated before actual assignment, while other parts of the full ...
1answer
162 views

### Pattern matching and HoldForm

Create rules based on data. I have a system that picks out on date,based on some rules. I then want to generate a new rule based on this date and apply the rule to a new dataset. ...
1answer
159 views

### Can I release a pattern without releasing the whole held expression?

I would like to release only the rules in an expression that held. Is that possible? ...
1answer
158 views

### Problem Using Evaluated Replace with Associations

If I define some function like: toISOdate[data_List]:=DateString[data,{"Year","-","Month","-","Day"}] and try to applicate it in an ...
1answer
200 views

Executing: ...
1answer
115 views

### Generate pattern held by HoldPattern

I am trying to match expressions that have factors with certain exponents. For instance, I would like to match as follows ...

15 30 50 per page