Tagged Questions

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

learn more… | top users | synonyms

7
votes
3answers
121 views

How to stop a single function to be evaluated?

See this example: AA = {x} \[Function] Normalize[x] BB = {x} \[Function] Evaluate[AA[x]*5] I need BB to be Normalize[x]*5. Some context:I call evaluate because ...
0
votes
1answer
116 views

Order of evaluation in nested expression

I am trying to make a function that works as follows: Integrate 1 for all t in the interval $ [0,1] $ such that the first element of function vstar is positive. ...
0
votes
0answers
56 views

CreateDocument using a specific Evaluator (Kernel)

I was trying to build a button to create a new document that contained a dynamicaly changing table. In the parent notebook i am using another kernel - not the usual "Local". The problem is that in the ...
14
votes
4answers
346 views

Prevent graphics render inside held expression

Assuming each odd line is input I would like the even lines to be the output of the following lines. In the above the Graphics are inside ...
6
votes
2answers
421 views

Obtaining the name of a variable as a string [duplicate]

Suppose that I have an arbitrary variable myVariable. Is there some function fun -- either built-in or one that I can define -- ...
15
votes
8answers
394 views

Is it possible to use RandomChoice to choose without other choices being evaluated?

I'm trying to do this: i1 = 1; i2 = 1; RandomChoice[{ (i1 = i1 + 1), (i1 = i1 - 1), (i2 = i1 + 1), (i2 = i2 - 1)}] In order to chose randomly which ...
7
votes
6answers
199 views

How to join held Lists?

Let's say I have a = Hold@{2+2} b = Hold@{4+4} How can I get Hold@{2+2,4+4} ie join the two held lists ? More ...
2
votes
1answer
51 views

Label cell goes away with SelectionEvaluate

When a given cell has a label (given with the CellLabel->"label" option of the cell), then this label disappears after calling SelectionEvaluate[ nb ] when the ...
2
votes
1answer
191 views

Manipulate executes expressions multiple times

I am using Manipulate for a rather intricate front end for data visualization. I was getting very sluggish performance and was able to boil the problem down to a ...
19
votes
1answer
193 views

How to get Cases to wrap results in an arbitrary head?

A number of functions provide for results to be wrapped in an arbitrary head. This is very important in cases where the results should not be evaluated. Take ...
2
votes
1answer
182 views

Dynamic [ NotebookEvaluate [“_”] ]

