Questions about how Mathematica evaluates expressions, tracing evaluation (Trace*), handling expressions in unevaluated form (Hold*, Unevaluated), nonstandard evaluation, etc.
6
votes
4answers
224 views
Attaching persistent assumptions to symbol definition
Is it possible to attach assumptions to a symbol? This relates to this question. Most of my work involves physical equations, i.e. there are basic assumptions on variables that will always hold true ...
10
votes
2answers
253 views
DSolve cannot solve for certain branches of the solution
Could somebody please tell me, why I am always getting an error message when trying to run the following code:
...
3
votes
4answers
1k 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:
...
6
votes
2answers
416 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 ...
9
votes
2answers
106 views
A notebook created on demand from a main document showing executable input along with output cells
I would like to make Mathematica documents with hidden calculations, such that they can be visualized on demand. In general it can be done in several forms and I actually use some. I would like to ask ...
10
votes
2answers
176 views
Make a button that evaluates a function over and over
I would like to have a command "RedoButton" which would make a button (or whatever control is suitable) that when clicked would print the value of a certain function over and over in the same place. ...
10
votes
2answers
256 views
Unexpected differences with various uses of NormFunction
I would expect all of the following to give the same answer (2.12467) but only half of them give this answer. The others seem to be using the default ...
4
votes
1answer
243 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 ...
10
votes
1answer
258 views
Manipulate evaluation sequence
Manipulate doesn't always evaluate in the order I expect it to. What is the evaluation sequence for Manipulate and other ...
3
votes
1answer
166 views
FunctionInterpolation Errors / Question re Evaluation Order and Options
I have using Mathematica functions that takes a Cartesian coordinate relative to the Earth (xyz) and converts it to a latitude, longitude, and altitude (lla). And here it is:
...
7
votes
4answers
335 views
Force function to make assumptions about its input variables in Mathematica
I'm trying to force a Mathematica function to make an assumption about its input variables. In my case, I'm trying to define a function to return the pdf of a Gaussian. But let's use a simple toy ...
6
votes
2answers
354 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
226 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 ...
6
votes
1answer
132 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 ...
13
votes
2answers
302 views
How to REALLY Hold arguments and capture FullForm?
I'm trying to write an expression deconstructor or FullForm-capturer; might even call it a parser, maybe, but that might be too glorious a word.
I got some great ...
6
votes
1answer
173 views
Module variable scoping in Scheduled Tasks?
I ran across a scoping puzzle while experimenting with ScheduledTasks, and I'd be grateful for an explanation from the sages here. I found a workaround by intuitive horse sense, but was unable to ...
8
votes
2answers
218 views
Exporting held expressions through JSON
Trying to round-trip expressions through JSON, I'm getting unexpected errors for held expressions, and would be grateful for advice or clues. Consider, first, something that works well
...
3
votes
2answers
199 views
Efficiently evaluating a held expression directly from a list
I am able to evaluate a held expression that I have put on a list by:
ReleaseHold[expressionList[[1]]]
and
...
5
votes
1answer
113 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 ...
7
votes
1answer
176 views
How do I write a ValueQ function that only returns True if there exists an OwnValue?
Reading the comments in this answer has motivated me to request a full solution to part of this problem.
What I'd like is an efficient solution that returns True ...
15
votes
2answers
304 views
Implementing a safe ValueQ that does not evaluate its argument
Mathematica has a built-in function ValueQ. Quoting the docs,
ValueQ[expr] gives True ...
10
votes
3answers
188 views
Arguments to If[] are not evaluated
I got bitten by the following:
f[x_] := 3*x;
g[x_] := If[Log[f[x]] < 0, f[x], 0];
g[x]
Out[11]= If[Log[3 x] < 0, f[x], 0]
where I thought the call to ...
8
votes
1answer
265 views
How to properly DumpSave & Get Global`s symbols inside packages while not touching Global context?
For efficiency reasons I prefer to use DumpSave instead of Save.
For ease of access I prefer to save symbols in ...
10
votes
1answer
143 views
Old values are not freed/garbage collected when you re-evaluate an assignment
For this code:
(* Cell 1 *)
generate := Module[{x}, x = Range[100 * 1000 * 1000]; x];
(* Cell 2 *)
g = generate[];
MemoryInUse[]
If I evaluate cell 2 ...
5
votes
2answers
191 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 ...
6
votes
1answer
152 views
Changing the plot variable inside Plot [duplicate]
Possible Duplicate:
Difference in Plot when using Evaluate vs when not using Evaluate
Assume one has vector of functions (e.g., vec={x,x^2}).
The ...
5
votes
1answer
112 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 ...
10
votes
2answers
128 views
Subtle difference in conditional rules placement
I had gotten used to thinking of the placement of a condition in a rule definition as logically immaterial. In my specific example, namely
...
12
votes
4answers
426 views
Making a symbol's new definitions be tried before all previously defined ones
Is there any way to "close" a package (or a symbol, or a context) in that if a user of the package adds definitions to the symbol they will be tried before the package defined ones, just like what ...
8
votes
2answers
449 views
Mathematica rule substitution memory
First I present the specific programming question, and then I provide further background details.
Given an expression in Mathematica, say f=3x+7y, there are two ...
8
votes
2answers
306 views
How to make Mathematica re-evaluate a cell after some event?
I am doing a little project to demonstrate something:
...
9
votes
2answers
239 views
Defining a ForEach function
Consider the following function definition:
ForEach[iterators__] := Table[#, iterators] &;
Two questions about it:
I. It works perfectly if you call it like ...
1
vote
0answers
78 views
is there an equivalent of “show” steps? [duplicate]
Possible Duplicate:
Get a “step by step” evaluation in Mathematica
In wolfram alpha, when preforming for complicated integrals there's a 'show steps' option that explains how ...
8
votes
3answers
217 views
How to write a function-defining function which stores the function arguments in a stack?
I have a function-defining function
SetAttributes[DefFn, HoldAll];
DefFn[f_[args___], body_] :=
f[args] := body;
I am trying to modify this function to record ...
2
votes
1answer
245 views
8
votes
3answers
140 views
With/Function(/etc) replacement behaviour
Can anyone explain to me this behaviour? I've been having more than a couple of similar doubts these last weeks.
For example
f[_?NumericQ] := 8;
Now, if I do
...
21
votes
3answers
669 views
Difference in Plot when using Evaluate vs when not using Evaluate
This example comes from
the Mathematica documentation for Plot
under Basic Examples.
Can someone please explain why these are each plotted as a different color in ...
11
votes
3answers
218 views
Does AbsoluteTiming slow the evaluation time?
I've started using AbsoluteTiming to discriminate between similar function constructs, but I sometimes feel like it takes substantially more time to evaluate a ...
4
votes
2answers
158 views
Setting a lower limit on calculation time
Sometimes it can come in handy to set a lower limit for a calculation. Consider for example an animation that is generated by some infinite loop, which would run way too fast to display properly for ...
7
votes
3answers
919 views
General::ivar is not a valid variable when plotting - what actually causes this and how to avoid it?
I was just evaluating a couple of expressions and started to get errors like this:
...
7
votes
2answers
141 views
Bags and non-standard evaluation
What can internally be happening here? Is the evaluator just messing with us and going non-standard because its a Bag? Or am I just not seing how something like this could be done in MMA?
...
10
votes
2answers
329 views
How do you programatically load data into symbols?
I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to ...
16
votes
1answer
340 views
How do you set attributes on SubValues?
SubValues, as discussed in a previous question, are declared as follows
...
14
votes
5answers
275 views
8
votes
3answers
153 views
How can I test properties of a symbol from the string name without the symbol completely evaluating
Suppose I have a few symbols, one of which has a value:
{abc1, abc2 = 5, abc3};
I can use Names to get the list of names, as ...
5
votes
1answer
132 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 Manipulate, ...


