We’re rewarding the question askers & reputations are being recalculated! Read more.

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
3
votes
0answers
57 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
22 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 ...
0
votes
1answer
43 views

Power towers Power towers from x to n [on hold]

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

Plotting works with @ but not with […] [closed]

Why is it that I can plot the function of a series if i define it with @: f1[x_] := Normal@Series[f[u], {u, 0, 2}] /. u -> x but not when I define it with [......
0
votes
1answer
31 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 ...
2
votes
1answer
63 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}}\...
4
votes
0answers
40 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
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
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
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
30 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
0answers
40 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$, ...
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
112 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
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
156 views

Conflict with hidden names

The following code hangs Mathematica 12.0.0: ...
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: ...
3
votes
2answers
83 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 ...
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 ...
0
votes
2answers
45 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
1answer
50 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
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 ...
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 ...
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["...
14
votes
3answers
276 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 ...
8
votes
2answers
159 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
56 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: ...
2
votes
2answers
82 views

InterpretationBox problem with symbolic expressions

Related to this question, Why does this InterpretationBox construct work when x, y are ...
4
votes
1answer
45 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 ...
3
votes
1answer
59 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 ...
6
votes
1answer
100 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 ...
0
votes
0answers
63 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 ...
6
votes
2answers
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: ...
4
votes
1answer
124 views

Evaluate an expression at singular points

I have y[x_] := 1/Sqrt[2] (5 - x - Sqrt[8 - (x + 1)^2]) {x0, x1} = {-1 - Sqrt[8], -1 + Sqrt[8]}; and I want to calculate ...
0
votes
0answers
37 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 ...
0
votes
1answer
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: ...
4
votes
1answer
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 ...
3
votes
1answer
88 views

ReplaceAll does not work

Why ReplaceAll does not work in this situation? ...
6
votes
1answer
47 views

Why does `$Pre` need to be defined indirectly via some other function?

The documentation for $Pre gives the following example ...
5
votes
2answers
84 views

Obtaining head and parts without evaluation

I have been trying to write a routine MyHead and MyPart which would have the following properties. MyHead[2+3] evaluates to Plus ...
0
votes
1answer
54 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. ...
1
vote
1answer
42 views

Respecting excluded index in sum

I'm using a function involving a sum where some indices are excluded: ...
0
votes
2answers
53 views

Can anyone please help me to plot the following list of complex values?

I tried to plot the complex values in Mathematica using the following code ...
0
votes
2answers
60 views

Why is this not False? (SameQ,Equal, Set) [duplicate]

How can we understand why Mathematica does not evaluate this expression to False? {{1, 2, 3, 4}, {4, 3, 2, 1}} == 0
1
vote
1answer
82 views

ReleaseHold and Get

I've created a try.m file which has the following structure: { Hold@{a+b+c}, Hold@{a^2+b^2} } On my main code I do: <...
3
votes
2answers
100 views

Inconsistency between Plot and NIntegrate

Have a look at the following definition Y[q_, w_ /; w < 0] := 0 Y[q_, w_] := w The function Y is zero for negative ...