# Questions tagged [evaluation]

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

1,160 questions
Filter by
Sorted by
Tagged with
43 views

### Retrieving the evaluation result of an Initialization Cell in a notebook nb1 from another notebook nb2

I have a very long code in a notebook nb1 in which all the initialization cells are tagged. I have another notebook nb2 where I ...
43 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? ...
29 views

### Changing machine precision notebook-wide leads to peculiarities

For a project of mine it is preferrable to set notebook precision globally. I have done so by using the answer in Global precision setting. The idea is to dynamically create a ...
99 views

### Accessing sowed data during long computation

This question is very similar to the one posted here: Interrogating a running evaluation but my running computation consists of a backtracking procedure which sows valid solutions. It is hard to tell ...
91 views

### Manipulate and ParametricNDSolve

EDIT: typo spotted in comments, code reposted with fix as well as new behavior I'm having trouble getting mathematica to give me a working plot. I've defined specific values for my parameters: ...
91 views

### How to extract parts of an expression using Cases

Let the following exprs stand for a list of complicated expressions which we are interested in breaking down into parts by extracting a number of individual ...
62 views

### How to plot function with pattern-matched argument and catch-all definition that throws

Consider the following function: f[n_?NumericQ] := n; f[args___] := Throw[{args}]; Then try to plot it: ...
25 views

### Substitution in delayed evaluation function [duplicate]

I am trying to do the the following: precomputing an expression and then making a function out of it. It has to be delayed evalution, because some of the parameters are only known when the function is ...
49 views

### Power towers Power towers from x to n [closed]

How can I make Mathematica calculate a power tower for a succession of numbers, but instead of writing them, Mathematica does the iterative calculation. ...
32 views

### Order of evaluation of variable

I'd like to control the order of evaluation in a multi-variable function. Example: Suppose I have the function: B[x_, y_] := x + y/x; If I try to evaluate ...
67 views

### Problem with numerical evaluation of a Hankel identity

