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

learn more… | top users | synonyms

7
votes
4answers
216 views

Button's command is not evaluated in iteration

I wish I didn't feel like a newbie after several months, but... If I enter the following: Table[ Button[ "Number: " <> ToString @ i, Print @ i], {i, 1, 5}] ...
5
votes
2answers
271 views

Problem with ParametricPlot of multiple Curves

I have written a function f[Ne,t,T], that gives back a list of results when evaluated with numeric values of the variables Ne, ...
0
votes
0answers
48 views

How to ContourPlot a Table? [duplicate]

Possible Duplicate: Why is ContourPlot not displaying this curve? Why do I have to put Evaluate[] here I'm trying to plot certain contours of a function $f:\mathbb R^2\to\mathbb R$. What I ...
2
votes
3answers
147 views

Function to preserve evaluation on display?

I'm looking for a function that applies the following behavior to an expression: -When the expression is given as the full input, or as part of a function that cannot be evaluated, it remains in ...
1
vote
2answers
151 views

Why does Evaluate[a[[1]]]=0 assign a value to a variable while a[[1]]=0 doesn't?

I'm trying to do a small page counter with Mathematica, for leting me know about my reading progress on some books. I'm stuck on a problem: ...
5
votes
1answer
171 views

Why does Dynamic output cause CPU usage when onscreen?

I write such a line in Mathematica: {Slider[Dynamic[s]], Dynamic[f[x_] := s*x]} After evaluation, the CPU immediately runs at full power. And if you scroll the ...
12
votes
2answers
397 views

Preventing Numerical value from being evaluated

I have searched stackoverflow (and comparable pages) for quite a while now (got redirected from there to this specialized stack), and I surrender. I am trying to evaluate an expression that is small ...
4
votes
2answers
184 views

Evaluating a Recursive Expression

Why does this raise an error ...
9
votes
1answer
88 views

Different behaviour of ValueQ inside and outside of a loop

I need to store a rather big number of variables and I tried to do that by storing each variable as Z[n] with varying n. I guess this was not my best idea. The first problem I encountered is when I ...
11
votes
2answers
245 views

can a ColorFunction have side effects?

Can anyone explain this (to me) odd behavior. If I run this code once (fresh kernel) it works as intended. ...
17
votes
1answer
600 views

How can I set a keyboard shortcut to run a command?

I want to use this to add a keyboard shortcut to an undo function I wrote. The basic problem is the following: I have a command, let's say x=1, and I want to run ...
17
votes
2answers
327 views

Context unique to each group at a specified level

Recent versions of Mathematica provide the option of having a unique $Context for each cell group, via: Evaluation > Notebook's Default Context > Unique to Each ...
9
votes
1answer
217 views

Get the name of a symbol passed to a function

I'm trying to get the name of a symbol passed to a function with this: f[x_] := {SymbolName[x], x} SetAttributes[f, HoldFirst] x = 5; f[x] But ...
7
votes
2answers
104 views

Obtain input expression from history without evaluating

I typed and evaluated an expression, but deleted it from the notebook. For instance, suppose it was In[1]:= Round@SessionTime[] Out[1]= 2 I now want to retrieve ...
10
votes
3answers
313 views

Why does ++++x return an increment of 2 when the value of x is only incremented by 1?

This line returns 3: x = 1; ++++x However, the value of x after the increment is only ...
4
votes
3answers
195 views

How can I create a custom control which evaluates to a list of values or replacements?

I have a set of variables which are used in various places in my calculations (solving a system, initial conditions, etc.). In order to make this easier to deal with, I want to make a control-like ...
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." ...
8
votes
1answer
123 views

Prevent Plus from threading InterpolatingFunction

For an InterpolatingFunction $y:\ \mathbb{R}\to\mathbb{R}^2$, Plus is unaware of this, so when I do any modifications to it in ...
2
votes
2answers
154 views

Updating a tracked symbol inside Refresh?

I have some code inside a Manipulate, whose goal is to allow the user to edit the upper half of the matrix while keeping it symmetric at all time. The minimal code ...
4
votes
2answers
3k views

Simple ways to evaluate a derivative at a point?

The contrast in behavior between, say, f[x_] = Sin[x^2]; f'[2] vs. u[x_, y_] = Cos[x + y^2]; has always bothered my ...
13
votes
2answers
235 views

How can I access a variable in one evaluator from another evaluator?

I have two notebooks, each with a different kernel. Is there a way to grab the value of a variable in KernelA from KernelB?
16
votes
2answers
1k views

Difference between AbsoluteTiming and Timing

I need to evaluate the efficiency of my code. Therefore I would like to evaluate the time the code need for some calculations. Mathematica gives me two possibilities for this kind of evaluation: ...
2
votes
1answer
122 views

Implementing a For (?) or series or loop (?) for individual results for every x to n

I'm working on improving a modeling formula and have spreadsheets worth of data to use, but my work so far has been quite tedious. I'm essentially pulling 20 rows of data from each separate sheet of a ...
4
votes
2answers
504 views

How to make a function that evaluates an expression?

I'm trying to make a function where the input is an expression, but somehow it just won't be evaluated. For example, this little function doesn't work: ...
4
votes
1answer
339 views

