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

learn more… | top users | synonyms

1
vote
1answer
35 views

Access variable middle of the run [duplicate]

I execute a Table[] that need large time to be finished. If I abort it I loose what evaluated until now. Does it possible to stop running and save what evaluated ...
12
votes
1answer
889 views

Why is this 2D plot so slow?

I first do a 3D Plot of four surfaces (eigenvalues of a $4\times4$ matrix) over $kx,kz$ (setting $ky=0$ all along). And then I try to give a 2D plot along three connected particular lines in ...
0
votes
0answers
40 views

Substitute arguments before evaluating variables in Block [duplicate]

Suppose I have f = x^2; mod[x_] := Module[{}, f] Then mod[3] returns x^2. Is there any way to tell Mathematica to treat the "x" inside of f as the same "x" as ...
1
vote
0answers
74 views

Unexpected behavior of Set [closed]

Set doesn't work in some conditions. ...
11
votes
4answers
191 views

Evaluation of Alternatives

I recently stumbled upon a few examples that suggest patterns containing Alternatives do not evaluate for individual alternatives. For example: ...
1
vote
0answers
57 views

Solving a polynomial equation with an approximate constraint is slower than the symbolic solution

Why do these two operations have such different timing, when the only difference is specifying r as approximate $0.1$ vs arbitrary-precision $1/10$? Here are the ...
1
vote
1answer
85 views

How can I draw truth tables using Mathematica [duplicate]

For instance, the given expression p ⊕ (p v q) In the problem I'm trying to solve. There's a Mathematica answer to this: ...
0
votes
0answers
40 views

Why doesn't Grid evaluate when I wrap all its arguments in Dynamic? [duplicate]

Here is a small program involving Dynamic: ...
2
votes
1answer
94 views

Clearing a global variable from inside a Module

This is a highly simplified version of a initialization problem I have with a complicated program with many (about 100) modules. If one enters: X=42; Clear[X]; the ...
1
vote
2answers
72 views

Evaluation of a list

I'd like to assign to $a[1],\ldots,a[m]$ ($m$ being defined beforehand) zero values. I tried Table[a[i], {i, m}] := Table[0, {m}]; but got an error message ...
4
votes
2answers
62 views

Controlling evaluation in a custom summation function

I'm doing some computations that involve summations with many indices over the same range - consider the simplified example Sum[a[i,j],{i,1,2},{j,1,2}]. To prettify ...
8
votes
4answers
290 views

How to inject unevaluated list of Unique into a RuleDelayed?

I am writing a function that constructs a rule which has Unique[] in the RHS. Here is a simplified segment of code ...
10
votes
4answers
453 views

Order of evaluation - does Mathematica evaluate variables before or after substitution?

Let's say I write y = x^2; x = 10; z = y + y^2 + y^3 Does Mathematica internally evaluate y before or after substituting it into z? I.e., does Mathematica ...
7
votes
2answers
149 views

Evaluation inside Inactivate

The documentation for Inactivate makes the function sound really powerful because it gives granular control over which kind of expressions specifically not to ...
0
votes
0answers
34 views

How to calculate a required definition only once for each iteration of NonlinearModelFit

This is my first post here. I've been using Mathematica for about 4 years now to analyze data, but am still very new and have no background in formal programming. This is the first question I couldn't ...
4
votes
2answers
74 views

Append fixed value to random selection of list

