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
4answers
177 views

Generate list of strings from a list of assigned variables

How do I generate a list of strings from a list of assigned variables? Eg. Convert ...
6
votes
2answers
146 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 ...
6
votes
2answers
292 views

Why is CityData[All, “Coordinates”] failing?

When I evaluate CityData[All, "Coordinates"] Mathematica returns {Missing["NotAvailable"], Missing["NotAvailable"]} ...
6
votes
2answers
467 views

How Can Notebook Know When it Called by Another Notebook?

I would like a notebook to behave slightly differently depending on whether it is evaluated from another notebook; i.e., ...
6
votes
2answers
202 views

Why does Mathematica appear to change the head of certain expressions?

I don't know if the question trivial or not (if so I will delete it), but here is what I have: I know that x x (* x^2 *) Looking at the full form gives ...
6
votes
2answers
209 views

Evaluation in lambda function

If I have a function, that returns a function, for example: f[a_] := a^2 * # & then f[3] == 3^2 # & Is there a way ...
6
votes
2answers
135 views

Partial result of aborted evaluation of FullSimplify

When FullSimplify invoked on a large expression, it can run for hours. If I do not have time to wait, and abort the evaluation, I get no result, although, ...
6
votes
2answers
508 views

How do I make NotebookEvaluate work inside Button?

The following creates a button to select a notebook to run. When the button is pressed it seems that Mathematica finds the notebook but cannot evaluate it. The following error occurs Could not ...
6
votes
3answers
123 views

Explicit use of Evaluate not behaving the way I expect it to

I discovered a strange behavior of the Evaluate function. Case 1: ...
6
votes
1answer
618 views

How is the Mathematica kernel structured internally, and how does evaluation work?

There is so much information available for Java--the internal details of (for example) the JVM memory manager are well-documented, and the performance considerations arising from its interaction with ...
6
votes
1answer
425 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 ...
6
votes
2answers
163 views

There is an issue with Manipulate in which it updates its argument twice in V10

I have asked this question before (here) and I thought that the issue is only when moving the Notebook window. It appears that Manipulate is working in weird manner. ...
6
votes
2answers
104 views

Showing “updating…” message while Manipulate is re-evaluating

Is it possible to show a fixed text such as "updating..." instead of the last result shown, when Manipulate is re-evaluating an expression (in a slow evaluation ...
6
votes
1answer
165 views

Machine Epsilon

I'm trying to evaluate the machine epsilon of my computer (see below). I wrote this: ...
6
votes
1answer
251 views

How to simplify expression and use HoldForm at the same time?

Hopefully a simple problem for the experts here. I have a need many times to build a symbolic expression for an equation (say a PDE) to use for plot labels in a low level function inside ...
6
votes
1answer
287 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 ...
6
votes
1answer
68 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
150 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
349 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
618 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: ...
6
votes
1answer
90 views

Strange behavior when setting NumericQ of a symbol

It happens both in v9&v10. If you try this a^0 a^0 (1/a)^(3/2) a^0 (1/a)^(5/2) Mathematica returns 1 (1/a)^(3/2) (1/a)^(5/2) It's trivial. ...
6
votes
1answer
192 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 ...
5
votes
5answers
228 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
251 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
1answer
149 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
113 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
2answers
180 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
107 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
2answers
235 views

Associativity of `/@` [duplicate]

Why are the following not equivalent: Map[Line, Map[(Print[#]; #) &, {{{2, 1}, {1, 1}}, {{-2, 1}, {3, 1}}}]] which produces ...
5
votes
3answers
242 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
5answers
761 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
1answer
407 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
232 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
287 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
2answers
116 views

Why does Rule behave like this?

Why does {x, x^2, x^3, a, b} /. x^n_ -> f[n] result in {x, f[2], f[3], a, b} when ...
5
votes
2answers
241 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
732 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
3answers
592 views

Prevent Mathematica to automatically evaluate Manipulate at start

I'm using an initialization cell to import a lot of data: data = Import[myFiles]; and then I use a custom function to display this data with Manipulate: ...
5
votes
2answers
816 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
4answers
476 views

Delayed evaluation of assignment

I have a set of PDE's that depend on parameters. They depend on many parameters, but for simplicity we can here assume that they depend only on one, say a. I want ...
5
votes
2answers
334 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
159 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
1answer
159 views

How to understand the difference between Sqrt and Log after ClearAll them

I came across this post, here I change the last line of the code Unprotect[Sqrt]; Sqrt[x_] = "blahblah"; Protect[Sqrt]; Sqrt[2] "blahblah" ...
5
votes
3answers
228 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
239 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
118 views

How is LHS = RHS; … ; RHS (nontrivially) different from … ; RHS

I'm trying to understand how Mathematica thinks about the results of Set. Suppose we perform LHS = RHS. I'm focusing on when ...
5
votes
1answer
297 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
192 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
154 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
320 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, ...