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
0answers
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 ...
2
votes
1answer
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 ...
0
votes
0answers
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: ...
0
votes
0answers
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 ...
0
votes
1answer
53 views

Defining relations between functions in Mathematica

I would like to find a way to implement the following in Mathematica: Let $F$ be the set of real functions $f_1,f_2,\ldots f_n$. The function $\min$ is defined as follows... $$\min F=f_i\iff \forall ...
1
vote
1answer
38 views

Insert result of inline evaluation [closed]

In previous versions of Mathematica I could inline evaluate the call to Solve in the code below with the result replacing the call. Very useful to speed code up. ...
1
vote
2answers
24 views

Assign numerical values to symbolic variables in a vector inside a do loop

I have vector k = {k1, k2, k3, k4, k5, k6}. I would like to assign numerical values to the elements of k in each step of a <...
2
votes
1answer
55 views

any way to stop all the following evaluations?

I often slect the whole notebook to evaluate. Sometimes some functions may return wrong parameters, which may happen, for example, I may have forgotten to specify values to some variables in the ...
0
votes
3answers
52 views

Partial evaluation of a function [duplicate]

In the spirit of a previous question, this is a self-assigned exercise in order to understand how we can control expression evaluation with Mathematica. So, given the following function definition: <...
0
votes
1answer
51 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 ...
0
votes
1answer
59 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
31 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
110 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 ...
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: ...
4
votes
2answers
96 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 ...
3
votes
0answers
65 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
26 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
51 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. ...
0
votes
1answer
34 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
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}}\...
4
votes
0answers
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 ...
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
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
47 views

Evaluation control inside Compile

I have the following function ...
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$, ...
1
vote
0answers
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]$: ...
3
votes
1answer
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 ...
0
votes
1answer
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] ...
11
votes
1answer
159 views

Conflict with hidden names

The following code hangs Mathematica 12.0.0: ...
2
votes
1answer
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: ...
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 ...
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
48 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
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 ...
0
votes
0answers
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 ...
2
votes
1answer
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: ...
1
vote
1answer
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 ...
0
votes
1answer
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["...
14
votes
3answers
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 ...
8
votes
2answers
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 ...
1
vote
2answers
58 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
86 views

InterpretationBox problem with symbolic expressions

Related to this question, Why does this InterpretationBox construct work when x, y are ...
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 ...
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 ...
6
votes
1answer
105 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
69 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 ...