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

learn more… | top users | synonyms

0
votes
0answers
86 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
52 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
338 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
73 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
89 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
73 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 <...
11
votes
2answers
183 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
53 views

How to evaluate following inputs only after finishing CreateDialog

I have a code which starts with the following Cell: ...
2
votes
1answer
121 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
78 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
108 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
120 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
112 views
0
votes
2answers
110 views

How to display results of NDSolve

I am solving differential equation of second order ...
2
votes
1answer
84 views

Errors in plotting regular function

Suppose we want to define Tanh-function via exponent: th[x_] := (1 - Exp[-2 x])/(1 + Exp[-2 x]); FullSimplify[th[x]] Out[13]= Tanh[x] Then we define new ...
1
vote
1answer
42 views

Aborting an evaluation automatically after a specified time elapsed

I use the following code to evaluate a series of notebooks: nb1 = NotebookOpen["C:\\Users\\....nb"]; SelectionMove[nb1, All, Notebook] SelectionEvaluate[nb1] ...
1
vote
1answer
52 views

How do I dynamically update “name” of Action Menu?

I have created an action menu that allows you to change the style of a cell. It works. However, I would like it to dynamically update the action menu "name". I can't get the name to refresh. ...
1
vote
1answer
42 views

Unpacking NumberForm expressions

Given a NumberForm expression, e.g.: NumberForm[N[Pi], 10] How does one get the underlying numerical expression (short of ...
1
vote
1answer
67 views

Trace and SameTest in Union [closed]

This question is actually two question. First, I feel so stupid that I just don't understand the use of theSameTest option in ...
1
vote
1answer
42 views

How to enable automatic “grammar check” for MMA? [duplicate]

The special evaluation mechanism of MMA might make it more likely for MMA users (especially new users) to make mistakes and more difficult to find them. For example, one may have defined a function ...
5
votes
2answers
284 views

Evaluate notebook from other notebook

I have a notebook ("notebook 1") which in the beginning sets some parameters, does something depending on their value and saves the result to a file, say: ...
1
vote
1answer
133 views

Why isn't Mathematica reducing my result to a number? [closed]

I do not understad why the program do not show the number values. Even when I use N[xx]. How can I simplify this?
5
votes
3answers
75 views

StepMonitor won't display Plot

This example is from the documentation under Monitor ...
0
votes
0answers
42 views

Evalutation strategy [duplicate]

This example code: ...
16
votes
3answers
287 views

Is it possible to change the order that symbol definitions are checked? (DownValues vs UpValues)

Suppose I have the function f with the following definition assigned to it: ...
4
votes
0answers
90 views

Simple arithmetic with Irrationals fails [closed]

While solving a simple puzzle that asked for a few calculations in plane geometry, I ended up with this expression: $-\frac{55}{2}+\frac{\sqrt{27233}}{2}+\frac{1}{2}(55-\sqrt{27233})$ Or, in ...
2
votes
2answers
80 views

Singleton pattern

How can I implement the singleton pattern in Mathematica in order to ensure that a symbol is not redefined if it's already defined ? This can be useful for example with global variables in packages ...
4
votes
1answer
387 views

mathematica does not evaluate without internet access? [closed]

I am watching the video Hands-on Start to Mathematica Basic Graphics and for about 15 minutes I was trying to evaluate $\frac{\sin x}{x}$ and each time I encountered errors like: The result can ...
17
votes
2answers
328 views
3
votes
1answer
64 views

How to evaluate an expression via `LinkWrite` when the expression is only known at runtime?

*** Here's the original post... I'm setting up a secondary kernel in sandbox mode with LinkLaunch, and need to pass various expressions to it for evaluation. These ...
1
vote
1answer
112 views

Evaluate multiple notebooks sequentially and automatically

I know how to run multiple notebooks at once. But my problem is that due to the RAM capacity, I have to run these notebooks consecutively. Another problem is that since I may not be in my office all ...
7
votes
1answer
143 views

How would one return from a place of a pure function's body using Return?

From previous answers, replies and discussions it is known, while not formally documented (even in the most recent Wolfram Language Documentation Center), that Return can be used in a two-argument ...
0
votes
1answer
91 views

Special fractions generator

Note that 13/33, 1313 / 3333 , 131313 / 333333, ... They are always equivalent fractions Fraciones generate desire to have this property based arbitrary ...
5
votes
1answer
35 views

How could I set TimeConstrained globally?

I want to set TimeConstrained globally, I tried use $PrePrint as bellowed script: ...
1
vote
3answers
101 views

Keep leading/trailing zeroes (like Defer except with numbers) in a given number

I'm trying to write a function that counts the number of significant figures a given number has so I can ensure my calculations are rounded correctly; however, I am having a lot of trouble preventing ...
1
vote
1answer
49 views

problem about Root and Hypergeometric2F1

See these example, why does the output is different? ...
10
votes
1answer
457 views

A problem about the implementation of Bezier curve

I implemented the Bezier curve like built-in BezierCurve as follow: SplineDegree -> d specifies that the underlying ...
1
vote
1answer
55 views

How to achieve fun[Unevaluated[f][Unevaluated[x], Unevaluated[y]] in a more elegant way?

I have defined a function fun[f_[x_,y_]]. When I call it, I want to wrap everything by Unevaluated: ...
-2
votes
1answer
86 views

Why is my function returning 0 when when I try to give it arguments by replacement? [closed]

I tried running a function f with rules and calling it directly with arguments specified directly but the one with rules returns zero while the one with direct ...
6
votes
2answers
119 views

Force evaluation of the right-hand side of a local variable definition

One can do expression = a + 1; f[a_] := Evaluate[expression] but how would one do something like this ...
3
votes
2answers
151 views

Even with Evaluate[], Mathematica is plotting everything in the same color

The code evals[x_?NumericQ] := Eigenvalues[{{x^2, 2 x}, {x, 3 x^2}}]; Plot[Evaluate[evals[x]], {x, -1, 1}] gives both eigenvalues in the same color. I thought ...
7
votes
2answers
110 views

Cannot Block Plus

It is customary to use the following idiom to partially evaluate something inside a held expression: ...
4
votes
1answer
143 views
7
votes
2answers
139 views

Inserting symbols' definitions during read time of the code

Let's say we've got a package: ...