# Questions tagged [evaluation]

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

1,169 questions
Filter by
Sorted by
Tagged with
31 views

### Are Hold attributes Mathematica's way to implement lazy pattern matching alla Haskell?

I'm reading this and I'm having a hard time understanding lazy patterns; in particular I'm baffled with the server-client toy problem and why there is a 'problem' of matching "...too early". The ...
66 views

### Using chain rule to calculate a second-order partial derivative in spherical polar co-ordinates

I have a function $f$ and I am supposed to calculate its second-order partial derivative first in cartesian co-ordinates, which is fine. However, I am stuck while solving the problem in spherical ...
35 views

### Radial Mathieu functions, divergence problem

I am working on a project that requires the utilization of even Mathieu functions. This is the definition of my functions: Even Mathieu function: ...
43 views

### Odd ordering of evaluation for piece-wise functions, element-wise multiplication and dot product

I am constructing functions that call on multiple other functions and I want to understand how the ordering of evaluation of functions works and what is the best practice when writing many component ...
53 views

45 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 ...
47 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$, ...
36 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]$: ...
116 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 ...
50 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] ...
159 views

### Conflict with hidden names

The following code hangs Mathematica 12.0.0: ...
141 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 ...
48 views

### Using MinValue with NDSolve

A simplified example looks like this. The basic idea is to maximize fHelper by adjusting \[Alpha] for each ...
79 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 ...
59 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 ...
31 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: ...
35 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 ...
35 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["...
282 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 ...
161 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 ...
58 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: ...
86 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 ...
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 ...