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
2
votes
0answers
46 views

How can I know the value of some parameter (say w) during a parallel calculation in Mathematica?

I am computing something like ParallelTable[{w, f[w]},{w,0,10,1/100}], in which f[w] is a numerically obtained function that ...
4
votes
0answers
50 views

Residue for $L(s,\chi_1)$ not same in Mathematica as theoretical value

I want to find the residue of Dirichlet-L function, defined as $L(s,\chi)= \sum_{n=1}^\infty \frac{\chi(n)}{n^s}$ for $Re(s)>1$. We know that $Res_{s=1}L(s,\chi_1)=\frac{\phi(k)}{k}$, where $\chi$ ...
3
votes
1answer
39 views

Mathematica Documentation for `HoldAll`: `Unevaluated` doesn't do anything?

I'm trying to understand the difference between HoldAll and Unevaluated. The documentation for ...
2
votes
1answer
44 views

Extract only a few coefficients of the multiple of extremely many polynomials

I want to extract some informations, say the coefficients of $x^{500}$ and $x^{1000}$ terms (numerical values are acceptable), of the multiple of ...
3
votes
2answers
60 views

How to symbolically evaluate expression within If[]?

I have a function, say f, that needs to take one of two symbolic forms depending on the value of its inputs. This function is part of a very large expression, and I'...
2
votes
1answer
46 views

Stop Minimization after condition

I want to interrupt the optimization of a function when a particular condition is satisfied. Here I provide a test function. ...
6
votes
1answer
162 views

Append vs AppendTo

According to the documentation AppendTo[s,elem] is equivalent to s = Append[s,elem]. But then ...
0
votes
0answers
39 views

How do I increase an amount of digits after the point?

I have an expression such as: Log[0.784637, 517.8796]*ArcTan[-1.112673]*0.4256^(-2.034)*Sqrt[3.567] and I get 3 digits precision. I tried: ...
0
votes
0answers
28 views

Evaluating function of two variables inside NMinimize with respect to second argument

Consider three functions: f[t_, 1] := {Cos[t], 1, 0} f[t_, 2] := {Sin[2 t], 1, 0} f[t_, 3] := {Cos[t - 2], 1, 0} For each $k=1,2,3$, let $g(\cdot,k)$ be the ...
1
vote
0answers
61 views

Different handling of division by zero [closed]

MMA differently handles division by zero. How to control this behavior? In this case it delivers the expected error: i/(i + k) /. {i -> 0, k -> 0} ...
1
vote
1answer
61 views

Creating a Button to evaluate initialization cells

I am trying to create a setup where I have a number of InputField, SetterBar, and Checkbox ...
2
votes
3answers
143 views

Limit of empty sum

Why MMA delivers this result and how to interpret or reformulate it? Limit[k Sum[1/i, {i, 1, k - 1}], k -> 0] I would expect 0 as it is an empty sum. MMA 12.1 ...
0
votes
1answer
51 views

How solve this system of trigonometric equations?

I have the following system of equations: (substituting any real values for a,b,c,r,Alpha,Beta will return the same answer for x) ...
0
votes
0answers
38 views

Evaluating more than one open notebook in Mathematica without mixing issues

I have two open Mathematica notebook files, call them file A and file B, that are identical except for some initial parameter conditions that I manually input at the beginning of each file (all the ...
0
votes
1answer
76 views

Evaluation taking extremely long

I am trying to solve the following: ...
0
votes
0answers
35 views

Notebook Evaluate crashes after several evaluations

I created master and slave notebook where master notebook evaluates slave notebook as follows: ...
4
votes
1answer
69 views

Refer to OptionValue externally without a specific function name

I want to refer to the actual option values of a function f outside of f, using OptionValue. ...
3
votes
1answer
91 views

How does MMA return an unevaluated expression on errors without going into an infinite loop? [duplicate]

Post-answer note: this question is (understandably) marked as a duplicate, and indeed has a similar solution, but is subtly different in focus: the linked question is about returning a function call ...
7
votes
1answer
150 views

How to write a simple interpreter / DSL with Wolfram Language?

I am specifically trying to write an interpreter for Mathematica predicates to MongoDB aggregation stages, but I wanted to phrase the question a bit more generically because I can see many times one ...
6
votes
2answers
162 views

Extract held value from Association

Consider an association which contains a key which must not be prematurely evaluated. assoc = <| key :> value |> For example, a value of ...
0
votes
0answers
24 views

Mathematica doesn't evaluate LinearSolve Function properly [duplicate]

Maybe this could be a stupid question, but I can't solve this problem. I'm trying to evaluate an expression with LinearSolve Function but it doesn't work. I have pre-evaluated the matrix ...
1
vote
1answer
102 views

WhenEvent how to handle events at the same time and detection order

I need to use WhenEvent inside NDSolve in which events happen simultaneously. I show simple code to better explain my question: ...
0
votes
1answer
51 views

How to prevent Table replacing expressions in argument

I have a function called velocitySolver, which takes in a list of geometric parameters as well as a condition involving those geometric parameters. Therefore, if I ...
0
votes
1answer
24 views

Create a table of plots in manipulate with redundant variables

I'm trying to create a table of diagrams of which each shows a different variable on the x axis and fetches the remaining parameters from the enclosing scope, a Manipulate object. So I have this code ...
0
votes
0answers
41 views

BellY function call fails

I would very much appreciate to get an answer about the reason of the message I get calling the BellY function. ...
0
votes
0answers
48 views

Force WhenEvent and NDSolve to numerical evaluation and Best Practice

I'm trying to perform an hybrid kalman filter for a nonlinear system. The following code works but it is very slow due to the fact that it does symbolic evaluation. What I wish is that for the filter ...
0
votes
1answer
31 views

Evaluating $T(x,y) = ((K_h*K_g - K_g)*(K_h*K_g - K_g))(x-y)$?

Define $K_h$ as$$ K_h(x) = \dfrac{1}{h}K\bigg(\dfrac{x}{h}\bigg), $$ where $K$ is the Gaussian function$$ K(x) = \frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}x^2}. $$ Define the function $T(x,y)$ by$$ T(x,y) = ...
2
votes
0answers
40 views