(This question might be an application of this other question, but there might be another solution specific to this application that I'm not aware of.) I am currently in a situation in which (in a ...
4
votes
1answer
70 views

Strange behavior of ArcTan [duplicate]

I've noticed a strange behavior of Mathematica's ArcTan function with two arguments. If both arguments are 0 or ...
3
votes
4answers
99 views

Working with ScheduledTasks inside DynamicModules

I have a question - is it possible to run ScheduleTask[] inside DynamicModule[]? What I have tried so far: ...
3
votes
0answers
84 views
3
votes
2answers
53 views

How to avoid 0 OverVector[F] to be evaluated as 0?

I am fairly new in Mathematica and I am trying to work with scalars and vectors. I decided to denote vectors using OverVector (as example, ...
13
votes
5answers
252 views

Prevent Plus from threading

This is probably a very simple question, but I couldn't find a duplicate. As everybody knows, {x, y} + v gives {x + v, y + v}. ...
4
votes
2answers
99 views

Derivative before Numerical Integration

I need to take the derivative of a function that have a numerical integration on it. The variable in which the integration will be taken is not the same as the one in which the derivative will be ...
16
votes
2answers
902 views

How to restart computation when kernels die?

When an important process needs to be kept alive, there are monitoring tools to restart them if they die (e.g. god tasks in ruby), in my case I have an overnight scraping task that I need to have done ...
3
votes
0answers
74 views

Is there an analogue of Evaluated->False (in FindRoot) for FindMinimum?

I guess functions like FindRoot, FindMinimum, etc puts the estimation number into the expression, and then do other ...
0
votes
2answers
44 views

Unevaluated derivatives of known functions after replacement

I want to make the following replacement work correctly: Array[(2 D[xM[[#1]][t], t] * D[xM[[#2]][t], t]) &, {3, 3}] /. {xM -> {Sin[ω t], Cos[ω t], 0}} ...
3
votes
1answer
99 views

Fast evaluation of a function in many points

I need to feed to an external program a number of points (in Complex128 format) generated from the numerical evaluation of some function, e.g. $e^{i ...
0
votes
0answers
43 views

Order of evaluation for numeric functions

I'm trying to plot a 3D vector field to illustrate an electric field of a uniformly charged disk, and I used Manipulate to change the radius R of the disk to see ...
5
votes
5answers
216 views

Nested function with an increasing argument

If, for example, I have a nesting function like Nest[1 + x^n (#) &, 1, 3] it gives the result ...
1
vote
0answers
34 views

Save a Mathematica notebook evaluated [duplicate]

My notebooks can take some time to evaluate and by quitting Mathematica, I have to reevaluate every definition I've made once I restart Mathematica. Is there a way to tell Mathematica to save the ...
0
votes
1answer
119 views

Plotting two variables indirectly dependent on each other

I have the following system of linear ODEs for "i" number of species "c" migrating in "j" number of habitats: ...
18
votes
1answer
259 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 10.4.1 Why plain Dynamic[x] is less sensitive and less likely to automatically be updated than e.g. ...
0
votes
0answers
79 views

Skipping sections of a notebook automatically

I have a notebook which allows to set some parameters at the start, and then does computations depending on these parameters. It is a long notebook and for readability it is broken up into sections ...
4
votes
1answer
51 views

How to adapt MSPToExpression function in $PrePrint?

I am introducing the mathematica Security (MSP module) to our system. The Document suggests use MSPToExpression as followed: ...
1
vote
1answer
39 views

Please explain this pattern/Message related issue and help with finding workaround

I attempted to clean up my code and also add messages to functions if they are called with wrong arguments. This introduced some error which I tracked down to the following: ...
1
vote
1answer
49 views

Evaluation of InverseFunction at the boundaries of its domain

Folks, I want to numerically evaluate a InverseFunction h[x] close to the edges x5 and ...
10
votes
4answers
336 views

How to take and evaluate a specific part of a list without evaluating the rest?

I have a large list, for example, lis = {x + y, x y, Sin[x] y + Exp[y], x^2 y} and its elements depend on variables x and ...
2
votes
0answers
43 views

Executing selected code [duplicate]

In current Mathematica interface, if I select some piece of code and press CMD + Shift + Enter, the code is evaluated in place. Replacing the selected part by the evaluated version. The question is: ...
0
votes
0answers
70 views

Memoization and upvalues

Can I store an algorithm to one variable and the result as an upvalue to another? With regard to the problematic code below (real algorithm and argument test omitted), I would like to store the ...
1
vote
1answer
55 views

Creating a keyboard shortcut to change the Style of text [duplicate]

I'm editing a very long text in a Mathematica notebook and I'm using the "Article" stylesheet. In this text, code is highlighted using ...
1
vote
1answer
43 views

Showing updating message in Dynamic with UpdateInterval

I am creating an interface which needs to repeat an operation every few seconds. The operation itself is expensive but faster than the update interval of the interface. I would like to have some ...
2
votes
2answers
86 views

PasteButton: Pasting expression name without quotation marks?

I am struggling to find a way to use PasteButton to paste the name of an expression (in particular a list) without showing the contents of the expression or without ...
2
votes
2answers
68 views

How can I use an InputField value as a variable name to save to?

I'm trying to save some settings and results from Manipulate, and I want to be able to save them to different variable names. The code I have is something like ...
10
votes
2answers
174 views

stop notebook evaluation when Assert fails

I would like a notebook evaluation to entirely stop when an Assert fails, without quitting the kernel. Is this possible (e.g., by setting ...
5
votes
1answer
46 views

How to evaluate following inputs only after finishing CreateDialog

I have a code which starts with the following Cell: ...
2
votes
1answer
117 views

How to properly define this function of function

I encountered real problem at first, and here is the toy example variable argument stored some expression that is generated from other parts of the program. I ...
1
vote
0answers
72 views

Meaning of Abs´? [closed]

A friend showed me the code below. r[i_] := {x[i, t], y[i, t], z[i, t]}; rji = r[i] - r[j]; solap = 2 a - Norm[rji]; FullSimplify[D[solap, t]] I'm unsure about ...
5
votes
2answers
103 views

Parallel function evaluation for minimal value

I am asking myself, if the evaluation of a function f looking for a minimal value over a discrete set of values can be parallelize (brute scan for a potential ...
2
votes
3answers
115 views

Evaluation inside a Manipulate

Let's assume I have a symbolic expression, and inside a Manipulate I define the actual values: ...
1
vote
2answers
64 views

Plot of function-generated lists: Why does this workaround not work?

My problem is a classic one: I want to plot a function-generated list, and there's no way to pre-evaluate (because the actual function includes NMinimize and thus ...
2
votes
1answer
111 views