Questions tagged [evaluation]
Questions about how Mathematica evaluates expressions, tracing evaluation (Trace*), handling expressions in unevaluated form (Hold*, Unevaluated), nonstandard evaluation, etc.
1,580
questions
4
votes
1
answer
248
views
Substitution rule is not working
I'm trying to replicate the equations of motion of the $4\partial$ST theory in Mathematica as is done in here as I need to use Mathematica and this package for my thesis. However, I have some trouble ...
8
votes
4
answers
323
views
How to Thread lists elementwise with the If function?
Consider the lists:
list1={a,b,c};
list2={x,y,z};
I want to Thread If elementwise across ...
2
votes
2
answers
154
views
'Update' and how to use variables to define patterns in functions' arguments...?
This seems like an obvious issue that I have nevertheless never encountered before.
In a package, I want to use a variable to define a pattern that is used in the definition of some functions. However ...
106
votes
5
answers
6k
views
Replacement inside held expression
I wish to make a replacement inside a held expression:
f[x_Real] := x^2;
Hold[{2., 3.}] /. n_Real :> f[n]
The desired output is ...
2
votes
2
answers
134
views
Replacing symbolic variables inside of a compile
As the result of a symbolic integration, I have a very long array with symbolic variables u[i] which I would like to substitute for real number values. Moreover, I ...
0
votes
1
answer
99
views
Preventing evaluation of $Exp[\pm i\pi]$ until the end of a calculation
I'd like to prevent Mathematica from evaluating $Exp[\pm i\ \pi]$=-1 until I tell it to, at the very end of a calculation. I have a lengthy expression that involves things like (-x+y)^(n), and I know ...
5
votes
2
answers
429
views
Can every usage of While be changed into NestWhile?
OK, I think this problem is more close to philosophy. :P
I've some idea now. But I'm not sure whether it's correct.
For the purpose of convenience, I will use some C-like code instead of Mathematica'...
3
votes
1
answer
110
views
Evaluation rules in Plot for function
Say I have some test function, which evaluates an integral, such as
...
2
votes
0
answers
53
views
Memorization for Rule + ReplaceRepeated?
Question
When build packages of noncummutative algebras I met the choice:
Rule + ReplaceRepeated
...
2
votes
1
answer
101
views
Evaluate a double sum using Mathematica
I am evaluating using Mathematica, the double sum $\sum_{u=0}^\infty \lbrace \sum_{k= u+1}^{u+y}[\dfrac{(1-a)}{4} (3/4)^k + 3a[(\dfrac{1}{2})^{k-1} - (\dfrac{3}{4})^{k-1} ]\rbrace $, where $'a' $ is a ...
1
vote
3
answers
506
views
Mathematica is not able to integrate a function over an integral which Wolfram|Alpha can?
This is a semi-cross post from: https://math.stackexchange.com/q/4519130/820472
Let $$f(x) = e^{\frac{-1}{1 - x^2}}, g(x) = \frac{d^2f(x)}{dx^2}$$.
Then $$g(x)^2$$ has a finite area as is confirmed by ...
2
votes
1
answer
92
views
Evaluation process of And, Or,
Small questions about evaluation process of And, Or.
code 1)
...
7
votes
1
answer
222
views
CellEvaluationFunction or $PreRead stripping inline cells from text cells
I want to create a textual style that has some CellEvaluationFunction that processes the contents of the cell a certain way. Particularly, it has to do something ...
3
votes
2
answers
104
views
Why can't I execute other commands while the dialog is running?
Bug introduced in 8.0.4 or earlier and persisting through 13.1
CASE:4226661
The code is from the following video:
http://www.wolfram.com/broadcast/video.php?sx=Ian%20Johnson&v=2076
...
3
votes
1
answer
426
views
When to use f:= x vs f[x_]:= x?
I have many compound functions, using the same variables. I can define them like this:
f[x_,y_]:= ...
g[x_,y_]:= ...
h[x_,y_]:= f[x,y] + g[x,y]
or like
...
30
votes
4
answers
9k
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 ...
25
votes
2
answers
883
views
Implementing a safe ValueQ that does not evaluate its argument
Mathematica has a built-in function ValueQ. Quoting the docs,
ValueQ[expr] gives True if a ...
7
votes
1
answer
156
views
What is the difference between "SessionSubmit" and "LocalSubmit" in performance?
Does SessionSubmit forward the computation to the master thread and LocalSubmit to some other idle thread? By thread, I mean CPU ...
1
vote
0
answers
57
views
How to get rid of "/." in my result, when I evaluate a term containing ReplaceAll?
In the previous code I defined Bchoice and pchoice
In one line I defined
...
3
votes
2
answers
147
views
Understanding HoldAll?
Suppose I try to run the following code:
f[x_] := Cos[x]
F[X_] := Normal[Series[f[x], {x, X, 5}]]
Plot[Table[F[n], {n, -5, 5, 1}], {x, -Pi, Pi}]
Mathematica will ...
1
vote
0
answers
58
views
Plot functions don't allow postfix function execution?
I'm confused about syntax of using // for postfix function execution. It fails in some situations where I would expect it to work. For example, it works with both <...
5
votes
3
answers
224
views
How to automatically interrupt `Set` with conditions
Maybe this is a bad idea: I want to inject some conditions into Set associated to specfic symbols, like
...
6
votes
1
answer
230
views
How to stop opening of cell groups after evaluation of the whole Notebook?
Bug introduced in 12.3 or earlier and persisting through 13.1.0
I have a long notebook with Section, Subsection, ...
4
votes
2
answers
169
views
Evaluation of an iterator construct containing Sequence in Table
The following code:
Table[i*j, Apply[Sequence , {{i, 1, 3}, {j, 1, 2}}]]
returns the error:
Table::nliter: Non-list iterator Sequence@@{{i,1,3},{j,1,2}} at
...
0
votes
1
answer
90
views
Error in evaluating a For loop
I defined an integral function and for solve it, I want to calculate it for some numbers and then plot its behavior. So I put the function in a For loop to automate this procedure and then plot the ...
3
votes
1
answer
1k
views
Evaluation of Derivative in a Module
Can someone help me understand the evaluation procedure in the following two pieces of code?
...
1
vote
0
answers
44
views
Manipulate reevaluate every time
my code is working, however I have a problem, every time I navigate to the pages of the dataset, the Manipulate performs a re-evaluation bringing me back to the first page of the dataset. I would like ...
3
votes
1
answer
185
views
BUG - Different Cloud vs. Desktop Return behavior in V13.1 [duplicate]
After install V13.1 one of my scripts get broke in my Mac. Here is the bug:
Module[{}, Return[1]; 2]
Return[1]
When I tested ...
0
votes
0
answers
56
views
A way to tell mathematica to not alphabetically order second derivatives
I have a frame of vector fields $E_1 ,... ,E_6$ and it's convenient for me to write $E_1(f)$ as Dt[f,e1] where e1 is an ...
0
votes
0
answers
19
views
Not getting evaluated output [duplicate]
I just started using Mathematica.
When doing the matrix calculation I encountered some problem, output is not evaluated instead it just gives the input as the output.
Example:
0
votes
0
answers
30
views
Avoiding notebook re-evaluation after quitting Mathematica [duplicate]
I'm new here so I hope I'm not asking something already solved. I'm new to Mathematica and I need to manage lists created from files that usually spend a lot of time to be created. I noticed that ...
0
votes
1
answer
92
views
How to prevent Table replacing expressions in argument [closed]
I have a function called velocitySolver, which takes in a list of geometric parameters as well as a condition involving those geometric parameters. Therefore, if I ...
4
votes
4
answers
210
views
Parts of a Piecewise Matrix Function in NDSolve
First time posting.
Reproducing the Problem
I'm relatively new to Mathematica (using v.12.3), and working on a project. My problem can be reproduced with this.
...
2
votes
1
answer
278
views
7
votes
1
answer
278
views
How to remember evaluation across sessions?
I am performing a very time-consuming symbolic calculation.
When I reopen a saved Mathematica notebook, it takes quite a long time to evaluate.
Is there an option to tell Mathematica to remember the ...
2
votes
1
answer
66
views
Wierd problem with Table and Evaluate
I have a very unpleasent problem with Mathematica, precisely with Table and/or Evaluate. After solving a parametric system with ParametricNDSolve, I'd like to collect the values of the solutions $f_3(...
0
votes
1
answer
110
views
How to construct the local variables for Block automatically (somewhere in the code)
I am working on the fancy abstraction for Block function. The idea is to use rules to specify which local variable will be used, even if it already defined in the global context
like this
...
1
vote
0
answers
107
views
Why Mathematica don't set \$RecursionLimit and \$IterationLimit very big by default? [closed]
For my current program in Mathematica, sometimes I will encounter an error regarding \$IterationLimit and \$RecursionLimit. So I always set these two numbers to very large at the starting of every ...
3
votes
3
answers
300
views
Different evaluation control inside of `Integrate` than outside of it
I want to keep inside of a integral evaluated after some replacement inside it, but at the same time the integral itself unevaluated.
I start with:
...
24
votes
1
answer
841
views
Why does the documentation call functions "pure"?
Clearly, Functions in mathematica are not pure functions according to the definition on Wikipedia (no side effects - basically implementabe with table lookups)
the ...
6
votes
3
answers
291
views
HoldForm is not working as I would expect
Why HoldForm do this?
HoldForm[a/b \[Integral]f[x] \[DifferentialD]x]
Output is this ugly looking formula:
$$\frac{a \int f(x) ...
0
votes
0
answers
86
views
Can I load a notebook without evaluating it?
I have a long notebook with a lot of definitions, calculations, etc. If I want to open the notebook on a new computer, or even on my computer after it has been shut down; then in order to make use of ...
1
vote
0
answers
42
views
How to derive the integral of a first kind zero-order modified Bessel function multiplied by a Rayleigh distribution?
I input the result into Mathematica and get the following result
In: $\int_{0}^{\infty} \operatorname{BesselI}[0, \epsilon] * \frac{\epsilon}{\rho^{2}} * e^{\left(\frac{-\epsilon^{2}}{2 * \rho^{2}}\...
7
votes
4
answers
425
views
How can I efficiently define functions with different names but doing the same stuff?
Recently I have met with with this interesting question:How can I efficiently define functions with different names but doing the same stuff? Somebody may want to ask me why I want to do things like ...
0
votes
0
answers
141
views
Variation with respect to inverse metric in a Lagrangian density
I am trying to vary the following Lagrangian density
with respect to the inverse metric appearing in the equation, but I am having trouble with how to write the right code in Mathematica.
I have ...
2
votes
2
answers
162
views
Double quotes as a 'function' (verbatim ToString?)
Can we construct a function F such that F makes any typed text into a string.
Just like double quotes.
...
0
votes
1
answer
157
views
Through does not have hold attribute?
Possibly Related to Unexpected behavior of KeyTake.
Consider the following example, where I input #11 (last) is the misbehaving one. Am I missing something or do you agree there is a bug?
...
3
votes
3
answers
242
views
Seemingly identical expressions, only one evaluates! [closed]
I am having difficulty using NMaximize with a user-defined function that involves NSolve. Stack Trace shows trouble at the ...
1
vote
3
answers
191
views
How to return unevaluated variable?
I'm not sure if this problem has been asked before as I don't know the keyword to search for it.
I have a function where return result contains variable b (just ...
2
votes
0
answers
58
views
Division by 0 Error when checking whether something is equal to zero
I was running a program and suddenly got Divide::infy messages coming from the following (rather ugly) expression.
...