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
415 views

Behavior of expression evaluation in Plot

I'm confused with Mathematica's way of parsing expressions. I've been struggling with this for a while and never found an exhaustive answer, sometimes things don't parse the way I think they would ...
4
votes
1answer
128 views

Tweaking Prime[n] to return 1 when n==0

I manually evaluate this cell to set Prime[0] Unprotect[Prime] Prime[0] = 1 Protect[Prime] I manually evaluate this cell to reset Prime[0] ...
4
votes
1answer
108 views

How can I test properties of a symbol without unwanted evaluation

Problem How to get the head, size, dimensions, etc. of a symbol without evaluating it? Since Mathematica does not allocate fix storage space and type to symbols it is not trivial to query runtime ...
4
votes
1answer
134 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 ...
4
votes
0answers
127 views

DynamicModule, SaveDefinitions and global functions

Unfortunately, I had not checked stackoverflow, because there, the exact same behavior was already reported. Please see the Q&A "SaveDefinitions considered dangerous". Up-front, I'm on Ubuntu ...
4
votes
1answer
187 views

Manipulate a Plot that contains a variable that contains symbol [duplicate]

This snippet mm = m Manipulate[{mm, Plot[mm x, {x, 0, 1}]}, {m, 0, 1}] (m is not defined anywhere) produces a sadly fixed ...
4
votes
0answers
68 views

Problem with inequality using refine

I am using inequalities to follow some line of reasoning in Mathematica and I came across a problem I can not explain to myself. Does from a>=0 and b>=0 not follow a+b >= 0? How does Mathematica ...
3
votes
3answers
331 views

Help on evaluation control?

I want to plot series of slopes: x, 2x, 3x, 4x, 5x, 6x... I'm trying to do this: ...
3
votes
2answers
273 views

Efficiently evaluating a held expression directly from a list

I am able to evaluate a held expression that I have put on a list by: ReleaseHold[expressionList[[1]]] and ...
3
votes
1answer
146 views

Evaluation order of Button[]'s action

it looks like it should be well known issue but I haven't found answer anywhere. Please tell me why the result (after clicking) of this: ...
3
votes
4answers
235 views

Replace symbols with values without evaluation

If I have assigned values to a, b and c: ...
3
votes
3answers
107 views

Using a variable to tell Mathematica which existing variable to manipulate

I have an estimation routine I have coded up, I want now to do some tests on it where I pick a particular parameter and run the estimation for differing values of that parameter. What I want is to be ...
3
votes
3answers
137 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 ...
3
votes
3answers
186 views

Alternative to using global variables in functions?

Often times I find myself using unevaluated variables (i.e. they show up blue) as dummy variables in whatever I'm returning such that I can evaluate them as needed later on. A simple example is as ...
3
votes
1answer
249 views

Log function - why is Log[b,b] not being evaluated to 1?

Have been experimenting with the Log function to demonstrate simple Log relationships such as Log[xy], Log[x+y] etc. ...
3
votes
2answers
105 views

Turning evaluation off

I am making a directed graph, but Mathematica keeps trying to evaluate my labels. I know that I can just use " ", but I have a lot of input. Is there a way to turn evaluation off? ...
3
votes
1answer
141 views

Set promotes Rule to RuleDelayed?

In mentally building a model of how Mathematica works, I naively expected Set to create a Rule in a symbol's ...
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
103 views

UpValues evaluation with Dot operator

I would like to simplify some database notation, and I'm doing some tests with UpValues for that. For example, if I set this Upvalue fot tab1: ...
3
votes
2answers
115 views

Assigning an equation as a variable

I am compiling a calculator where many slider parameters are used to define a value, where the defined value may then be reused to define another value. I am unable able to, or at least been ...
3
votes
3answers
331 views

Prevent Mathematica to automatically evaluate Manipulate at start

I'm using an initialization cell to import a lot of data: data = Import[myFiles]; and then I use a custom function to display this data with Manipulate: ...
3
votes
1answer
249 views

Why can't Mathematica parallelize this?

The following code makes mathematica print "ParallelTable::nopar1: [...] cannot be parallelized; proceeding with sequential evaluation." ...
3
votes
1answer
118 views

Gateaux (directional) derivatives and higher order differentials of a functional

