Questions tagged [evaluation]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
46 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 ...
2
votes
2answers
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: ...
7
votes
2answers
128 views

Bug in VectorFieldPlot[] with InterpolatingFunction[]?

Bug introduced in 11.3 or earlier and persisting through 12.0.0 or later While looking at https://mathematica.stackexchange.com/questions/192081/how-do-i-plot-a-divergence, I thought to suggest the ...
0
votes
1answer
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? ...
1
vote
0answers
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 ...
7
votes
1answer
100 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 ...
4
votes
2answers
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 ...
4
votes
1answer
112 views

Cell Bracket Clarification

I am running a very simple program that uses NotebookEvaluate to evaluate an open notebook that only has the context of saving and closing, and while it completes that task, the program gets stuck in ...
0
votes
1answer
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. ...
2
votes
1answer
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}}\...
0
votes
0answers
48 views

Creating a non-zeta-ified sum

The expression Sum[i^(-s), {i, 1, ∞}] evaluates to Zeta[s] But, of course, this is not strictly correct as ...
3
votes
0answers
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: ...
1
vote
1answer
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 ...
12
votes
5answers
310 views

Implement settable properties

I am looking for advice on implementing the following. (It is possible that the answer is that it is simply not a good idea to do this.) I would like to have an object similar to ...
0
votes
1answer
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 ...
4
votes
0answers
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 ...
0
votes
2answers
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, ...
0
votes
1answer
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? ...
0
votes
2answers
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 <...
3
votes
1answer
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 ...
0
votes
1answer
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 ...
0
votes
1answer
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 ...
0
votes
0answers
43 views

Evaluation control inside Compile

I have the following function ...
1
vote
1answer
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 ...
1
vote
0answers
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$, ...
10
votes
2answers
211 views

How to explain the behaviour of TreeForm? [duplicate]

Just try this: g=1;a=1;TreeForm[Hold[g[a]]] The weird thing in the outcome is that the node of g displays 1 ,and a is still a. I do not know how to explain ...
1
vote
0answers
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]$: ...
3
votes
1answer
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 ...
0
votes
1answer
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["...
0
votes
1answer
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] ...
11
votes
1answer
157 views

Conflict with hidden names

The following code hangs Mathematica 12.0.0: ...
2
votes
2answers
83 views

InterpretationBox problem with symbolic expressions

Related to this question, Why does this InterpretationBox construct work when x, y are ...
2
votes
1answer
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: ...
13
votes
1answer
162 views

Scheduled tasks and dynamic updating

Here is an example: x = 0; Dynamic[x] now please run: SessionSubmit[x = 1; Pause[10];] Problems: Annoying one: ...
2
votes
1answer
39 views

How to Evaluate a Cell written in code and store the result in a variable

Consider the following command. CellPrint[Cell["[1,2,3]", "ExternalLanguage"]] It creates a python cell with command [1,2,3]. ...
3
votes
2answers
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 ...
0
votes
2answers
47 views

Using MinValue with NDSolve

A simplified example looks like this. The basic idea is to maximize fHelper by adjusting \[Alpha] for each ...
0
votes
0answers
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 ...
28
votes
1answer
3k views

How does Return work?

It is not completely clear to me how Return[] works. The documentation says: Return[expr] returns the value expr from a ...
2
votes
1answer
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: ...
1
vote
1answer
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 ...
14
votes
3answers
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 ...
6
votes
1answer
156 views

TreeForm and Unevaluated

Bug introduced in 8.0.4 or earlier and persisting through 12.0 or later Check this example: ...
8
votes
2answers
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 ...
1
vote
2answers
57 views

Why does sol[r][[1]] 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: ...
4
votes
1answer
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 ...
0
votes
1answer
57 views

Evaluation functions with lower and upper limit ODE?

How do I find the numerical value of y at 0 and also at 1. Here is my code. I appreciate any help. ...
3
votes
1answer
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 ...
3
votes
1answer
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 ...
1
vote
2answers
206 views

Evaluating ReplaceAll inside SetDelayed, first

Consider the following (simplified for the purpose of example) definitions: f[x_] := y /. y -> x g[x_] := x Where for example, the definition of ...