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

learn more… | top users | synonyms

3
votes
1answer
96 views

Manipulate a Plot that contains a variable that contains symbol

This snippet mm = m Manipulate[{mm, Plot[mm x, {x, 0, 1}]}, {m, 0, 1}] (m is not defined anywhere) produces a sadly fixed ...
6
votes
0answers
48 views

Performance of Dispatch and lists of Rules

First of all, I have seen the question "Why is this parallel evaluation with Dispatch[] so slow?", but that seems to be a different matter. My question arose when I tried to answer this question by ...
4
votes
3answers
109 views

Unexpected behavior of Unevaluated

Maybe it is about time I read some proper text about the main loop. Maybe I should not care (so much) about Unevaluated (as Leonid suggests). But I think this is an interesting question anyway. This ...
0
votes
3answers
64 views

Evaluation in Manipulate [duplicate]

I have an expression assigned to a variable. For example: exp1 = a*x+b Now I would like to plot it using something like this ...
1
vote
2answers
67 views

Overloading conjugate operator for a particular function

I trying to modify the behaviour of the built-in Conjugate[] operator on a particular function I have defined, to take into account that some of its variables are real. ...
5
votes
3answers
97 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 ...
28
votes
1answer
468 views

How to compare power towers in Mathematica?

First I tried it directly, but it overflowed: ...
0
votes
1answer
67 views
0
votes
0answers
60 views
0
votes
2answers
53 views

Automatically evaluating related cells

I have the cells: In[1]:= l = 2 + 2; In[2]:= l >= 5 After evaluating them: Out[2]:= False Is there a way to evaluate ...
1
vote
1answer
115 views

Confused about Unevaluated

