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

learn more… | top users | synonyms

6
votes
1answer
64 views

How to reset the $ModuleNumber?

According to the documentation, we can reset $ModuleNumber to a positive machine integer. There is even an example in the doc: ...
6
votes
1answer
195 views

Difficulty catching thrown errors in asynchronous tasks

In this Question, Leonid explained that module variables can get garbage collected from a chain of asynchronous tasks unless their Temporary attribute is cleared ...
6
votes
1answer
78 views

Held keys in associations

Jacob Akkerboom commented: Note that PositionIndex does work correctly with held expressions, whereas this is a bit painful to implement using ...
6
votes
2answers
159 views

Menu item “Interrupt Evaluation…” missing in V10

The menu item “Interrupt Evaluation…” seems to have disappeared in Mathematica 10 on OS X. Well, this is a bummer. I personally use Mathematica for very long calculations, and I was using this ...
6
votes
1answer
115 views

Functional-Style Partial Application and the Accumulator Pattern?

Following up on Functional-style Fixed-Length Queue Object?, I want to generalize it to a functional-style accumulator pattern. Lots of things look like accumulators, loosely defined as binary ...
6
votes
1answer
315 views

PlotStyle does not work when plotting a non-evaluated list of functions [duplicate]

When a list of functions is passed to Plot in an unevaluated form (e.g. with Through), the result is a plot with single color. ...
6
votes
1answer
230 views

Can Mathematica do two evaluations at the same time?

When one evaluation is running, if I want do another evaluation, Mathematica will put the second one in the queue and run it after the first evaluation finish. However, the first evaluation may take ...
6
votes
1answer
577 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: ...
5
votes
5answers
214 views

How to make a table of $\sum_{i=1}^n$?

I want to create a table of $\displaystyle \sum_{i=1}^n i^k$ for $1\le k\le 5$. The output I want to obtain is a TeXForm output as follows. \begin{align} ...
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 ...
5
votes
2answers
513 views

Normal[Series[ ]] does not give a normal expression

Let us say I want to show how the Taylor's series for Sin behaves: ...
5
votes
4answers
4k views

Mapping multiple parameters of a function to specific values

I am a little bit confused by the documentation for Apply (@@). I want to define a list of parameters, for instance: ...
5
votes
1answer
145 views

Why does this pattern with Plus not work for numbers?

I have a very simple question about redefining basic built-in functions, such as Plus. I'm pretty sure someone must have asked a similar question around here, but I ...
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 ...
5
votes
2answers
108 views

ReplaceAll performance problem: packed arrays on the LHS are unpacked when the RHS is too long

The following is one of the most mysterious performance problems I encountered and came up while extending the booleval function mentioned here. I am looking for a ...
5
votes
1answer
105 views

“And” to continue evaluation after “False”

Below, is it possible to print No and have x be 2. That is, I'm looking for an And-like function that looks at all arguments ...
5
votes
3answers
234 views

difficulty abstracting the OptionValue pattern

I am building lots of functions that use Options and OptionValue and wanted to reduce the redundancy in the expressions that ...
5
votes
2answers
164 views

Remove versus ClearAll

What is the difference between Remove and ClearAll? I thought that "not being recognized by Mathematica", which is the effect ...
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 ...
5
votes
1answer
231 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, ...
5
votes
3answers
253 views

HoldFirst and inserting additional options into a Grid of Graphics

This is related to my earlier question, but is specific to an issue I have encountered with the use of the HoldFirst First, let's create some fake data for ...
5
votes
5answers
638 views

Prevent Part[] from trying to extract parts of symbolic expressions

