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

learn more… | top users | synonyms

4
votes
1answer
70 views
7
votes
2answers
124 views

Inserting symbols' definitions during read time of the code

Let's say we've got a package: ...
0
votes
3answers
76 views

Do not expand matrices in Mathematica calculation

Here is an example of a problem I'm having. Consider that I have defined: omega={{p[t]},{q[t]},{r[t]}} x={{a},{b},{c}} R={{1,2,3},{4,5,6},{7,8,d}} What I would ...
3
votes
1answer
96 views

A pre-parsed HoldForm

HoldForm holds an expression's parsed form not its actual "inputted form" e.g. ...
5
votes
2answers
202 views

How do I “evaluate in place” programmatically? Need to evaluate Defer[] result in non-interactive setting

I need to evaluate the result returned from an external package, which contains Defer in it, but do this in a script without user interaction. I am not able to ...
7
votes
1answer
111 views

Unevaluated @ {args} versus Unevaluated /@ {args}

Working my way through Robby Villegas's lovely notes on withholding evaluation, I almost got Polish Notation on my first try. Here is my final solution, which seems to work well enough: ...
4
votes
5answers
152 views

Using Through with SlotSequence

I have an expression consisting of a few pure functions added together like so: f+g+h I want to add the bodies of these functions together and make that a pure ...
2
votes
0answers
24 views

SelectionEvaluate executes out of turn

I'm seeing some unexpected (to me) behavior from SelectionEvaluate. I've got a notebook with two sections. In section 2, I've got code that clears the notebook's ...
1
vote
0answers
15 views

Manipulate inside Module - “Order of evaluation conflicts” [duplicate]

In this example, Manipulate is contained within a Module: ...
2
votes
1answer
47 views

Non-autonomous Dynamical system Sliding mode controller Error

This code is a simulation of a sliding mode controller of a non-autonomous dynamic. When I use ArcTan in input, I receive an error. ...
4
votes
2answers
103 views

Simplifying expression with non-commutating entries

Say I have an expression such as (a + X)**(b-Y) where the variables above possess the following commutation relations [a, b] = [a, X] = [a, Y] = [b, X] = [b, Y] ...
3
votes
0answers
50 views

Why does FreeQ seem not to work with complex numbers?

I guess I do not understand how Mathematica evaluates this simple expression inside FreeQ ...
2
votes
2answers
160 views

Optimize evaluation time for a Quantum Walk simulation

Here's the problem. I'm trying to simulate a noisy Quantum Walk to obtain results similar to these, experimentally obtained. I wrote my code, and I get results which are in accordance to what I ...
6
votes
0answers
131 views

NMinimize with NIntegrate (crash in symbolic evaluation, memory leak)

This is a "common" problem from what I've seen, but with a different spin. I have a function I use often that finds a fit of an expression to another expression with some free parameters (e.g. for ...
4
votes
1answer
65 views

How to define an expression which is differently evaluated in calculations and printed

Let's say, we have a list: values = {1.2, 0.04, 0.9}; Is it possible to replace 0.04 by some expression, which displays as ...
1
vote
3answers
58 views

Controlling the evaluation of other arguments in pure functions [duplicate]

I have a piece of code where I would like to do the something like the following: ...
1
vote
2answers
96 views

Why does Mathematica not evaluate the difference recurrence using `RSolve` or `RecurrenceTable`?

Mathematica does not evaluate the following recurrence of two variables using RSolve and only echoes the input: ...
4
votes
1answer
76 views

Formal Differentiation

I'm trying to formally differentiate an expression. (I am aware of how to differentiate formally?, but am unable to generalize the idea) For example: ...
6
votes
3answers
123 views

Evaluate a expression split in a list

I have a list with this format {integer, sign, integer, sign, integer}, sign being one of these: Plus, Subtract, Times, Divide. For example, let's say: ...
3
votes
1answer
139 views

Trouble with polynomial multiplication

Bug introduced in 10.1.0 and persisting through 10.2.0 or later ...
2
votes
2answers
91 views

How can I partially evaluate a function?

I have a multivariable function, from which I'd like to define a marginalization: f(a,b,c,d,...,z) ---> g(a,1,c,d,...,z) Generally, g will have fewer argument than f, possibly none (full ...
1
vote
0answers
69 views

How to Implement a “Function Object” suitable for NDSolve and Finite Element Method?

I have a bunch of methods that shoud return an expression that behave like a function, i.e. an expression that, when supplied with suitable arguments, evaluate to something. A simple ...
0
votes
0answers
81 views

Preventing Power from evaluating principal value [closed]

Can I prevent Power from evaluating the principal value and force it to keep the expressions in the exponential form until the end of all other evaluations? For ...
2
votes
3answers
53 views

Display a part of a notebook when MMA has done evaluating it

When you evaluate a notebook, it begins to slide upward and shows you a different part of your code, several cells upstream of the notebook... I was wondering if there is a command that could always ...
9
votes
1answer
162 views

Comparing exact expressions for equality — is it really OK if I get wrong answer?

Bug introduced in 7.0 or earlier and fixed in 10.2.0 I found an unexpected behavior (that I think of as a bug) in evaluation of the equality operator applied to mathematical functions with exact ...
2
votes
1answer
63 views

