Questions about how Mathematica evaluates expressions, tracing evaluation (Trace*), handling expressions in unevaluated form (Hold*, Unevaluated), nonstandard evaluation, etc.

learn more… | top users | synonyms

4
votes
1answer
83 views

Resume/continue interrupted evaluation

I interrupted an evaluation to quickly do something else. How do I resume the interrupted evaluation? I cannot open the "Interrupt evaluation" window, as it is disabled. There is no "Resume" button to ...
5
votes
5answers
285 views

Efficiently finding the positions of a large list of targets in another, even larger list

I have a big list. It contains nearly 60,000 sub-lists. It's structured like bigList= {{x1,y1,z1},{x2,y2,z2},{x3,y3,z3},.....,{x60000,y60000,z60000}}; ...
6
votes
3answers
187 views

Graphics in Notebook Different from Graphics Expression?

Consider the expression TreeForm[a+b^2+c^3+d] which displays as This is a nice Graphics object, as I can prove by typing ...
0
votes
1answer
69 views

Why does evaluating an integral within a Plot expression take so long? [duplicate]

I want to evaluate Plot[Integrate[Sin[((1 + 1/2) x)] (1/(2 Sin[(x/2)]) - 1/x), {x, 0, t}], {t, 0, 5}] but it takes ages to load on Corei3 computer with ...
8
votes
2answers
124 views

Half-delayed evaluation

In a certain wider context, I need to make some delayed definitions, such as x := a + b + c, but within these definitions I want ...
0
votes
0answers
37 views

Notification when evaluation completes [duplicate]

I thought it would be fun to see a list of ways to have Mathematica notify you when a long evaluation completes. There are a few posts up already that address specific methods, given below, but not ...
0
votes
0answers
30 views

RandomReal behavior in Block environment [duplicate]

I ran into an unexpected behavior of RandomReal function inside the Block environment. If I simplify my problem: I wanted to use two random local variables, such that the second one would be less that ...
1
vote
1answer
134 views

How to tell Mathematica not to simplify an expression

While there is this question with a very similar title, it does not answer my question, which is: I have part of an input, in my case Re[Exp[I*x]] which ...
0
votes
0answers
83 views

How to modify the file “KeyEventTranslations.tr” to use Enter to evaluate the current cell? [duplicate]

I asked the following question before, but I do not think it has been fully answered. By default, we use Shift+Enter to evaluate the current cell, and use Enter to get a new line. Is there a way ...
1
vote
2answers
85 views

How to evaluate Modules in a notebook from another notebook?

I would like to create a notebook populated with several modules and be able to evaluate these modules by running a separate notebook. I have attempted several uses of the ...
0
votes
0answers
35 views
11
votes
1answer
238 views

What is the real default CellEvaluationFunction?

The default CellEvaluationFunction is Identity but one can quickly see that this is handled specially as an equivalent function, ...
50
votes
5answers
22k 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? Example : Let's say I want to ...
3
votes
0answers
164 views

A design of abstract data structures: How robust is the presented design? [closed]

EDIT: An envisioned answer to this post should be in the form of a mathematica code that can demonstrate how the internal checks discussed below can be bypassed. Everything goes... On my part, I think ...
0
votes
1answer
89 views

Evaluate integral of a series

I want to evaluate this integral, but it won't work. Does anyone knows why? ...
2
votes
2answers
69 views

Can I have Mathematica show intermediate forms before final evaluation?

If I have x = 2 and I want to evaluate y = x^2 I would like to the output to show ...
10
votes
3answers
200 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. ...
1
vote
2answers
76 views

Extract the real components from a very large expression

Suppose I have a very long expression (>500,000 characters) which contains a mixture of real and imaginary terms. e.g ...
2
votes
1answer
36 views

is there a way to construct a pattern that would trigger when an expression is used as a held/unevaluated in some form?

For example, consider the following code f[x_] := (Print["evaluated f"]; workWith[x]); We use it, then f evaluates: ...
4
votes
1answer
131 views

Selecting expressions from a sequence that are not subexpressions of earlier elements

I have a While loop that generates and prints an expression on each iteration (there can be thousands of iterations). UPDATE: Some expressions are generated in ...
2
votes
1answer
175 views

Nested Derivative

These two expressions are mathematically the same, but when substituting with the same rule, yield different results. What is happening? ...
2
votes
2answers
65 views

Integrating a Simple Piecewise Function

If I define f[x_]:=If[x<0,-1,1] and then integrate,say Integrate[f[x],{x,-3,7}] I get what I expect, namely 4. But ...
3
votes
1answer
67 views

Where do Mathematica's probability functions draw a line in the sand for predicates?

Thinking about a recent question mis-posted here (belonged on math), I noted the following. A contrived example - probability that a or b are 1: ...
2
votes
2answers
81 views

Merging two held expressions into a held compound expression

Consider e1 = Hold[a = x + x; b = y + y + y]; e2 = Hold[c = a + a + b + b + b; c^2]; How can I obtain the following? ...
8
votes
1answer
130 views

Why does Plot[Hold[x], {x,0,1}] work?

