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
45 views

Apply a function to the current selection in place

Say a have the function foo: foo[x_] := x + 2 Like the Evalution ...
10
votes
2answers
347 views

How do I get Mathematica to return a function call unevaluated?

How do I get Mathematica to return a function call (conditionally) unevaluated? I expect this may use the slightly-mysterious Hold function. As a toy example, ...
0
votes
2answers
70 views

Simplifying Fourier transform of a complicated function

I would like to evaluate the following expression but takes too much time. I would be greatly appreciate for any comments to make it fast. ...
1
vote
0answers
38 views

can I evaluate multiple cells at the same time? [duplicate]

my laptop has 2 cores, can I assign a core to evaluate one code, and the other core for another code in parallel instead of evaluating in sequence? thanks
0
votes
1answer
51 views

Optimizing repeated function calls

Easiest way to keep my library nice, is to naively call some functions many times with same parameters. Doing so prevents from zoo of (library-)global variables and complicated initialisation ...
2
votes
1answer
65 views

Defer parts of the expression

Is there a way to Defer only parts of the expression? For example, I have a=1; and then I want the expression to be shown as...
5
votes
3answers
105 views

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

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

Symbolic integral including Hermite polynomial does not evaluate

I am trying to evaluate the following integral: Integrate[HermiteH[n, Sqrt[a]* x] * Exp[- (c/2)* (x^2 + y^2) + b* x * y - (a * x^2)/2], {x, - Infinity, Infinity}] ...
3
votes
1answer
122 views

Why even try the semantic constraints, if expression can't match the pattern structure?

This result is unexpected: Trace[MatchQ[{7}, {_?NumberQ, __}], NumberQ] (* -> {{NumberQ[7], True}} *) Why evaluate ...
0
votes
1answer
93 views

Getting unevaluated function expression

Say I've got a function f[x_] := a x^2 + b*x + c; and later set for some other reason a=1; how can I get the expression of f in ...
2
votes
2answers
93 views

Handling a sequence of unevaluated arguments

I have the following piece of code: ...
2
votes
1answer
94 views

Wrapping at evaluation for inline cell

I've been playing with inline evaluation and I've came to the conclusion that it's most convenient to put the Dynamic@ inside the inline cell, so I've started to ...
4
votes
1answer
120 views

Example from Mathematica documentation (ExtremeValueDistribution) seems to be evualting “forever”

I am referring to this example at the reference page for the extreme value distribution: http://reference.wolfram.com/mathematica/ref/ExtremeValueDistribution.html#6764486 The first three commands ...
2
votes
2answers
121 views

Time delayed evaluation of a function

I'd like to write a function that delays the evaluation of a function (say) $5$ seconds after I hit Shift+Return. Is this possible?
1
vote
1answer
153 views

Why is evaluation Enter for Mac and shift+Enter for Windows? [closed]

Per the title, why is evaluation done using just the Enter key for Macintosh and shift+Enter for Windows? UPDATE Okay, I see the Mac keyboard's "Enter" key is actually labeled "Return", so by Enter ...
1
vote
0answers
30 views

How to Plot a function that returns multiple values? [duplicate]

I have a function that returns multiple values, like this: f[x_] := ( (*... something ... *); {y1, y2}); They are computed together, so there's absolutely no ...
0
votes
2answers
53 views

Evaluate differentiation after replacement

The problem is Find two linearly independent solutions of $2x^2y'' -xy' + (-4 x + 1)y = 0, \, x>0$ of the form $y_1 = x^{r_1}(1 + a_1 x + a_2 x^2 + a_3 x^3 + \cdots)$ and $y_2 = x^{r_2}(1 + b_1 x ...
2
votes
2answers
164 views

Expectation of a family of random variables

I did some search here, but seems that no one asked about this. I want to define a family of independent and identically distributed random variables, $x_1,...,x_n$, and then calculates the expected ...
2
votes
0answers
49 views

What is “ (Dialog) Input [ ] := ” after evaluating a cell?

I have done a time-consuming run and calculation. After many hours ( about 7 hours!), the black color which shows that the cell is evaluating, turn into gray and a strange text appears like this : ...
0
votes
0answers
50 views

Numeric function not fully evaluating

I'm running into an issue where it seems Mathematica is not fully evaluating the output of my function h[t_]. I included the definition of phi[t_] just to demonstrate that it is a numerically defined ...
7
votes
2answers
163 views

Nothing appears in simple plot

I'm trying to get the following simple code to work. (The code is just supposed to graph the norm of the second derivative of a vector function). ...
5
votes
1answer
166 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 ...
7
votes
3answers
216 views

Graphics in Notebook Different from Graphics Expression?

Consider the expression TreeForm[a+b^2+c^3+d] which displays as This is a nice Graphics object, as I can prove by typing ...
0
votes
1answer
89 views

Why does evaluating an integral within a Plot expression take so long? [duplicate]

I want to evaluate Plot[Integrate[Sin[((1 + 1/2) x)] (1/(2 Sin[(x/2)]) - 1/x), {x, 0, t}], {t, 0, 5}] but it takes ages to load on Corei3 computer with ...
8
votes
2answers
133 views

