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

learn more… | top users | synonyms

9
votes
1answer
650 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
30 views

Mathematica won't evaluate expressions [on hold]

Mathematica isn't evaluating a lot of expressions for me, and I'm unsure of why. Input of GeoDistance[{37, -109}, {40.113, -88.261}] gives output of ...
0
votes
0answers
32 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
58 views

Unexpected behavior of Set [on hold]

Set doesn't work in some conditions. ...
9
votes
4answers
172 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
50 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
72 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
59 views

Approaching infinity

I'm using Mathematica to visualize the autocorrelations of all kinds of wave-types. Obviously, my waves aren't infinite and don't have infinite periods though, so the autocorrelation I get is a ...
0
votes
0answers
37 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
80 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
69 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
57 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
233 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
435 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
138 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
31 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
63 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
55 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
88 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
80 views
3
votes
2answers
50 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, ...
12
votes
5answers
237 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
92 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
874 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
51 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
41 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
88 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
39 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
204 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
2answers
59 views

NDSolve with one parameter

This is a copyable minimal example to illustrate the problem that occours when I include one parameter U into a differential equation which I want to solve with ...
1
vote
0answers
31 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
105 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
230 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.3.1 or later Why plain Dynamic[x] is less sensitive and less likely to automatically be updated than ...
0
votes
0answers
59 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
49 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
38 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
48 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 ...
0
votes
0answers
56 views

Is it possible to somehow parallelize PadeApproximant in Mathematica?

Is it possible to somehow parallelize PadeApproximant in Mathematica? I'm dealing with a too long function (including exponential and trigonometric terms) in ...
10
votes
4answers
328 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
61 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
46 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
38 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
82 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
61 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 ...
9
votes
2answers
151 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 ...
4
votes
1answer
34 views

How to evaluate following inputs only after finishing CreateDialog

I have a code which starts with the following Cell: ...
2
votes
1answer
107 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
56 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 ...
4
votes
2answers
88 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 ...