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
6 votes
1 answer
92 views

Distinguish three fraction forms (feature stronger than Hold)

This question can not be typed easily, using mathematica stackexchange interface. So here is a GIF file : My question is : Can we construct a function f whose ...
  • 3,621
2 votes
2 answers
78 views

Don't understand an evaluation with BezierFunction

I don't understand the source of the failure of the following attempts to solve an equation involving the following very simple BezierFunction. ...
  • 13k
-1 votes
1 answer
54 views

Calculate the value of an interval [closed]

I want to calculate the maximum value of the formula given in the code, but it is obvious that my writing is incorrect. How should I modify it? ...
1 vote
1 answer
65 views

Table of conditions seems incorrect

If I enter Table[Sort@IntegerDigits@x == Sort@IntegerDigits[n x], {n, 2, 6}] the result is ...
  • 4,087
2 votes
0 answers
47 views

Bug: managed library expressions are freed prematurely during evaluation

I believe I have run into a bug with managed library expressions and garbage collection behavior. In the example below, adapted from the documentation for ...
4 votes
3 answers
157 views

HoldForm not working with Map

I am debugging a ListPlot implementation and I need to see the command. To avoid huge list of numbers, i just need the ListPlot ...
  • 3,474
3 votes
1 answer
42 views

Strange output of NIntegrate when constraining the precision with $Pre

One can constrain the precision of NIntegrate by setting PrecisionGoal: ...
  • 2,754
0 votes
1 answer
79 views

When running code to compute a sequence, loop variable gets set to a constant

I would like to write Mathematica code to read in a list of sequences, and print the sequence definition ($a_n$), along with the sequence evaluated at a few values of $n$. ...
  • 1,939
0 votes
1 answer
46 views

Evaluate part inside HoldForm [duplicate]

What I want to do is pretty straight forward: Entere something like this: HoldForm[Sum[la /. a -> b, {l, 0, N}]] and get something like this Σ lb Generally spoken, holding the sum but evaluating ...
2 votes
1 answer
49 views

How to modify the argument of a specific function below?

I would like to change the values of a and b in the following function: ...
  • 232
0 votes
1 answer
48 views

Can Print no longer access certain values during evaluation? [duplicate]

This example from Power Programming in Mathematica doesn't work for me anymore: the values used for rootfinding are not printed during evaluation. What changed? Is there a new way to reproduce the old ...
  • 1,706
3 votes
1 answer
140 views

How to get the closed form solution from DSolve[]?

Hi I've noticed something rather annoying which is when I try to use this function DSolve to check the answers to my homework problems it will simply not show a solution due to lazy evaluation. E.g.: <...
  • 133
3 votes
2 answers
57 views

Convert Strings in Variables [duplicate]

I want to convert strings to variables. I want to create the term pionprodg1. I tried to do this: ...
6 votes
6 answers
453 views

How do I withdraw the rhs from a list of equations?

I have a list of equations that were solved for different values of another parameter and stored in a Table and has the form: {a==0, a==1, a==2, a==3} and so on. I ...
  • 63
5 votes
2 answers
203 views

Do not understand evaluation order of ReplaceAll [duplicate]

{x, x^2, Length@x, Subsets[x]} /. x -> {1, 2, 3} (* {{1, 2, 3}, {1, 4, 9}, 0, {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}} *) with error What ...
  • 817
4 votes
1 answer
153 views

RuleDelayed (:>) involving Piecewise leads to Piecewise::pairs warning in ReplaceAll (/.)

When I write a replacement rule like this: Piecewise[{{x^2, x < 0}}] /. Piecewise[a_, b___] :> Piecewise[a, b] It works fine, but I get the unexpected ...
  • 2,923
1 vote
1 answer
52 views

Plus[__] matches everything in MatchQ [duplicate]

I understand that Clear[a,b,c] MatchQ[a+b+c, Plus[__]] True Because a+b+c is in fact ...
  • 3,621
