# Tagged Questions

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

1answer
86 views

### Why is my function returning 0 when when I try to give it arguments by replacement? [closed]

I tried running a function f with rules and calling it directly with arguments specified directly but the one with rules returns zero while the one with direct ...
2answers
122 views

### Force evaluation of the right-hand side of a local variable definition

One can do expression = a + 1; f[a_] := Evaluate[expression] but how would one do something like this ...
2answers
153 views

### Even with Evaluate[], Mathematica is plotting everything in the same color

The code evals[x_?NumericQ] := Eigenvalues[{{x^2, 2 x}, {x, 3 x^2}}]; Plot[Evaluate[evals[x]], {x, -1, 1}] gives both eigenvalues in the same color. I thought ...
2answers
111 views

### Cannot Block Plus

It is customary to use the following idiom to partially evaluate something inside a held expression: ...
1answer
145 views

### Random variable within Manipulate: how to make it independent on other controls

The code sample: ...
2answers
140 views

### Inserting symbols' definitions during read time of the code

Let's say we've got a package: ...
5answers
179 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 ...
2answers
137 views

### A pre-parsed HoldForm

HoldForm holds an expression's parsed form not its actual "inputted form" e.g. ...
2answers
277 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 ...
1answer
130 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: ...
5answers
165 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 ...
1answer
65 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 ...
0answers
19 views

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

In this example, Manipulate is contained within a Module: ...
1answer
73 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. ...
2answers
136 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] =...
0answers
54 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 ...
2answers
184 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 ...
1answer
299 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 ...
1answer
69 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 <...
3answers
64 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: ...
2answers
172 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: ...
1answer
108 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: ...
3answers
143 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: ...
1answer
221 views

### Trouble with polynomial multiplication

Bug introduced in 10.1.0 and fixed in 10.4.0 ...
2answers
169 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 evaluation)....
0answers
119 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 ...
3answers
59 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 ...
1answer
186 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 ...
1answer
81 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: ...
3answers
108 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 ...
1answer
86 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 n...
4answers
154 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: ...
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?
2answers
170 views

### When are numerical expressions identical

Very elementary: 2 + 3 == 5 evaluates to True and 5 == 5 evaluates to ...
2answers
81 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 ...
2answers
70 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: ...
1answer
93 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: ...
1answer
152 views

### Using PlotLegends->“Expressions” inside Manipulate or DynamicModule doesn't work

Take this simple example: ...
0answers
33 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: ...
1answer
159 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 ...
1answer
111 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 ...
1answer
427 views

0answers
47 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 ...
1answer
59 views

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

Consider the following simple front-end code: ...
0answers
52 views

### Import names into notebook namespace [duplicate]

I have function that at some point has list of strings (e.g. {"apple","pear"}) and I want to declare (initialize) those variables in notebook namespace to default ...
1answer
83 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 ...