Failure in the use of FullSimplify

My question is about an apparent failure of the function "FullSimplify" to simplify an easy algebraic expression. This is the expression that I ask Mathematica to evaluate: ...
3
votes
3answers
100 views

How to force evaluation on the right of an @ operator?

Is there a way to force evaluation on the right before the Prefix operator (@) without using parentheses? I came across this question when I was working with the ...
6
votes
1answer
44 views

How to force evaluation of an expression with Part left unnevaluated?

My goal is to minimize a real valued multi-variable function averageFreeEnergyDensity. The function accepts an integer argument ...
5
votes
4answers
119 views

How to map Unevaluated over a list

I have a list {a1, a2, ...... , an}, in which all as have been initialized to a number. I want to get: ...
2
votes
0answers
43 views

Find the numerator of 6/8 [duplicate]

The statement Numerator[6/8] evaluates to 3. Numerator[Hold[6/8] does not work. What function NewNumerator[6/8] evaluates to 6?
4
votes
2answers
164 views

When are numerical expressions identical

Very elementary: 2 + 3 == 5 evaluates to True and 5 == 5 evaluates to ...
2
votes
2answers
74 views

Evaluation speed of apparently equivalent functions

Consider the following expressions: f[x_Integer] := x, f[x_] := x /; x ∈ Integers, f[x_?IntegerQ] := x All of the expressions above (and probably others which ...
4
votes
2answers
49 views

How to print unevaluated arguments in the form they were originally typed in?

I'm looking for a way to print a function's arguments, not only unevaluated, but also in the way they were originally typed in. By way of experimentation, I tried stuff like this: ...
1
vote
1answer
40 views

How to get Mathematica to abort the current evaluation if an assertion fails?

I can turn on assertions, but they don't terminate the current evaluation. For example: ...
4
votes
1answer
74 views
0
votes
0answers
31 views

Why is DownValues releasing RuleDelayed's hold for Graphics? [duplicate]

I am trying to understand DownValues in regards to the evaluation of its output. Consider this: ...
1
vote
1answer
46 views

GCD of Table entries

This question is from a newbie, so please be gentle in thrashing if I'm missing something very basic. How can I use GCD on a matrix/vector entries stored as Table. For example, if ...
2
votes
1answer
60 views

Why isn't Table iterator value inserted in failed NIntegrate arguments?

Consider this simplest example: Table[{z, NIntegrate[f[x], {x, 0, z}]}, {z, {1}}] Here f is not defined, so ...
6
votes
1answer
93 views

Debugging a $RecursionLimit error?

I sometimes encounter bugs that involve a recursion limit. It's often very hard to find the origin of the problem. Would there be a way to copy the stack somewhere and abort the evaluation in order ...
5
votes
0answers
154 views

Built-in symbols which are more close to the root/core of Wolfram Language

Seeing the vast scope of science covered by the Wolfram Language (WL) and the large amount of built-in symbols (functions), I am curious to know which built-in symbols are more close to the root of ...
0
votes
0answers
26 views

What makes items with head `Function` different?

I apologize beforehand for the muddleheadedness of this question. It reflects the fact that I'm trying to interpret outward "behaviors" of Mathematica expressions without having any understanding of ...
16
votes
1answer
371 views

Quit the Kernel and start new session automatically

The question is how to quit the kernel, start a new session automatically, and to be able to run such procedure from e.g. Button. This is especially useful when ...
0
votes
0answers
23 views

Timing of an Evaluation is not correctly displayed

From: http://reference.wolfram.com/language/howto/DisplayTheTimingOfAnEvaluationInANotebookWindow.html I ran a process that took about two minutes to finish. But the time recorded is only 0.18 ...
0
votes
1answer
60 views

How do you stop Mathematica from evaluating a sum? [closed]

A concentration $A(i,j)$ varies over i,j. I'd like to include the summation of $A(i,j)$ in my Mathematica expressions, but it evaluates the sum ...
1
vote
0answers
40 views

Unexpected order of evaluation in ForAll

I noticed that ForAll behaves rather unexpectedly when its first argument is a symbol which has been Set in an outer scope. For ...
1
vote
1answer
51 views

How do you programmatically update a tag using the TaggingRules mechanism?

Consider the following simple front-end code: ...
1
vote
1answer
47 views

Replace symbols in output without evaluation

I found the Wolfram example for ExpandNCM but I want a more human-readable output form. I want to evaluate ExpandNCM, for example with ...
-2
votes
1answer
113 views

Why does Mathematica “sleep” when I don't work at computer? [closed]

I started using Mathematica few days ago. I'm running this code: ...
4
votes
0answers
110 views

Why the flat f[x] is treated as ghostHead_[f[x]]?

While reading this answer I feel confused. If we do not care any specific detail of the original question, then ybeltukov's answer essentially makes use of the following fact ...
3
votes
1answer
226 views

Output an Expression in terms of GoldenRatio

Sorry if this is a dumb question (I'm new). I swear I searched and read forums first! I'm trying to rewrite expressions in terms of the Golden Ratio. For example, I know 9+4Sqrt[5] is Phi^6, but can ...