There an identity with the Hankel functions of both types (https://dlmf.nist.gov/10.11 eq. 10.11.4 or http://apps.nrbook.com/bateman/Vol2.pdf pg. 80 eq. 43):  \sin\left(\nu\pi\right){H^{(2)}_{\nu}}\...
41 views

### Run computation in separate process and kill it after a time limit

I am looking for a solution to run a Mathematica calculation in a separate process (separate kernel) and cancel the computation after a given time. If it cannot be cancelled, then just kill that ...
29 views

### Testing Expression over region of values

I'd like to test whether this expression is negative when a and b are constrained to lie within (0,1) interval. Any ideas how? ...
86 views

### Only evaluate assignments in a notebook

Maybe I'm not using the best programming practices in Mathematica, but my notebooks usually contain a mixture of "definitions" and "computations" with these definitions. Say, ...
30 views

### Plotting 3-d function using Evaluate and Table

I want to plot $z(F, x, \lambda)$ where I fix a few values of $F$ and $\lambda$ and see how it varies with $x$. With 2-d functions, I could vary the second parameter easily using a combination of <...
35 views

### Prevent argument substitution in held expression when injecting into unevaluated code

I want to write a custom sow/reap pair to wrap any piece of code in sow[code] and call reap ...
31 views

### How to have NonlinearModelFit not evaluate a function too early?

This is a follow up of my previous question How can I define the following function for arbitray values of the arguments? that received no attention so here I will try to be more concise with the ...
43 views

### Evaluation control inside Compile

I have the following function ...
44 views

### InverseLaplaceTransform does not evaluate [closed]

I am very new to Mathematica and not a mathematician, so the question may be very trivial. I am trying to find the function $f(t)$ such that $\qquad e^{-e^{s}} = \int_0^{+\infty} e^{-st}f(t)dt$, ...
35 views

### How to speed up the evaluation of a sum of incomplete Gamma functions?

We need to do a ContourPlot for the following function $H[x,y,n]$: ...
114 views

### An alternative to (%%…%) (k times) [closed]

Sometimes it may be useful to use (%%…%) (k times) to get the kth previous result in a notebook instead of setting a variable. However, if I want to get the 8th previous result, for example, I would ...
49 views

### Getting unexpected results form If expressions [closed]

I'm mystified by this: g[a_, b_, c_] := Module[{d}, d = If[(b < 1), b, b + 1]; If[a < b, d = 0.]; d*c] g[a, 20, 40] ...
157 views

### Conflict with hidden names

The following code hangs Mathematica 12.0.0: ...
137 views

### Why would Evaluate[] in Plot give me warning about precision?

I have a code:- Plot[Evaluate@PDF[NormalDistribution[1.6, 0.2], x], {x, -6, 6}] And then I got the warning: ...
84 views

### Construct a function that maps strings to functions

The main question is the last 5 lines (including codes) of this article. A[x_, y_] := Evaluate[ToExpression["x^2+y^2"]] A[3,4] Then the output becomes ...
61 views

### How to get ReplaceAll to happen before function call

I have a problem I am attempting to solve with NMinimize. I have a scoring function, which will give me a final score. The problem has many variables, so instead of having them as parameters, they ...
47 views

### Using MinValue with NDSolve

A simplified example looks like this. The basic idea is to maximize fHelper by adjusting \[Alpha] for each ...
53 views

### How can I define the following function for arbitray values of the arguments?

Consider the following function a[m_, l_] = 1/Log[m/l]; with this function I define ...
58 views

### Mathematica does not evaluate large expression

I want to apply Conjugate[] to a certain quite long rational function of some parameters. My problem is that although it evaluates perfectly fine on each single part of the expression, Mathematica ...
30 views

### How can I keep the argument of TeXForm[Integrate[1/Sqrt[1 + x], x]] from being evaluated?

How can I keep the argument of TeXForm[Integrate[1/Sqrt[1 + x], x]] from being evaluated? This is what I am getting: ...
34 views

### How to interpret a string as a multiline cell of expressions

I need a string like the following: "2+2 \"Hello world\" 3+3" to be evaluate like 2+2 "Hello world" 3+3 Note that ...
34 views

### Unable to operate on the table imported from .mx file

I saved a table by exporting it to .mx file. Now, when I import it back, it gives me the desired output. So, to work with elements of the table, I first define the imported table as (res2 = Import["...
279 views

### Evaluated vs. unevaluated Association

This question might have a remote connection to my older question, it is also about sameness of expressions and subtle differences observable only in certain forms. I encountered this strange ...
160 views

### Using With[…] with a list specification as a variable [duplicate]

If you have some defined function, say f[a_, b_ c_, x], one can initialize this by using With[...] as ...
57 views

### Why does sol[r][] become r?

This is a follow up to this question. This answer is great it gives the correct solution and I can plot it, but I have a problem: when I try to integrate the solution in this way: ...
83 views

### InterpretationBox problem with symbolic expressions

Related to this question, Why does this InterpretationBox construct work when x, y are ...
47 views

### Evaluate calls my function multiple times when the function generates an error

If I execute a line of code with Evaluate I find some unexpected behavior when the code returns an error. Here is a minimal example. Let ...
60 views

### Combining With, If and SetDelayed

I just noticed that With[{x = 1}, If[x == 0, 0, 1]] returns 1 (as I expected) but ...
117 views

### function evaluation - I don't get it

this function returns Pi/4 for a[1,4] In[...]:= a[r_, n_] := Module[{an = Pi/n, h = r Cos[an], w = 2 r Sin[an]}, an]; a[1, 4] Out[...]= Pi/4 so the kernel ...
102 views

### Suppressing analytical evaluation in NDSolve

I am trying to find a numerical solution to a set of coupled ODEs with NDSolve. Let us say $\boldsymbol{X}$ is a vector, and $\boldsymbol{F}$ is a non-linear vector ...
65 views

### How to see/trace Manipulate steps?

I am relatively new in Wolfram Language. What I want to solve is tracing "manipulate" steps in one of the demonstration project example codes. In my particular example, there are nearly 20 user build ...
124 views

### How to define a functional that produces at runtime a function by evaluating selected parts in its definition?

Consider the following functional as an example: ...
126 views

### Evaluate an expression at singular points

I have y[x_] := 1/Sqrt (5 - x - Sqrt[8 - (x + 1)^2]) {x0, x1} = {-1 - Sqrt, -1 + Sqrt}; and I want to calculate ...
38 views

### Run only a part of a notebook

Is it possible to run only a part of a notebook? I have a long notebook which takes forever to evaluate, so I was wondering if it was possible to run only a couple of cells instead of the whole ...
52 views

### How to evaluate a function on Imported data (.xlsx file)

I have imported an excel file, and I want to evaluate an expression on each point: Data = Import["data.xlsx"] which gives output like this: ...
53 views

### Evaluate in place annoyance

I want to use the following expression to get a string value: Row[{"Enter index identifier: ", InputField[Dynamic[indexidentifier], String]}] and I also want to ...
90 views

### ReplaceAll does not work

Why ReplaceAll does not work in this situation? ...
48 views