Hold parents of ArcTan

If this question is beating a dead horse about Hold, Inactivate etc., a close vote is fair enough. That being said, I'm curious ...
0
votes
2answers
38 views

Defining function in terms of previously defined symbol

With a very high frequency I find myself working with giant and hard to alter expressions in a situation where it would be convenient to do something like ...
1
vote
2answers
59 views

WhenEvent inside Ndsolve how to evaluate actions numerically every time the event happens

I need to force a whenevent action to be evaluated numerically all the times the event happens. The fact is that I use very complicated matrices and I need to invert them so the system requires a lot ...
1
vote
2answers
49 views

Applying a particular rule to a held (or unevaluated) function

I am a very novice Mathematica user and still can't get my head around its evaluation control, all possible constructs related to it (e.g. Hold, ...
2
votes
1answer
62 views

What's the difference between Evaluate and Replace command? [closed]

all, I'm new to Mathematica, I am very confused between Evaluate and Replace (/.) command. I feel they are very similar. For example, ...
0
votes
1answer
52 views

Sum over multiple values falsely returning 'Indeterminate' [closed]

I have a conditional expression which depends on three variables, say x, y and z (all ...
1
vote
3answers
59 views

How to set a value to the symbol denoted by a given string? [duplicate]

The code setString[name_String, value_]:= Evaluate[Symbol[name]] = value fails whenever Symbol[name] has already been assigned ...
6
votes
1answer
50 views

Automatically set x=0, after each input/output ? ($AfterEachInputOutput)

Is it possible to do something that I want, after each input/output automatically and silently? I am looking for a feature like $AfterEachInputOutput in the following code : Example : to set variable ...
5
votes
1answer
98 views

Extracting n-th part of an expression without any evaluation

Is it possible to extract n-th part of an expression as a string, without any evaluation? For example, ...
4
votes
1answer
50 views

Floor function not returning correct value

Something very strange is happening as I evaluate the Floor function: (9.2 - 8)/1.2 Floor[(9.2 - 8)/1.2] returns: 1. 0 so I ...
1
vote
0answers
43 views

Series coefficient not working for abstract powers

I'm trying to extract coefficients of some complicated polynomials. If I try to write SeriesCoefficient[1/(x-1)^4,{x,0,m}], this works fine, everything as expected. ...
2
votes
1answer
154 views

An alternative command to compute a logarithmic integral [closed]

I am trying to see if Mathematica can calculate: $$\int_0^1\frac{\ln(x)\ln(1-x)\ln(1+x)}{x}dx,$$ which has a closed form found here. So I tried ...
7
votes
1answer
151 views

Fast Evaluation of a series of dot product

Context I have a function that depends on 3 real variables x,y and z and that is defined by a series of matrix products. The evaluation of f for a specific (x,y,z) is fast ~0.02 sec but I want to ...
2
votes
1answer
44 views

What is the best way to coalesce two values, if the first value is Null?

I want to set a variable to a value, and have a default value in case the previous value is Null. Basically it would act like a Coalesce statement in SQL. I have not been able to find a succinct way ...
1
vote
0answers
33 views

Evaluating function taken as input

Consider this toy example: myDerivative[f_, x_] := D[f, {x, 2}] This defines a function myDerivative that takes in a function <...
0
votes
1answer
53 views

TemplateEvaluate, TemplateUnevaluated, and TemplateVerbatim [Undocumented] - What do you know?

Let's discuss some undocumented Template-related functionality. Specifically, what do you know about TemplateEvaluate, ...
3
votes
0answers
42 views

Symbol differentation in Wolfram Programming Lab gives recursion error [closed]

I was experimenting with the Wolfram Programming Lab, but it doesn't seem to be working. I tried running this code in a notebook: D[x^2, x] but it gives the error <...
0
votes
1answer
82 views

Combination of Block and With - Unexpected results

I'm trying to use Block to prevent a function from executing. In this example, the function I'm trying to block will simply be ...
2
votes
1answer
73 views

Accessing already defined Symbols in a function

I'd a like a function that assigns variables based on a rule list. That is, SetParameters[{x->1, y->2}] would set x=1 ...
0
votes
2answers
69 views

Hold `outermost layer` of expression

In pursuit of a function to force unsimplified fractions forceden[x_,d_]:=Hold[Evaluate[Numerator[x]d/Denominator@x]/d]; There are many related functions (...
2
votes
2answers
185 views

Wolfram modules returning functions

I am trying to get a With / Module pair to return a set of functions. ...
1
vote
0answers
84 views

Do Loop contained in a function defined within a custom package doesn’t work as expected but works fine when function is defined directly in a script

Below is my code and I am having problems running the StdMPC function that I am trying to define. Running my code gives me the error that the matrix A and Xopt[[i]] are not of compatible shapes for ...

1
2 3 4 5
27