Questions tagged [evaluation]
Questions about how Mathematica evaluates expressions, tracing evaluation (Trace*), handling expressions in unevaluated form (Hold*, Unevaluated), nonstandard evaluation, etc.
1,637 questions
149
votes
7
answers
191k
views
Get a "step-by-step" evaluation in Mathematica
Is it possible in Mathematica to get a step-by-step evaluation of some functions; that's to say, outputting not only the result but all the stages that have led to it? If so, how does one do it?
...
112
votes
4
answers
18k
views
Plot draws list of curves in same color when not using Evaluate
This example comes from
the Mathematica documentation for Plot
under Basic Examples.
Can someone please explain why these are each plotted as a different color in ...
107
votes
5
answers
7k
views
Replacement inside held expression
I wish to make a replacement inside a held expression:
f[x_Real] := x^2;
Hold[{2., 3.}] /. n_Real :> f[n]
The desired output is ...
96
votes
6
answers
5k
views
The clearest way to represent Mathematica's evaluation sequence
WReach has presented here a nice way to represent the Mathematica's evaluation sequence using OpenerView. It is much more clear way to go than using the standard <...
70
votes
10
answers
4k
views
Injecting a sequence of expressions into a held expression
Consider the following toy example:
Hold[{1, 2, x}] /. x -> Sequence[3, 4]
It will give
Hold[{1, 2, Sequence[3, 4]}]
...
68
votes
4
answers
6k
views
How do I evaluate only one step of an expression?
I am looking for a simple, robust way to evaluate an expression only one step, and return the result in a held form.
The definition of a single step is ambiguous, and this itself is probably worthy ...
59
votes
6
answers
7k
views
Why doesn't Mathematica abort evaluation when I tell it to?
This frequently happens to me. I'll have some code, execute it, and realize it's taking a long time. My PC isn't frozen, and Mathematica itself isn't even frozen: I can select stuff in the notebook, ...
57
votes
2
answers
3k
views
How do you set attributes on SubValues?
SubValues, as discussed in a previous question, are declared as follows
...
51
votes
6
answers
5k
views
How to create symbols from strings and set values for them?
I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to ...
45
votes
2
answers
8k
views
Difference between AbsoluteTiming and Timing
I need to evaluate the efficiency of my code. Therefore I would like to evaluate the time the code need for some calculations. Mathematica gives me two possibilities for this kind of evaluation:
<...
42
votes
4
answers
3k
views
Interrogating a running evaluation
Is it possible to find the values of variables of a running Mathematica evaluation, without interrupting it? For example, suppose I do:
Do[Pause[1]; a++, {50}]
...
40
votes
3
answers
9k
views
Can Mathematica do two evaluations at the same time?
When one evaluation is running, if I want do another evaluation, Mathematica will put the second one in the queue and run it after the first evaluation finish. However, the first evaluation may take ...
40
votes
4
answers
2k
views
What is the difference between Dynamic[x] and Dynamic[ h[x] ] for DynamicModule variables?
Bug introduced in 9.0 or earlier and persisting through 12.0
In 11.3 it is even worse. An example from the accepted answer with a Slider is now broken too:
...
37
votes
3
answers
1k
views
Can we intelligently control evaluation in Thread?
This is a bid at creating a canonical Q&A.
Many questions have been asked that come down to the fact that Thread evaluates its first argument before threading ...
36
votes
1
answer
4k
views
How does Return work?
It is not completely clear to me how Return[] works.
The documentation says:
Return[expr] returns the value expr from a ...