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

learn more… | top users | synonyms

6
votes
2answers
158 views

Nothing appears in simple plot

I'm trying to get the following simple code to work. (The code is just supposed to graph the norm of the second derivative of a vector function). ...
5
votes
1answer
144 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 ...
7
votes
3answers
212 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
87 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
130 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
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 ...
0
votes
0answers
38 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 ...
1
vote
2answers
125 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
36 views

Number precision in a list [duplicate]

I have list with elements: ...
0
votes
1answer
93 views

Evaluate integral of a series

I want to evaluate this integral, but it won't work. Does anyone knows why? ...
2
votes
2answers
72 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 ...
0
votes
0answers
89 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
79 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
38 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: ...
3
votes
0answers
168 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 ...
2
votes
1answer
192 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
223 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
75 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: ...
8
votes
1answer
155 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
65 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 ...
2
votes
2answers
86 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? ...
0
votes
0answers
48 views

Dynamically Update Inset within Graphics with RunScheduledTask

I followed the instructions given below to play with RunScheduledTask within DynamicModule. ScheduledTask with scoped ...
1
vote
1answer
45 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. ...
3
votes
2answers
131 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 ...
12
votes
2answers
106 views

Why the Block command does not forget the $ContextPath variable

I do not understand this behavior: ...
9
votes
2answers
294 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 ...
11
votes
4answers
261 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
1answer
43 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 ...
4
votes
2answers
63 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. ...
0
votes
2answers
73 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: ...
1
vote
0answers
78 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-> ...
3
votes
1answer
82 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 ...
0
votes
1answer
98 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
91 views

Why does $Failed have attribute HoldAll?

Why does $Failed have attribute HoldAll? Are there typical situations where $Failed is ...
12
votes
2answers
144 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, ...
1
vote
0answers
55 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
216 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
0answers
38 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 ...
0
votes
1answer
183 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
57 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
124 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: ...
3
votes
2answers
136 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
118 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
173 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 ...
2
votes
2answers
127 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
1answer
118 views
-3
votes
2answers
91 views

Find the value by using FindRoot command [closed]

The equation x^4-3 x^3 = cos(3x)+3 has two real solutions on the interval from -10 to 10. Lets call these two solutions r and s. Use Mathematica's FindRoot command to find r and s. Now let M equal the ...
6
votes
1answer
59 views

How to reset the $ModuleNumber?

According to the documentation, we can reset $ModuleNumber to a positive machine integer. There is even an example in the doc: ...
2
votes
1answer
124 views

Order of operations, precedence in Mathematica [duplicate]

I get confused in the order of operations in Mathematica. For example, f /@ 10^{1, 2, 3} {10, 100, 1000} In my head, that ...