Half-delayed evaluation

In a certain wider context, I need to make some delayed definitions, such as x := a + b + c, but within these definitions I want ...
0
votes
0answers
30 views

RandomReal behavior in Block environment [duplicate]

I ran into an unexpected behavior of RandomReal function inside the Block environment. If I simplify my problem: I wanted to use two random local variables, such that the second one would be less that ...
0
votes
0answers
38 views

Notification when evaluation completes [duplicate]

I thought it would be fun to see a list of ways to have Mathematica notify you when a long evaluation completes. There are a few posts up already that address specific methods, given below, but not ...
1
vote
2answers
139 views

How to evaluate Modules in a notebook from another notebook?

I would like to create a notebook populated with several modules and be able to evaluate these modules by running a separate notebook. I have attempted several uses of the ...
0
votes
0answers
36 views

Number precision in a list [duplicate]

I have list with elements: ...
0
votes
1answer
95 views

Evaluate integral of a series

I want to evaluate this integral, but it won't work. Does anyone knows why? ...
2
votes
2answers
72 views

Can I have Mathematica show intermediate forms before final evaluation?

If I have x = 2 and I want to evaluate y = x^2 I would like to the output to show ...
0
votes
0answers
92 views

How to modify the file “KeyEventTranslations.tr” to use Enter to evaluate the current cell? [duplicate]

I asked the following question before, but I do not think it has been fully answered. By default, we use Shift+Enter to evaluate the current cell, and use Enter to get a new line. Is there a way ...
1
vote
2answers
81 views

Extract the real components from a very large expression

Suppose I have a very long expression (>500,000 characters) which contains a mixture of real and imaginary terms. e.g ...
2
votes
1answer
38 views

is there a way to construct a pattern that would trigger when an expression is used as a held/unevaluated in some form?

For example, consider the following code f[x_] := (Print["evaluated f"]; workWith[x]); We use it, then f evaluates: ...
3
votes
0answers
171 views

A design of abstract data structures: How robust is the presented design? [closed]

EDIT: An envisioned answer to this post should be in the form of a mathematica code that can demonstrate how the internal checks discussed below can be bypassed. Everything goes... On my part, I think ...
2
votes
1answer
202 views

Nested Derivative

These two expressions are mathematically the same, but when substituting with the same rule, yield different results. What is happening? ...
2
votes
2answers
307 views

Integrating a Simple Piecewise Function

If I define f[x_]:=If[x<0,-1,1] and then integrate,say Integrate[f[x],{x,-3,7}] I get what I expect, namely 4. But ...
3
votes
1answer
77 views

Where do Mathematica's probability functions draw a line in the sand for predicates?

Thinking about a recent question mis-posted here (belonged on math), I noted the following. A contrived example - probability that a or b are 1: ...
8
votes
1answer
170 views

Why does Plot[Hold[x], {x,0,1}] work?

It appears that, counter to my expectation, all of these (and probably many others) seem to work fine: ...
2
votes
0answers
66 views

Assign a value to a variable without using Set or SetDelayed?

I supose probably yes, but at the end I assume that internally mathematica has to use Set or SetDelayed. Am I right? Background: I am developing a super simple phraser that takes a code description ...
2
votes
2answers
90 views

Merging two held expressions into a held compound expression

Consider e1 = Hold[a = x + x; b = y + y + y]; e2 = Hold[c = a + a + b + b + b; c^2]; How can I obtain the following? ...
0
votes
0answers
49 views

Dynamically Update Inset within Graphics with RunScheduledTask

I followed the instructions given below to play with RunScheduledTask within DynamicModule. ScheduledTask with scoped ...
1
vote
1answer
46 views

Commutative algebra by generators and quadratic relations

My apologies if this has been asked before. Please also be gentle, as this is my first question here. I am trying to define a commutative algebra by generators and relations in the following way. ...
3
votes
2answers
135 views

Stopping a head from evaluating more than once

While attempting to answer my own question, Is there a way to "hold" prefix / infix / postfix notation?, I came across the need to evaluate a recursive function only one level deep. For ...
12
votes
2answers
109 views

Why the Block command does not forget the $ContextPath variable

I do not understand this behavior: ...
9
votes
2answers
294 views

How to see which arguments are passed into a function

It is often that one wonders which arguments are evaluated before being passed into a function. I would like to know if it is possible to see which argumets are being passed into a function without ...
11
votes
4answers
270 views

Replacing parts of a held expression with held parts of another expression

I'm applying the Trott-Strzebonski technique in order to replace inside a held expression. ...
1
vote
1answer
43 views

Cell seems to be evaluating in exponential time even though it shouldn't

I am trying to implement Newton's method for a given function f[x] and a starting x-value xval. The code should print out each new x-value as it approaches one of the zeroes of the functions. g[x] is ...
4
votes
2answers
64 views

With command does not behave as expected according to its Attributes

The attributes of the With command are HoldAll which means it should not evaluate its arguments before its starts its business. ...
0
votes
2answers
80 views

Defining Piecewise Functions in Modules

In short, my question is the same as my previous one except that everything is now wrapped up in a module. The relevant code I'm working with is: ...