If you have a list, e.g. {1, 2, 3} then you can extract the $k$th part using Part (...
5
votes
2answers
226 views

Why doesn't Evaluate appear to work in this RegionPlot example with MatchQ?

I am trying to plot the region over which a function of two (real) parameters a and b is real-valued, using ...
5
votes
2answers
698 views

Expression evaluation inside of FindRoot inside a Compiled Function

I'm trying to get some performance increase out of my own implicit differential equation solver using Compile[]. The uncompiled function is of the following form: ...
5
votes
2answers
697 views

Possible to evaluate only selected cells?

Is it possible to evaluate only the selected cells programmatically that I am interested in? Say in current cell to bottom of the notebook, instead of evaluate notebook or cells?
5
votes
2answers
316 views

Manipulate Evaluation Order Problem

I seem to be getting some unintended results from a nested Manipulate that I have not been able to resolve. I boiled down the problem I'm having to a simplified ...
5
votes
1answer
154 views

Impossible to bypass evaluation on returned values?

Following all the great advice on this other question, I'm now fluent with HoldAllComplete and Unevaluated on the input side of ...
5
votes
3answers
220 views

Applying a function with the HoldAll attribute inside NestList

I'm trying to write an update function, which can be applied to a list and then to NestList it. As the function has to manipulate the given variable I figured I ...
5
votes
2answers
234 views

Graph does not evaluate some options when not displayed

How can I force Graph to evaluate all its options without actually displaying the graph itself? Evaluating the following code ignores the ...
5
votes
1answer
219 views

Resume/continue interrupted evaluation

I interrupted an evaluation to quickly do something else. How do I resume the interrupted evaluation? I cannot open the "Interrupt evaluation" window, as it is disabled. There is no "Resume" button to ...
5
votes
1answer
274 views

Evaluation order control

This question is related to Evaluation order of Button[]'s action Concusion was, Button[]'s actions are evaluated in preemptive link so "the code that needs ...
5
votes
1answer
185 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 ...
5
votes
2answers
153 views

Strange Behavior when making Equal Listable in Pick

While trying to make this problem more efficient I tried different methods and dabbled with making Greater and Equal ...
5
votes
2answers
300 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, ...
5
votes
1answer
119 views

Changes in Handling of Real Zeros

I recently upgraded from Mathematica 5 to Mathematica 8 and I have a number of notebooks that no longer work correctly. The problems relate to the use of units. I don't need complicated unit ...
5
votes
2answers
683 views

Speeding up mathematica by subsitituting numerical values

According to this Wolfram Blog post, one can speed up Mathematica code by substituting numerical values as soon as possible. How does one substitute before the main expression is evaluated? The ...
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 ...
5
votes
1answer
81 views

How to track Part of Symbol or How to symbolize Parts of Symbol without copying data

Let's create simple function: SetAttributes[h, HoldFirst]; h[data_] := Dynamic[Grid[data], TrackedSymbols :> {data}] test = RandomReal[1, {2, 2}]; h[test] ...
5
votes
0answers
112 views

Are there any videos that show how different Mathematica expressions are evaluated?

Are there any videos that show how different Mathematica expressions are represented internally as object graphs and demonstrate how they are transformed during an evaluation? I am asking because I ...
5
votes
1answer
187 views

Strange Behavior with RegionPlot

Consider the following code. RegionPlot[Print[{x, y}], {x, -2, 2}, {y, -2, 2}, PlotPoints -> 2] ...
5
votes
0answers
157 views

Context “Unique to This Notebook” makes variables black even if they're not defined?

I'm trying to use this technique to keep variables separated between different notebooks. It seems to be working fine, except that variables turn black as soon as they are evaluated — any ideas why ...
4
votes
3answers
3k views

How to force 2+2=5

I was looking at this question (writing a program such that 2 + 2 = 5) and tried to write something in Mathematica, but I couldn't get something to work without completely replacing ...
4
votes
2answers
110 views

Choosing an initializer list in With

I'm trying to have several initializer lists in a With function and choose which one I want to use. So far I have this: ...
4
votes
3answers
385 views

Why the difference?

When I do the double sum using the sigma notation I get $$1 + \sum_{n=0}^{\infty}\sum_{k = n}^{\infty} \frac{1}{(k+2)k!}$$ $1 + e - \cosh[1]$ When I do the sums as below, I get the expected ...
4
votes
2answers
102 views

Difference between Evaluation>>Quit Kernel and Quit[]

What is the difference between Evaluation >> QuitKernel and Quit[]? Both seem to quit the kernel (and clearing all ...
4
votes
2answers
68 views

With command does not behave as expected according to its Attributes

The attributes of the With command are HoldAll which means it should not evaluate its arguments before its starts its business. ...
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: ...
4
votes
1answer
400 views

Can a Table iterator “leak” into a Module?

I want to repeatedly call a module by using a Table statement. When I use an i iterator in the Table command calling the module, I receive the error message ...
4
votes
1answer
131 views

Can $\it{every}$ usage of While be changed into NestWhile?

Ok, I think this problem is more close to philosophy. :P I've some idea now. But I'm not sure whether it's correct. For the purpose of convenience, I will use some C-like code instead of MMA's. A ...
4
votes
2answers
136 views

Equivalent of __FILE__?

Many languages define a special identifier whose value is the path to the source file currently being processed. (For example, in C, this is done through the ...