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

How to force evaluation inside the body of a pure function?

For example, I'm writing a function to scale my list of numbers into a specific range. It goes like ...
-1
votes
1answer
59 views

How to plot a function, that is not properly defined in mathematica? [closed]

After rather long and relatively complicated calcuations, I finally got to a point where all my $x(t)$ functions are ...
6
votes
2answers
147 views

What is the Difference Between Rule (->) and RuleDelayed (:>)?

I am new to Mathematica so this question may seem rudimentary. Sorry for that! :) I want to implement the well-known property of Kronecker's Delta $$\Sigma_{i=1}^{n} a_i \delta_{ij}=a_j,\quad 1 \le ...
8
votes
3answers
188 views

Expand series unevaluated

I'm newbie in Mathematica. I'd like to obtain nice and verbose output for any series calculation. For example, given a simple sequence n*(-1)^(n-1) and ...
6
votes
0answers
71 views

Why Unevaluated doesn't work on unheld side of Rule/RuleDelayed?

Unevaluated is a function that I never truly understand, and here's one of the cases confusing me: ...
8
votes
1answer
148 views

Why one needs two Unevaluated to show 1+1 correctly in TreeForm?

The task sounds simple, give the tree plot of 1+1. However, after some trying, I can only make this possible by using two Unevaluated. ...
1
vote
1answer
60 views

Convert an evaluated in place code to original

I like "Evaluate In Place," because it hides code and works well. However, I can't figure out how to return to the original code when I want to modify it. I'm sure there is an easy way, but I can't ...
13
votes
3answers
468 views

Handling Kernel quit

One can use $Epilog to do something when the Kernel is quit or put an end.m file next to the ...
9
votes
0answers
69 views

Is there a way to TagSet a HoldAllComplete function?

Let's say I want to overload the built-in function Lookup, to handle my data wrapped in myObject. One would use ...
2
votes
1answer
71 views

Create a notebook and save it without prompting Dynamics

This is closely related to the recent: Creating self destructing notebook. However the answer doesn't work in my case. ...
8
votes
1answer
926 views

Creating self destructing notebook

Inspired by this post I've been trying to implement the idea in Wolfram with no success yet. I've come pretty close though and need some help. So I've managed to do this: ...
1
vote
0answers
111 views

Why this expression is not evaluated correctly?

Look at the following code: ...
6
votes
1answer
57 views

Partial evaluation of symbols with non-inert OwnValues

Background: there are many, many questions here about the infamous ::setraw error. More often, than not, they have to do with repeated assignments to symbols. Here's the code: ...
0
votes
1answer
42 views

Computing approximations of exponential [closed]

I have the code f[x_] := 13 x e^-x bit = Nest[f, 1, #] & /@ Prepend[1]@Range[4, 16, 4] Which I am using to compute values of $f^{(4)}(1), f^{(8)} (1), \...
1
vote
1answer
93 views

Evaluation of a Notebook

I am new to Mathematica so I do apologize if my question is too elementary. In the start of my notebook, I want to make sure that any previous definitions are wiped out so I use the ...
3
votes
1answer
97 views

Map works but Thread doesn't

This question may be trivial, but I can't get past it for the life of me. I have $n$ matrices of dimension $p_i \times N_i$, with $i$ indexing the $n$-set. I also have $n$ vectors of the appropriate ...
5
votes
2answers
152 views

Evaluate numerically an extremely small number

How to evaluate numerically $e^{-4 \cdotp 10^{35}}$ in the form $0,a_1a_2...\times 10^{-n}$ ...
3
votes
1answer
52 views

An issue regarding the use of CopyToClipboard with dynamic content

Please, consider the following code: ...
2
votes
1answer
50 views

Recognition Power Head for numeric value

We know: Map[Head, {a, a^2, a^3}] (* {Symbol, Power, Power} *) and Map[Head, {2, 2^2, 2^3}] all of them will be known as <...
1
vote
0answers
43 views

How can I use x->Root outputs from Solve? [duplicate]

Do not understand the meaning of the output given by Mathematica to this equation: ...
0
votes
0answers
45 views

EvaluationMonitor and variables with indices + subscripts

I have encountered the following problem while using EvaluationMonitor with NMinimize: variables that have both a subscript and an index, e.g. Subscript[x,y][1] do ...
0
votes
1answer
51 views

Manipulate curves [duplicate]

I want to draw curves with manipulation. When I use the following code, I receive nothing. ...
6
votes
0answers
49 views

How trap expression that doesn't evaluate?

If evaluating an expression produces an error, it's easy to trap that using Check or Throw......
1
vote
1answer
37 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
892 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 $kx,kz$-...
0
votes
0answers
42 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
82 views

Unexpected behavior of Set [closed]

Set doesn't work in some conditions. ...
11
votes
4answers
199 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
59 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
89 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
104 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
307 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
456 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
151 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
35 views

How to calculate a required definition only once for each iteration of NonlinearModelFit [on hold]

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
78 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
73 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 ...
4
votes
4answers
120 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
91 views
3
votes
2answers
55 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
258 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
102 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
921 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
89 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 calculations....
0
votes
2answers
45 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
107 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 \vec{k}\cdot\...