Why does Map[Unevaluated, Table[PauliMatrix[i], {i, 1, 3}] give {Unevaluated[{{0, 1}, {1, 0}}], Unevaluated[{{0, -I}, {I, 0}}], Unevaluated[{{1, 0}, {0, ...
19
votes
2answers
631 views

Mathematica for Computer Scientists

Background I've coded in C/Scheme for 10 years. I have a BS CS. I've recently become very interested in pattern-matching (lisp's match macro), and term rewriting systems, which brought me to ...
1
vote
1answer
98 views

direct assignment to the element in a Table

I have already asked a related question here why set values in this way doesn't work? But I think I have to write the question which I encountered explicitly? ...
9
votes
3answers
210 views

Comparing Mathematica expressions like diff

I am looking for a way to compare (or "diff") two Mathematica expressions, similarly to how to diff utility can compare two text files and report the differences. Has anyone already written such a ...
2
votes
2answers
82 views

Evaluating Polynomials at Grid Points

I am continuing my quest on B-splines. The code below builds a 5x5 matrix out of B-splines, using the BSplineBasis[] routine. I now want to evaluate the polynomials that are stored in each matrix ...
0
votes
0answers
127 views

A SetDelayed issue [closed]

I get General::ivar: "-Cos[[Pi]/52] is not a valid variable. when I call the function below ...
7
votes
2answers
375 views

How do you force a decimal output? [duplicate]

I have some very small values such as 2.601519253*10^-8. I'd like to output these values to CSV for another program to work with. I've tried N[value, 50], but Mathematica still insists on producing ...
2
votes
1answer
224 views

GraphPlot only working when I evaluate twice

I have some code that builds a graph and some vertex coordinates, but when I evaluate it I get a message that the list of coordinates is not valid and the graph is not valid and it shows the output as ...
5
votes
1answer
90 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 ...
23
votes
9answers
748 views

Injecting a sequence of expressions into a held expression

Consider the following toy example: Hold[{1, 2, x}] /. x -> Sequence[3, 4] It will give Hold[{1, 2, Sequence[3, 4]}] ...
4
votes
2answers
175 views

Is there a way to show the details of a numerical computation?

I have recently started using Mathematica as a calculator while teaching (definitely overkill, but I try to use as few tools as possible). I would like my students to be able to trace simple numerical ...
4
votes
3answers
289 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 ...
0
votes
1answer
63 views

Can I force a function to quit and return some value after a certain amount of time has passed during its evaluation?

Imagine I provide some random input to function like FindInstance[], and I observe that, despite the existence of good solutions, the function will, with some ...
5
votes
2answers
137 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 ...
0
votes
2answers
72 views

Symbolic evaluation fails because it exceeds $RecursionLimit

I am trying to perform a simple arithmetic in complex algebra. ...
4
votes
2answers
137 views

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

When I evaluate CityData[All, "Coordinates"]` Mathematica returns {Missing["NotAvailable"], Missing["NotAvailable"]}` but when I evaluate ...
0
votes
4answers
113 views

Specify a variable as an integer

I have a formula that always evaluates to a certain number for any variable X under one condition that X is an integer and ...
2
votes
2answers
89 views

How do you configure Mathematica 9 to automatically evaluate all notebooks?

I have a Mathematica 6 course that I am using in Mathematica 9; there is no updated version. Every time I open a notebook I have to go to the Evaluation menu and click on "Evaluate Notebook". Is there ...
13
votes
1answer
395 views

Unique[] symbol not properly tracked

In a nutshell, why does this work (change y and see how the value updates) ...
1
vote
2answers
63 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: ...
2
votes
3answers
115 views

Alternative to using global variables in functions?

Often times I find myself using unevaluated variables (i.e. they show up blue) as dummy variables in whatever I'm returning such that I can evaluate them as needed later on. A simple example is as ...
23
votes
4answers
838 views

How do I evaluate only one step of an expression?

I am looking for a simple, robust way to evaluate an expression only one step, and return the result in a held form. The definition of a single step is ambiguous, and this itself is probably worthy ...
5
votes
2answers
167 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 ...
2
votes
0answers
42 views

Non-preemptive evaluation of a dynamic function? [duplicate]

I want to monitor a long calculation that is triggered by the release of a Slider. While one can indicate running calculations when the main evaluation loop is ...
2
votes
2answers
101 views

How to make Mathematica returns the exact expression I typed

I'm using Mathematica to compare some constants. Before playing around with those constants, I would like to check that I didn't make any mistake in typing them. So my question is the following: "What ...
1
vote
1answer
89 views

Evaluate code to some point

How can I evaluate my code, up to some point? I don't want to evaluate all of my code always. I have to use Shift - Enter for every line from the first cell up to the point I want to be, and it's not ...
8
votes
4answers
134 views

How to pass a list of arguments into HoldAll

I have a list of arguments (which in reality is lengthy): arguments = {a, b, c} arguments2 = {a_, b_, c_} f[Sequence@@arguments2] := a + b + c Note: It seems ...
4
votes
4answers
203 views

Efficiently finding the positions of a large list of targets in another, even larger list

I have a big list. It contains nearly 60,000 sub-lists. It's structured like bigList= {{x1,y1,z1},{x2,y2,z2},{x3,y3,z3},.....,{x60000,y60000,z60000}}; ...
0
votes
0answers
19 views

Define a Plot3D function with custom options [duplicate]

I am trying to define a Plot3D function with custom options, following (this previous SE question), but I'm running into a brick wall. I've narrowed the problem to the following 'toy' code: ...
11
votes
1answer
312 views

Get the current iteration count

I would like to be able to get the current iteration count, the one that if exceeds $IterationLimit makes the evaluation stop. After not finding a magical variable ...
1
vote
0answers
39 views

Confusing efficiency and evaluation when returning pure functions? [duplicate]

I have a function that takes some time to evaluate, that's meant to be a polynomial approximation to a function. The polynomial is defined by a list of coefficients, so I have the function ...
10
votes
4answers
148 views

How do I evaluate the terms in an expression, but not the expression itself?

I am trying to write a set of homework questions. I would like the output to evaluate the constants but not the sum, so that I may present the homework question as something like this: ...
5
votes
4answers
194 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 (...
0
votes
0answers
29 views

Finding solutions based on set criteria [duplicate]

If anyone would be so kind, I'm wondering if I could get a basic direction in Mathematica to begin coding a method for taking a set of resources (numbers and operators) along with a set goal/answer, ...
0
votes
1answer
81 views

NumericQ prevents evaluation at a numerical value sometimes

I set up a symbolic integral, to be evaluated only when some of the symbols have been replaced by numbers. The evaluation after assigning numbers to the symbols is still symbolic for some reason. The ...
4
votes
1answer
94 views

Identical code, different answers?

I'm having some trouble with identical code giving different answers. On a fresh kernel (MM 9.0.0.0, Windows 64-bit), running the same code, copy-paste, gives two different answers: ...
0
votes
1answer
84 views

Why won't ContourPlot accept a variable argument? [duplicate]

I have a list of linear inequalities which describe a (polygonal) region. I can use RegionPlot to visualize this region; but I'd also like to overlay this plot with ...
4
votes
3answers
136 views

Keep function range as a variable

Plot[2*x^2 - x + 2, {x, -1, 1}] plots a function of x from -1 to 1. As far as I can see, I cannot "save" this range in a variable: ...
3
votes
1answer
54 views

Stop TradtionalForm evaluating expression

I'm trying to get this expression to display as typed instead of evaluating the 1/1.121. ...
1
vote
1answer
99 views

Forcing evaluation of ArgMax

How to force evaluation of ArgMax before its output gets used in Solve? Background: I'm trying to solve for the Nash ...

1 2 3 4