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
1answer
183 views

ScheduledTask with scoped variables. Working with timed evaluation

I guess I have to try harder and focus more but timed evaluation always frustrates me. I will show the issue on simple example of delayed trigger. ...
8
votes
3answers
194 views
0
votes
1answer
99 views

Solving NLODE with substitution

I am trying to get a solution to a non-linear ODE, below is the code that works for my problem. ...
10
votes
3answers
161 views

Creating a custom context with a Hold construct

I'm trying to create a function "InContext" to execute a piece of code inside a certain context (and to return the result of evaluating that piece of code). One approach is to place the code inside a ...
5
votes
2answers
151 views

Remove versus ClearAll

What is the difference between Remove and ClearAll? I thought that "not being recognized by Mathematica", which is the effect ...
2
votes
3answers
115 views

Dynamic plot with Evaluate on expression

I'm trying to make a make a plot of a table of expressions, which should be pre-evaluated (since they are infinite series with analytic sums). I'm able to make the plot normally with ...
1
vote
1answer
103 views

Caching data in Mathematica package

Consider the following: m=Quantity[1,"meter"] If I run the package, it will return 1m But when I load the package, the ...
1
vote
1answer
101 views

Evaluation of second argument to NIntegrate

Apologies if this is a duplicate, but I couldn't find it. The expression Integrate[x^2, Flatten[{{x},{1,2}}]] evaluates properly, to $\frac{7}{3}$. However, ...
0
votes
1answer
138 views

Plot[ D[Sin[x]] ] and Evaluate[] [duplicate]

Why does t = 2 Pi; Plot[D[Sin[x],x], {x,0,t}] (* Plotting the derivative of Sin[x] *) not work, but ...
17
votes
1answer
389 views

Incorrect result from Integrate

I attempted to calculate the following integral: ...
1
vote
1answer
109 views

Printing intermediate calculations in an external file, while suppressing the output in the notebook

I'm trying to construct a text-file that contains all the operations that Mathematica performs when evaluating an expression. However, i'd like to suppress all output in the notebook in which I'm ...
7
votes
3answers
212 views

Why does Mathematica not seem to know that $i^x$ cannot be equal to $0$?

I am experiencing a curious behaviour of Simplify when handling expressions involving powers of $\mathbf{i}$, such as $\mathbf{i}^x$ where $x$ is unknown. For ...
1
vote
1answer
134 views

Passing a joined list of symbols for Module or Block to treat as its own local symbols

The Question I'd like to write a function which itself takes a list of symbols, e.g. Foo[{x, y, z}] to pass to Module ...
2
votes
1answer
367 views

Is there anything like a C pointer (or returning a reference) in $Mathematica$?

I want to do in Mathematica what the following does in C. ...
0
votes
1answer
85 views

Plot producing many error messages when given complicated function

I'm new to Mathematica and am running in to all sorts of silly difficulties with coding in it. I'm trying to calculate a function f[x, k], normalise it with another ...
2
votes
1answer
205 views

Why is this expression being held, and how can I evaluate it?

I can't figure out why an expression isn't evaluating, even though there's no Hold* in its FullForm: ...
5
votes
1answer
121 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 ...
11
votes
4answers
299 views

Using With to scope over pure functions

Consider this example: given an option for a function func as "x" :> (a&), how can one assign different values to ...
1
vote
1answer
40 views

Output cell written with NotebookWrite dissappears on whole notebook evaluation, yet remains if I individually evaluate it

Create a new notebook with the following two input cells: NotebookWrite[EvaluationNotebook[], Cell[BoxData[ToBoxes[Manipulator[Dynamic[x]]]], "Output"]] and ...
0
votes
1answer
75 views

Evaluate outer function first

I'm new in Mathematica so this is maybe super easy to do, but I can't figure out how. I've got a function plus[a,b] that sums two numbers and I need to implement a ...
12
votes
3answers
195 views

Selective evaluation of blocks of code in a Manipulate

Is it possible to attach certain pieces of code to certain controls in a Manipulate? For example, consider the following Manipulate ...
7
votes
3answers
833 views

Keyboard shortcut to evaluate notebook

(If this is entirely trivial, although I couldn't find an answer as much as I searched the archives, I will delete the question.) How could I add a keyboard shortcut to evaluate the entire notebook ...
6
votes
3answers
259 views
7
votes
3answers
115 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
101 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
51 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 ...
12
votes
4answers
317 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
328 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
385 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
195 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
49 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
173 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 ...
17
votes
1answer
183 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
148 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
304 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
246 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
164 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
102 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
250 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
176 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
71 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
330 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
123 views

Understanding output of multivariable integration

I'm new to Mathematica and I'm trying to integrate this function: ...
3
votes
3answers
141 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
2k 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
311 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
52 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
169 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 ...
2
votes
0answers
104 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? ...