I would like to calculate the Gateaux derivative of a functional (i.e. a function depending on functions). A simple example for the Dirichlet functional: $L(u(x))=\int_0^1 \frac{1}{2} (u'(x))^2 dx$ ...
3
votes
1answer
80 views

How to localize symbols on the right-hand side of Rule when using ReplaceAll?

I am frustrated by the following: {1, 2, 3.0} /. a_Integer -> a + 1 The a on the left side of the arrow is localized and ...
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 ...
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 ...
3
votes
1answer
89 views

Why is held expression evaluated?

Context: I'm studying non-linear dynamics. As part of a bigger problem, I'd like to generate lists of the form {{deq, ic1}, {deq, ic2}, ...}, where ...
3
votes
1answer
268 views

How can I save the current evaluation state of a notebook and start from it later?

I currently have a nested Table command running (in Mathematica 9), with two progress bars to track the variables. I have to shut down or hibernate the computer in ...
3
votes
1answer
86 views

Stop TradtionalForm evaluating expression

I'm trying to get this expression to display as typed instead of evaluating the 1/1.121. ...
3
votes
1answer
53 views

Print prints into the Messages notebook rather than into the evaluation notebook

Some time ago I noticed that the results of the evaluating the function Print[something] does not emerge in a new cell created in the notebook where the operation ...
3
votes
1answer
42 views

Apply a function to the current selection in place

Say a have the function foo: foo[x_] := x + 2 Like the Evalution ...
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 ...
3
votes
2answers
90 views

Evaluate in Plot leads to function error

Please help - I'm really struggling to understand why this evaluates with errors. ...
3
votes
2answers
207 views

Overloading conjugate operator for a particular function

I trying to modify the behaviour of the built-in Conjugate[] operator on a particular function I have defined, to take into account that some of its variables are ...
3
votes
1answer
120 views

Why even try the semantic constraints, if expression can't match the pattern structure?

This result is unexpected: Trace[MatchQ[{7}, {_?NumberQ, __}], NumberQ] (* -> {{NumberQ[7], True}} *) Why evaluate ...
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: ...
3
votes
2answers
91 views

Keep data in memory inside a notebook without having to evaluate it again [duplicate]

I have a notebook that calculates some data in a relatively large time so I want to keep these data saved inside the notebook without recalculate them every time I open the notebook. I know I can ...
3
votes
1answer
242 views

FunctionInterpolation Errors / Question re Evaluation Order and Options

I have using Mathematica functions that takes a Cartesian coordinate relative to the Earth (xyz) and converts it to a latitude, longitude, and altitude (lla). And here it is: ...
3
votes
0answers
169 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 ...
3
votes
0answers
62 views

Non-preemptive evaluation of a dynamic function? [duplicate]

I want to monitor a long calculation that is triggered by the release of a Slider. While one can indicate running calculations when the main evaluation loop is ...
3
votes
0answers
318 views

A is fast, B is fast, but together they're Mathematica-crashing slow?

I'm trying to do something with finding solutions to a quantum mechanics problem with n wells. If there are 40 wells, I need to find the solution to an equation in the form: ...
2
votes
3answers
162 views

will the same result be evaluated twice per evaluation?

here is the silly question of mine, if mathematica takes 3 seconds to evaluate the function ...
2
votes
2answers
131 views

How to make Mathematica returns the exact expression I typed

I'm using Mathematica to compare some constants. Before playing around with those constants, I would like to check that I didn't make any mistake in typing them. So my question is the following: "What ...
2
votes
1answer
193 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
3answers
289 views

Select sublists with second element nearest to zero

I've got some big lists from which i need some data (one of the big lists). To be specific, I need to divide this biglists in sublists of the same length (10000), and form a new list with the mean of ...
2
votes
3answers
114 views

Dynamic plot with Evaluate on expression

I'm trying to make a make a plot of a table of expressions, which should be pre-evaluated (since they are infinite series with analytic sums). I'm able to make the plot normally with ...
2
votes
2answers
2k views

Step-by-step definite integration

I am interested in obtaining the intermediate steps for rather straightforward symbolic definite integrations (e.g., from an elementary calculus text). As an example, for $\int_0^1 x\,dx$ I'd like ...
2
votes
2answers
91 views

Handling a sequence of unevaluated arguments

I have the following piece of code: ...