It appears that, counter to my expectation, all of these (and probably many others) seem to work fine: ...
2
votes
0answers
63 views

Assign a value to a variable without using Set or SetDelayed?

I supose probably yes, but at the end I assume that internally mathematica has to use Set or SetDelayed. Am I right? Background: I am developing a super simple phraser that takes a code description ...
1
vote
1answer
38 views

Commutative algebra by generators and quadratic relations

My apologies if this has been asked before. Please also be gentle, as this is my first question here. I am trying to define a commutative algebra by generators and relations in the following way. ...
0
votes
0answers
42 views

Dynamically Update Inset within Graphics with RunScheduledTask

I followed the instructions given below to play with RunScheduledTask within DynamicModule. ScheduledTask with scoped ...
3
votes
2answers
114 views

Stopping a head from evaluating more than once

While attempting to answer my own question, Is there a way to "hold" prefix / infix / postfix notation?, I came across the need to evaluate a recursive function only one level deep. For ...
9
votes
2answers
286 views

How to see which arguments are passed into a function

It is often that one wonders which arguments are evaluated before being passed into a function. I would like to know if it is possible to see which argumets are being passed into a function without ...
12
votes
2answers
92 views
4
votes
1answer
49 views

With command does not behave as expected according to its Attributes

The attributes of the With command are HoldAll which means it should not evaluate its arguments before its starts its business. ...
1
vote
1answer
42 views

Cell seems to be evaluating in exponential time even though it shouldn't

I am trying to implement Newton's method for a given function f[x] and a starting x-value xval. The code should print out each new x-value as it approaches one of the zeroes of the functions. g[x] is ...
12
votes
2answers
132 views

How to find out what files are touched when Get is called?

Is there a way to capture all package files touched whenever a package is called via Get, Needs, ...
0
votes
2answers
54 views

Defining Piecewise Functions in Modules

In short, my question is the same as my previous one except that everything is now wrapped up in a module. The relevant code I'm working with is: ...
3
votes
1answer
74 views

How to calculate the residue of $1/f(z)$ at a numerical approximation to a root of $f(z)$?

The input Residue[1/DirichletL[19,10,s],{s,s0}] gives 0 even when s0 is a root. For ...
1
vote
0answers
57 views

Is there a way to stop evaluation immediately?

Sometimes I'll have a loop that I accidentally made too big. I'll evaluate, and MM will try to run through the entire loop. The program itself doesn't actually seem frozen... I can go to Evaluation-> ...
6
votes
2answers
95 views

Partial result of aborted evaluation of FullSimplify

When FullSimplify invoked on a large expression, it can run for hours. If I do not have time to wait, and abort the evaluation, I get no result, although, ...
0
votes
1answer
93 views

Symbolic vs. numeric evaluation is incorrect [closed]

In Mathematica 9: I have two functions f[v] and g[v]. When I do f[g[0]], I get the correct ...
9
votes
1answer
86 views

Why does $Failed have attribute HoldAll?

Why does $Failed have attribute HoldAll? Are there typical situations where $Failed is ...
2
votes
2answers
100 views

Generating an editable table that can be used as input

Say I have a number $n_{max}$. I want a command to generate a table like 1 1 2 2 3 3 4 4 ... nmax nmax where the second column is editable, and this table can be ...
1
vote
0answers
51 views

How to extract a variable names (not values) from a list of transformation rules?

I am trying to extract variable names from a list of transformation rules mapping = {var1 -> 'val1', var2 -> 'val2' }. Variables ...
2
votes
1answer
165 views

Why does Mathematica evaluate Sin[2.0] but not Sin[2]?

I can't understand why is it that In[88]:= Sin[2] Out[88]= Sin[2] while In[89]:= Sin[2.0] Out[89]= 0.909297 I even tried ...
0
votes
1answer
118 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 ...
0
votes
0answers
35 views

Faster evaluation of an expression for brute force optimization [duplicate]

I'm trying to bruteforce an optimization problem and I want to generate roughly a million function evaluations. I was wondering what would be the best for me to do in terms of having the expressions ...
3
votes
2answers
113 views

How to define the irrational domain or any other arbitrary domain?

I have found no way to define the domain of Irrational numbers. I can easily define a test to see if a number is irrational by defining: ...
0
votes
0answers
42 views

Evaluation - separate Output window + not evaluate particular cells

is it possible to avoid that mathematica writes the output into the nb file? I would prefer that mathematica writes the output into a separate file. If it writes into the notebook (I usually use: ...
3
votes
2answers
123 views

Bare symbol invocation fails but not if used with an argument

How to achieve the following behavior on a symbol f? Background: The main goal is to use the symbol to tag an abstract data structure where downvalues are used to store information. Only defined ...
1
vote
2answers
85 views

Converting expression into string without evaluating it

How can one convert a Mathematica expression into a string without the expression being evaluated first? I tried using Hold, but it returns ...
6
votes
2answers
162 views

Evaluation in lambda function

If I have a function, that returns a function, for example: f[a_] := a^2 * # & then f[3] == 3^2 # & Is there a way ...