Strange Error in Bifurcation Diagram:

I am attempting to plot the bifurcation diagram of the tent map $$ f(x):=2\alpha \begin{cases} x, & 0<x<1/2\\ 1-x, &1/2<x<1, \end{cases} $$ i.e., the plot $\alpha$ vs. the limit ...
4
votes
1answer
63 views

How can I kill one evaluator from another?

I have a kernel named A in one notebook and other notebook with kernel B, how can I kill B from A?
6
votes
2answers
489 views

Evaluate while external command is being run [duplicate]

Possible Duplicate: Computing Many Slow I/O Operations I'm launching an external command with the Mathematica front end that takes two arguments: ...
4
votes
1answer
121 views

Pre and Post in a Block[]

Why does Block[{$Pre = ( 1 + #) &}, 1] produce 1 while ...
1
vote
1answer
66 views

Grid — Row expressions not evaluated [closed]

Can anyone explain why in the following Grid expression the Row expressions are not evaluated ... ...
6
votes
1answer
185 views

How can I have interruptible computations inside a manipulate?

Here's a perfect example of my problem: Manipulate[Pause[n], {n, {1, 10}, ContinuousAction -> False}, SynchronousUpdating -> False] It is illustrated by ...
2
votes
2answers
1k views

Animation of Differential Equations from NDSolve with ParametricPlot3D and Evaluate

I have a system of differential equations (referred to as "s") and use NDSolve to obtain the solution. I substitute the interpolated functions for the original ...
0
votes
1answer
67 views

How can I restrict a notebook to evaluate only if I am user 'root'?

I am playing with openCL on Linux with an AMD gpu, and due to a glitch in the driver, I need to be 'root' to get stuff to work. Installation question here.
1
vote
2answers
132 views

How can define a set of nested parameters

I would like to know how I to define a function with a nested set of parameters (or whatever you would like to call it). For example, how would I get the following function ...
5
votes
3answers
242 views

First evaluation fails

I am fairly new to Mathematica (version 7), so please bear with me... I have duplicated, in Mathematica, a program that I originally wrote in C (it generates OEIS sequence A191837). The problem is ...
7
votes
2answers
209 views

Why does the name of a pattern affect the result of a transformation rule?

I was playing a little dirty, trying to get a template for defining a Curl[] operator. I wrote the following rule, which I knew was going to spit out a few ...
1
vote
2answers
97 views

What is the default file path used by the Put function and how do I pre-evaluate an expression to use in Put?

I have a problem of trying to store some output in an external file. In one note book I define a function f[x_]:=AdvancedCalculation, where this function generates ...
0
votes
1answer
125 views

Slow Dynamic Button Does Not Print [duplicate]

Possible Duplicate: Why do buttons with ChoiceDialog freeze the front end? Why is SystemDialogInput failing to return a save file path? Evaluation inside Button stops after some seconds I ...
17
votes
3answers
523 views

How can I completely ban usage of some functions in output and mandate use of others?

For example, I hate that Mathematica uses Pochhammer symbol in outputs and prefer all the expressions in Gamma function. How can ...
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] ...
13
votes
2answers
283 views

How to make use of NumericQ[x] = True (and use it safely)?

Basic Issue: I'm trying to understand the proper use of NumericQ's "magical" capabilities. Please consider the examples below. Actual question and some links are ...
1
vote
1answer
180 views

Particular solutions of a Differential Equation not evaluated in a given case

Below first case which gives particular solutions of an OED correctly: ...
15
votes
1answer
266 views

Polynomial expectations of generic distributions

Summary Polynomial expectations depend only moments and cross moments of a multivariate distribution. I would like to use Expectation to compute polynomial ...
7
votes
2answers
169 views

Keywords to find documentation for this syntax

Mathematica allows this syntax, but I cannot find any documentation (or books) that discuss the various uses/advantages of it ...
17
votes
4answers
372 views

Function that caches when it returns unevaluated

How would you go about implementing a function that caches not the result but the fact that it didn't match a pattern? So that it doesn't waste time recomputing a complex time-consuming pattern ...
5
votes
1answer
227 views

Parts of Module body evaluated in external scope?

I have an expression that suggests that some expressions in a module body are dragging in definitions from outside the scope in a surprising way. First, consider a symbolic constant, ...
10
votes
3answers
296 views

How can I hold UpValues but evaluate other expressions?

Consider these definitions: own = "OwnValue"; down[_] = "DownValue"; sub[_][_] = "SubValue"; N[n] = 3.14; _[___, up, ___] ^= "UpValue"; The attribute ...
6
votes
1answer
323 views

Why does Manipulate execute the expression twice?

When I execute Foobar[] in the code below and move a slider, the variable grad is printed twice. Why is this? How can I make the ...
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? ...
2
votes
1answer
2k views

setting a variable equal to the output of FindRoot

So I set a function f[x] f[x_] := x*E^(-x) - 0.16064 Then I set a variable 'actualroot' to the function FindRoot, starting at 3 ...
12
votes
4answers
443 views

Recovering intermediate results from a Table after an interruption

I am interested in knowing if it is possible to recover intermediate results from a Table after an interruption. Let us say I want to produce a really useful table ...