7 votes
2 answers
165 views

Map function with evaluated and unevaluated parameters

Let's consider a function with evaluated and unevaluated arguments inside: list1 = {1,2,3} list2 = {x,y,z} fun[list_]:={list,ToString@Unevaluated@list} When I use ...
  • 225
3 votes
3 answers
180 views

Building A Function Using Constants From a List

I want to build a function of the form $f(t)= C + \sum_i A_i*Sin(f_i*t+\phi_i)$ Where $(A_i,f_i,\phi_i)$ are amplitudes, frequencies and phases that I have stored in a text file. Here is my attempt: <...
  • 43
4 votes
1 answer
59 views

another problem with context using package and association when using Inactivate

This problem is similar to this problem using package to verify solution of ode with Association, Naming scope/context handling but when I used the solution/trick given there, I still get a problem. I ...
  • 127k
4 votes
3 answers
110 views

How to evaluate EXPR in a subsession of a different already running kernel and get the output?

Is there a way to evaluate some expression in a subsession of another already running kernel, collecting the output, from a Local monitoring kernel? Something like ...
0 votes
0 answers
62 views

Answer changes slightly when re-run

I am trying to resolve why I get slightly different answers when I re-run my notebook. Here is my full code: ...
  • 1
2 votes
1 answer
47 views

Aborting the loop using external events

If we run one Wolfram Kernel (Wolfram Engine) there is one thread we can use While[True, doSmth; Pause[0.1]; ]; since there is a sort of interruption ...
0 votes
1 answer
62 views

Compute all bivariate polynomials over GF(2) of degree d or less and evaluate them at certain polynomial input

