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

learn more… | top users | synonyms

16
votes
1answer
237 views

Exclude Sections/Subsections/… from evaluation

I'm working on a large notebook and I want to exclude some sections and subsections from being evaluated when I evaluate the whole notebook. Is there a way to exclude specific sections or ...
1
vote
1answer
278 views

Summation of If statements

The following made me curious. Suppose you want to sum the if statement If[x[i] < 1., x[i]^2, 0.] over i=1,2, i.e. ...
3
votes
1answer
170 views

Evaluation order of Button[]'s action

it looks like it should be well known issue but I haven't found answer anywhere. Please tell me why the result (after clicking) of this: ...
15
votes
1answer
421 views

Using Evaluate and Evaluated -> True in Plot

A few use cases: (1) This, as expected, returns (almost) immediately: f[x_?NumericQ] := Evaluate[(Pause[1]; x)] Plot[f[x], {x, 0, 1}] (2) This takes ...
0
votes
2answers
225 views

How can I get the approximate analytical solution to this simple algebra equation?

Is there a way to get the analytical form to the root of this equation 2 A e (-ArcTanh[smax/s0] + ArcTanh[(smax Cos[w \[Zeta]])/s0]) == F0 ...
1
vote
2answers
646 views

Derivative of a spline approximation

To approximate an experimental data function $f(t)$ with $t \in (t_{min},t_{max})$ I used a cubic spline $s(p)=(t(p),f(p))$ with the parameter $p \in (0,1)$ and $p = t/(t_{max}-t_{min})$ by using the ...
3
votes
1answer
265 views

Log function - why is Log[b,b] not being evaluated to 1?

Have been experimenting with the Log function to demonstrate simple Log relationships such as Log[xy], Log[x+y] etc. ...
3
votes
2answers
105 views

UpValues evaluation with Dot operator

I would like to simplify some database notation, and I'm doing some tests with UpValues for that. For example, if I set this Upvalue fot tab1: ...
0
votes
1answer
286 views

Make Mathematica wait before replacing?

How can I force Mathematica to completely evaluate a subexpression before using a replacement rule? For example, consider the following definition (for the series of ...
5
votes
1answer
126 views

how to print stack trace when TimeConstrained times out

According to the documentation, TimeConstrained generates an interrupt which interrupts the computation. This interrupt is treated just like an abort, at least in ...
21
votes
2answers
358 views

Evaluation of OptionValue[]

I have a function that takes an OptionsPattern and I want to access several options, say a, and ...
0
votes
1answer
504 views

Array of functions, evaluation in plot

I would like to create two arrays of functions yfunc[[i]] and tfunc[[i]], with each entry of those functions being a function ...
8
votes
1answer
118 views

How to catch the “Preemptive” evaluations from within the main loop?

When trying to make an optimized version of my plotRange fonction I faced a problem of catching the "Preemptive" evaluations ...
4
votes
0answers
71 views

Problem with inequality using refine

I am using inequalities to follow some line of reasoning in Mathematica and I came across a problem I can not explain to myself. Does from a>=0 and b>=0 not follow a+b >= 0? How does Mathematica ...
7
votes
4answers
228 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
299 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
50 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
152 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
154 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
183 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
423 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
220 views
9
votes
1answer
94 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
255 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. ...
18
votes
1answer
699 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 ...
9
votes
1answer
273 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
126 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
323 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
206 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
276 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
130 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
161 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 ...
5
votes
2answers
5k 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 ...
14
votes
2answers
257 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
128 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
662 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: ...
5
votes
1answer
379 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
67 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
569 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
127 views

Pre and Post in a Block[]

Why does Block[{$Pre = ( 1 + #) &}, 1] produce 1 while ...
7
votes
1answer
189 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
145 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
248 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
211 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
100 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
135 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
575 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 ...