A nice way to centralize various tasks in one notebook is the NotebookEvaluation function. For instance I can evaluate ten notebooks from a single notebook (e.g. ...
2
votes
3answers
341 views

Select sublists with second element nearest to zero

I've got some big lists from which i need some data (one of the big lists). To be specific, I need to divide this biglists in sublists of the same length (10000), and form a new list with the mean of ...
7
votes
1answer
260 views

How to force an evaluation to use only one core?

There are some evaluations which are automatically parallelized or multithread if there are cores available.( for example, Eigenvalues) But I don't want the ...
8
votes
1answer
173 views

Why is building a table of function values so much slower than just plotting the function?

Here is a function that take some time to evaluate: n = 1000; coeffs = RandomVariate[NormalDistribution[], n]; f[x_] := Sum[coeffs[[k]] Sin[k x]/k, {k, 1, n}]; ...
2
votes
1answer
112 views

Reuse local variable in declaration within With [duplicate]

Considering the richness of Mathematica.SE, I am quite surprised I could not find my answer... I am very sorry if it is a duplicate. Consider the following example: ...
2
votes
1answer
304 views

Use output of NDSolve as an integration limit of NIntegrate

I've been working on a ODE, for a function y[t], that, due to it's complexity, has to be solved numerically. I then need to use the results of NDSolve, which I ...
2
votes
1answer
207 views

is there a method to send different cell evaluation to different core

I am running Mathematica on a computer with mulicpu and every cpu has multicore. I am wondering if there exist a method to send different cell evaluation to different core? So if I already have a ...
2
votes
0answers
76 views

Assign variables from list inside With or Module

I have found that it is possible to assign variables from lists, as follows. In[1]:= r = {1, 2, 3}; In[2]:= {a, b, c} = r; In[3]:= b Out[3]= 2 However, if I try ...
0
votes
1answer
408 views

Can graph interpolating function, but not use it. Any thoughts?

When solving a system of differential equations numerically, I get two interpolating functions. I can graph both of these, but when I try to evaluate either of the functions at a point, it just spits ...
0
votes
1answer
135 views

Understanding output of multivariable integration

I'm new to Mathematica and I'm trying to integrate this function: ...
3
votes
3answers
154 views

HoldForm: how does it interact with nested evaluations?

Here's an example to illustrate the issue I'm having. right = 8 - y; left = y^2 + 6; integrand = HoldForm[Evaluate[right]] - HoldForm[Evaluate[left]] (I ...
2
votes
2answers
3k views

Step-by-step definite integration

I am interested in obtaining the intermediate steps for rather straightforward symbolic definite integrations (e.g., from an elementary calculus text). As an example, for $\int_0^1 x\,dx$ I'd like ...
3
votes
1answer
383 views

How can I save the current evaluation state of a notebook and start from it later?

I currently have a nested Table command running (in Mathematica 9), with two progress bars to track the variables. I have to shut down or hibernate the computer in ...
1
vote
2answers
54 views

Get the unevaluated expression from a numbered cell

If a cell exists as below: In[1] := (xyPoints = {{1,2},{2,5},{3,10}}; ListLinePlot[xyPoints]) Is it possible to get at the expression rather than the plot shown ...
10
votes
3answers
184 views

Pattern matching on Orderless functions inside Hold

MatchQ[Hold[1 + 2], Hold[2 + 1]] returns False. But in the presence of a Blank[] in the ...
3
votes
0answers
118 views

Force Dispatch to generate dispatch tables

Dispatch creates hash tables only for lists of length larger than 3. Is there any way to force MMA to create hash tables even for lists of length smaller than 4? ...
0
votes
1answer
263 views

Pull Constants outside of integrals

I would like Mathematica to pull constants outside of an integral: e.g., $\int_0^t f[t] g[s] dt \to g[s] \int_0^t f[t] dt$ This has previously been discussed at replacement rule to pull independent ...
2
votes
2answers
178 views

While loop doing cell evaluation not completing

I am trying to get a loop structure using While to repeatedly evaluate another cell referred to in its body (using a cell tag). ...
2
votes
1answer
117 views

NotebookWrite undo

Is there way to make NotebookWrites undooable? For example let's say I open a new notebook and then run. ...
1
vote
1answer
448 views

The underlying process of Integrate[] [duplicate]

Integrate[x^4 E^-x^2, {x, 0, +∞}] Output: (3 Sqrt[π])/8 Can someone explain to me the specific calculation process ?
1
vote
2answers
106 views

Evaluation of elements in a list and then sorting them

This is probably a simple problem, but I'm having a lot of issues with it because I'm unfamiliar with Mathematica syntax. I have a list ...
7
votes
1answer
159 views

The Flat Attribute, Unevaluated and the Evaluation Process

To make this question easy to follow let's give some symbols a couple attributes. Attributes[f] = {Flat}; Attributes[s] = {Orderless}; Now consider the ...
14
votes
1answer
353 views

What is the real default CellEvaluationFunction?

The default CellEvaluationFunction is Identity but one can quickly see that this is handled specially as an equivalent function, ...
4
votes
2answers
135 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 ...
11
votes
2answers
301 views

Clever use of DownValues, or failure to understand the “Mathematica Way.”

I needed to look at the changes in the values of about 4000 items from one year to the next. I have a table with identifiers and values for each year. Not all of the items are in each list. The ...
1
vote
2answers
162 views

How can I speed up this plot manipulation? Why does Evaluate not help?

If I were able to "Save" the computed inverse function somewhere and then plot it, the manipulation would become faster. As I understand, Evaluate should do the job, but for some reason it does not. ...
1
vote
1answer
104 views

About evaluation in Block

I'm completely puzzled by the following codes: Clear[func, f] a = x^2 + z; func[k_] := Block[{f}, (f[x_] := Evaluate[(a /. {z -> k})]; f[1])] func[2] ...
2
votes
1answer
217 views

Expectation function does evaluate my expression

I am trying to evaluate the expression Expectation[(B x (-6 b + 12 a n0 + B x + B^2 x^2))/(2 (6 a + B x + B^2 x^2)), Distributed[x, BetaDistribution[α, β]]] ...
1
vote
1answer
241 views

How to tell Mathematica not to simplify an expression

While there is this question with a very similar title, it does not answer my question, which is: I have part of an input, in my case Re[Exp[I*x]] which ...
0
votes
0answers
175 views

Select and plot real positive solutions for a sixth order parametric equation

I need your help in order to solve the following problem: I have a sixth order equation: $ax^6+bx^5+cx^4+dx^3+ex^2+fx+g=0$ and I solved it using Solve[] command, ...
10
votes
1answer
193 views

TimeConstrained dynamic change of maximum time

I would like to run a time consuming function: TimeConstrained[f[x],maxseconds] and be able to change maxseconds during running (increasing or decreasing max ...
2
votes
0answers
186 views

Lazy evaluation/loading of parts of an expression

Is it possible to have an expression x such that its elements are only evaluated when they are individually accessed, for example when evaluating statements like ...
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
1answer
671 views

What do the hashtags represent in the result of Solve, and how should I use them? [duplicate]

There is a function that I'm trying to get the inverse of. My function is a simple polynomial: Tn[T_] := 4/9 T^3/Tc^2 + 5/9 T Now I tried to find ...
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 ...
-2
votes
1answer
217 views

Why doesn't Mathematica evaluate this limit?

I am trying to evaluate a few limits in Mathematica, and I can only get it to evaluate them in certain cases. I don't fully understand the evaluation order and when it substitutes numerical values in ...
8
votes
1answer
141 views

Is it possible to write a function immune to symbol redefinitions in any Block surrounding its invocation?

Normally, semantics of symbols used in a function definition can be changed by their redefinitions in Blocks surrounding the function invocation: ...
8
votes
1answer
122 views

Is it possible to use the global definition of a symbol as part of its new local definition set in a Block?

Consider the following expression: Block[{Print = CopyToClipboard}, doSomething[]] Now all calls to Print from ...
0
votes
0answers
116 views

How to evaluate only arguments, but leave topmost expression unevaluated? [duplicate]

I want to represent expressions mostly in unevaluated form, but being able to evaluate it's subparts. For example, how to evaluate only arguments, but leave topmost expression unevaluated? For ...