I want to compute all $<=d$ degree bivariate polynomials of form $f_1(x)g_1(y) + f_2(x)g_2(y)$, over field $GF(2)$, and evaluate them at a certain polynomial input for eg $d = 1$, evaluation at $(p^...
  • 1
4 votes
1 answer
153 views

Why is Evaluate[] in Plot[] not necessary in some cases?

after reading some related materials(Why do I have to put Evaluate[] here), in my understanding, BecauseAttributes[Plot] has ...
0 votes
0 answers
45 views

MMa 13, holding previous solutions instead of clearing them

I suspect this is something one line of code will fix, but I have a fairly simple code, that needs to be evaluated at 2 different points. I tried it for the first one... got an answer, it's correct, ...
  • 505
1 vote
2 answers
84 views

Construct association depending on itself

I want to construct an association that some of the Values are constructed from other parts of the Values, for the simplest ...
  • 1,440
0 votes
0 answers
39 views

Some confusions about Evaluate[] and HoldAll in Plot[] [duplicate]

i can't understand the outputs of the three commands in the following picture. question1: In my understanding, command one Plot[Table[a*x^2,{a,3}],{x,-3,3}] is ...
4 votes
4 answers
164 views

How to use replacement rules in a named expression before a sub-expression evaluates?

I have a named expression: expr := a + b. a and b are also named expressions. Let's say <...
0 votes
1 answer
53 views

What is the proper way to use Manipulate and Graphics in this context?

So this is my setup: I want to have an unspecified number of points, let's say n, which I can manipulate in a Manipulate environment. I want to later use these ...
0 votes
1 answer
63 views

Problem with For Loop when evaluating a recursive function at multiple points

I am running into problems with my For loop when trying to evaluate my expression. Fix some parameter values : ...
0 votes
0 answers
66 views

Map-ed programmatic Style-s (based on user-input) are not evaluating. Scoping constructs are suspected

The top function manages several sub-functions which set visual properties over a list of Options. Inside stylerules the ...
  • 2,337
0 votes
0 answers
42 views

Preventing Evaluation of Body of Manipulate

Overall, I am looking for a way to prevent the evaluation of the body of Manipulate until the controls meet a certain condition. For example, consider the following....
4 votes
0 answers
68 views

Why does `MakeBoxes` have the HoldAllComplete attribute and ignore it rather than HoldAll?

MakeBoxes has the attribute HoldAllComplete. For a normal function, it would imply that Upvalues should not be taken into account when the expression is evaluated: <...
2 votes
2 answers
178 views

The derivative anomaly in Mathematica 13, showing in the Plot[] function

Edit: Still inexplicably, it was found that in the Plot[] functions, showing a correct curve plot for the expression computing the derivative incorrectly, when '...
  • 313
4 votes
1 answer
127 views

How to evaluate this InverseFunction?

Solving an ODE problem DSolve[{y'[x] == x*(y[x]^2 - 1)^(2/3), y[1] == 3/2}, y[x], x] ...
  • 21.1k
2 votes
1 answer
129 views

Define Conformal Metric in xAct

For my thesis, I'm reproducing the results of a paper here by Alic et al in Mathematica using the package xAct. I'm able to reproduce the standard $3+1$ ...
  • 163
0 votes
1 answer
35 views

Parts of the expression are evaluated well, but not the whole expression together

I have the following code inended to define quaternions: ...
  • 3,399
3 votes
4 answers
404 views

Define a delayed function depending on a global variable as though the variable's contents was pasted

Problem Say I previously defined a variable (maybe through some extensive calculation) thing = (a+x)y Then, I want to use that expression elsewhere. In general, I ...
  • 689
1 vote
2 answers
103 views

Symbolic manipulations of predefined variables without numerical substitution

As a novice in Mathematica I would like to expand an expression without substituting its variables so that x = 4; y = 4; Expand[(x^2 + y^2)/x^2] generates the same ...
1 vote
2 answers
246 views

How to prevent Mathematica from rounding some PDF values to 0?

Dear Mathematica community, I'm having a problem with the PDF function for the hypoexponential distribution. Specifically, Mathematica returns 0 as soon as the value is very small. Below is an example:...
0 votes
0 answers
51 views

Plotting D of Sin fails but ' of Sin does not [duplicate]

I understand why you have to use Evaluate with D to make it work, but why then does the apostrophe form work for Derivate without Evaluate? If I plot a derivative one way I get an error - and yes, I ...
0 votes
1 answer
67 views

Cannot plot a function that calls Eigensystem on a large matrix

Is there a way to plot an expensive function without resorting to making a list of values and using ListPlot? I have a function called ...
  • 1,706
5 votes
5 answers
1k views

How to simplify a pure function?

I am dealing with the vibration of a multi degree of freedom system with driving force, and I need to find the relation between the amplitude and the frequency of the driving force. I hope to get an ...
  • 328
4 votes
1 answer
202 views

Substitution rule is not working

I'm trying to replicate the equations of motion of the $4\partial$ST theory in Mathematica as is done in here as I need to use Mathematica and this package for my thesis. However, I have some trouble ...
  • 163
-2 votes
1 answer
149 views

Mathematica doesn't evaluate an expression

I have such a code: ...
8 votes
4 answers
286 views

How to Thread lists elementwise with the If function?

Consider the lists: list1={a,b,c}; list2={x,y,z}; I want to Thread If elementwise across ...
2 votes
2 answers
143 views

'Update' and how to use variables to define patterns in functions' arguments...?

This seems like an obvious issue that I have nevertheless never encountered before. In a package, I want to use a variable to define a pattern that is used in the definition of some functions. However ...
  • 1,407
2 votes
2 answers
99 views

Replacing symbolic variables inside of a compile

As the result of a symbolic integration, I have a very long array with symbolic variables u[i] which I would like to substitute for real number values. Moreover, I ...
  • 153
0 votes
1 answer
68 views

Preventing evaluation of $Exp[\pm i\pi]$ until the end of a calculation

I'd like to prevent Mathematica from evaluating $Exp[\pm i\ \pi]$=-1 until I tell it to, at the very end of a calculation. I have a lengthy expression that involves things like (-x+y)^(n), and I know ...
  • 1

1
2 3 4 5
31