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
1answer
31 views

How to “Hold” variables assigned value inside DSolve?

Consider the following ODE: a = 0.8; b = 8; v = DSolveValue[{ u[x] == a*(b* u'[x] + u''[x]), u[4.925] == 4, u'[4.925] == 0.625 }, u[x], x] which gives ...
0
votes
0answers
17 views

Evaluation order of multi-argument function and why is () sometimes equivalent to Evaluate[]?

So this question has two parts: 1) How can the order of evaluation of a multi-argument function be determined? and 2) Why does () seem to be equivalent to Evaluate[] in some cases? I was plotting a ...
2
votes
2answers
93 views

Why can't I evaluate this integral and obtain a closed-form solution?

I have the following spherical density distribution: $\rho(x, z) = \frac{1}{\sqrt{x^2 + z^2}\left(1+\sqrt{x^2+z^2}\right)^2}$ which I have broken into a "line of sight" dimension $z$ and a &...
0
votes
2answers
71 views

Still having trouble evaluating expressions (involving Log this time)

I'm trying to get some old Mathematica code working on MMA 12. I found the code at this link. Here's the relevant code: ...
1
vote
0answers
26 views

Evaluation time of If[] conditionals taking too long [closed]

I have a simulation to run, and the whole script was written by somebody else (I think over 10 years ago) so I know it works perfectly. However, when I try to run in myself, there is an input, with ...
1
vote
1answer
29 views

How does Mathematica evaluate sums where the upper limit of the index is not an integer?

I am interested in the way Mathematica evaluates sums where the upper limit of the index is not an integer - i.e., sums that are some sense mathematically meaningless. For example: ...
1
vote
1answer
96 views

Can you transcribe this mathematica expression into a formula or pseudocode?

I want to understand the mathematca formula A282720 The description says Number of nonzero terms in first n rows of the base-2 generalized Pascal triangle P_2 (But ...
1
vote
1answer
46 views

How to asign well numerical values efficiently before to plot?

A problem is presented when the substitution of the numerical values for this function ...
2
votes
3answers
78 views

Ignore Null when summing elements of a list, but return Null if all elements are Null

Let's say I have two different lists for which I want to compute the total list1 = {1, Null, 2, Null} list2 = {Null, Null, Null, Null} For list1, I want the total ...
0
votes
0answers
24 views

How to DumpSave previously assigned symbols

I'm trying to DumpSave[] some variables based on their name string. To define them, I'm using ...
2
votes
0answers
41 views

Which Method is used during the processing of Sum Function?

I am trying to find out which Method is used while evaluating the following function: Sum[1/((n^2)), {n, 1, Infinity}] Any help would be greatly appreciated. A ...
2
votes
0answers
111 views

How can I use Compile to Evalaute a trace of a sympolic Matrix?

I would like to evaluate a trace of a matrix of size 4Wn×4Wn at different point (x,y). with <...
5
votes
3answers
221 views

HoldForm does not prevent evaluation

I'm still relatively new here, and I'm not a native speaker. I hope, I don't make any obvious mistakes when asking this question. For instance, I simply had no idea how to title it accurately. I'm ...
1
vote
0answers
39 views

ArgMin returning unsolved solution

I have been trying to get the ArgMin function to work so that I can find the value of $s$ that minimizes this function: $$ f(s)=e^{-sa}\left(pe^s+(1-p)\right)^n\style{font-family:inherit;}{\text{, ...
2
votes
0answers
118 views

How can I numerically evaluate the trace of a large matrix to speed up the code?

I have a large matrix (4Wn*4Wn) resulted from multiplication of different matrices and I would like to evaluate the trace numerically to speed up the process. Here ...
3
votes
0answers
46 views

With notebook's default context set to “Unique to each cell group”, how do I make “Evaluate in Place” work in a text cell?

With the notebook's default context set to "Unique to each cell group", I have: x=1 The value of x = x where the second line is a text cell with an ...
0
votes
1answer
57 views

Compute this once, not twice

I have two questions. So, I have a function g defined in terms of another function, f: ...
1
vote
0answers
35 views

Why are nested anonymous pure functions shielded from evaluation?

I tried the following code (ignoring the warning messages): ...
13
votes
1answer
176 views

Problem passing a list from Mathematica to external python function

comp1a = Flatten[Join[{{0 + 0 i}}, {comp1}]]; Flatten[comp1a[[1 ;; 6]]] This creates a list of complex values -> comp1a The first 6 terms in the list are: {0, -...
6
votes
2answers
138 views

Mathematica emits a beep after any evaluation - how to remove it?

Without any obvious reason Mathematica started to emit a beep after each evaluation, even when it is error free. Why is that, and how can I turn it off? I tried restarting Mathematica to no avail, and ...
1
vote
2answers
45 views

Evaluate with numbers from list

This code works: x=2 y/.Solve[y==x^2] Out[138]= 2 Out[139]= {4} So above I put number in variable x and getting the result of ...
1
vote
1answer
23 views

Construct string argument and pass it to command

My Mathematica variable scope is set to Notebook, more about it here: What is my current scope if I change `Inspector>Cell options>Evaluation options>...
1
vote
1answer
20 views

Grid questions: text-wrapping / copying and pasting expressions

I want to make a list of functions like this: ...
1
vote
1answer
60 views

Is it possible to solve a PDE in NDSolve for a simple functional PDE where the dependent variable is evaluated at a point?

Is it possible to configure NDSolve to approximate solutions of a PDE where the state variable is evaluated at a point? Mathematica detects such a PDE as a delay equation, but clearly all that is ...
2
votes
1answer
35 views

Formula: setting parameters vs replacement, different results?

I have a question that may sound stupid and have an easy answer - but I currently do not see it. I have defined a function of four variables, $f[a,b,c,d]=...$, in what I think is correct Mathematica ...
1
vote
1answer
32 views

Should be a Piecewise function, a ConditionalExpression or Indeterminate, but it is a number

I apologize in advance for the lack of focus of my question. Consider the function: f[x_, y_] := x/(x + y); f[0,0] evaluates to ...
1
vote
1answer
54 views

Formatted/modified Mathematica command

I know there is a way of making your own commands that outputs your desired information but I'm not sure how to do this. How do you format/modify/make your own command that outputs what you want. E.g. ...
1
vote
2answers
88 views

Expectation of product of independent random variables (using Expectation function)

I'm trying with no luck to get Expectation to calculate the expectation of expressions containing sums of products of independent random variables. For instance, ...
4
votes
1answer
85 views

Thread and RandomReal

I am trying to use Thread to apply a function involving RandomReal but it does not work as I expected. If I have the function <...
6
votes
1answer
374 views

Why can't I create {a,a,a,b,b,b,b,b,c,c} from x={a,b,c}; f={3,5,2}; Thread@Table[x,f]?

ClearAll[x, f] x = {a, b, c}; f = {3, 5, 2}; Thread[Table[x, f]] produces Table::nliter: Non-list iterator f at position 2 does not evaluate to a real numeric ...
5
votes
1answer
48 views

Piecewise function not evaluating properly

I have a simple Piecewise function that defines a square pulse: ...
3
votes
1answer
55 views

NumericQ and unknown number of variable in a module-block

I have the following problem I want to address in an elegant way. I have a function of many variables f[x, y, z,...] I want to find the minimum with ...
2
votes
1answer
62 views

Symbolized, Subscripted Variable Doesn't Look Pretty

I'm trying to programmatically generate a subscripted variable in a way that makes it appear "pretty". Here is a minimal working example that shows some strange behavior I'm trying to ...
2
votes
1answer
23 views

Maximize with manipulate

Iam trying to include a manipulate to NMaximize function to see how the output values are changing for p and t. By varying the variable w, x, y and z. Kindly please help me to resolve this, the file ...
3
votes
1answer
51 views

About function with Manipulate and order of evaluation

I have many problems to understand how mathematica evaluates Manipulate[] when I use function before or inside Manipulate[] . ...
1
vote
1answer
54 views

Order of evaluation

I am having a hard time figuring this out: ( sample ) I have any matrix which can have an arbitrarily large dimension. ...
1
vote
1answer
32 views

Setting a function equal to another function then Clearing the latter

I have a loop in which several values of a function are computed, depending on the values for that function that were computed in the previous iteration of the loop. This could be implemented ...
0
votes
1answer
36 views

Avoiding unexpected behaviour of ValueQ in Module

ValueQ returns True when for example on the following test (from a clean kernel with no assignments to ...
2
votes
1answer
26 views

RandomPrime inside Manipulate gets evaluated multiple times

Manipulate[ m = RandomPrime[d]; {m, d}, {d, {20, 50}, SetterBar} ] Basically, I expected the code to generate a random prime m (under the upper bound d) for me ...
0
votes
0answers
26 views

Can I use D[] inside of Plot[]? [duplicate]

I wanted to make a plot like this: Plot[-BesselJ[1, z]*Evaluate[D[BesselJ[1, z], {z, 2}]], {z, 0, 5}] but I got an error. However, when I tried this: ...
1
vote
1answer
85 views

General::ivar: is not a valid variable

...
5
votes
2answers
279 views

Efficiency of the rule _ * 0 := 0

In the standard evaluation process, innermost parts are evaluated first. For example: In[0]:= (a/a + 1) * 0 The evaluation process gives: ...
2
votes
2answers
48 views

Cannot understand meaning of “identical”

This came up in the context of plotting solutions to NDSolve, but I've reduced it to the following issue. This really has me scratching my head. ...
12
votes
1answer
173 views

PlusMinus definition unexpectedly affects plotting

In version 10.1 I found a strange Plot behavior I did not anticipate. It seems that various heads including PlusMinus are ...
5
votes
1answer
69 views

head of a sequence

Why does Head[Sequence[b, c]] return c[Symbol] and not Sequence? Why does ...
3
votes
2answers
58 views

Defer evaluation of function but not of its derivative

Sometimes, the derivative of a function can be simplified nicely using the definition of the function itself. For example, if $f(x) = e^{x^2}$, then $$f'(x) = 2x \cdot f(x).$$ How can I perform this ...
1
vote
1answer
22 views

Evaluation order and Tables - Errors when using Evaluate@Table

following this question of mine Conditional PlotStyle, I ran into another problem. I fear it has to do with evaluation orders, as for example described in Table and Evaluation Order, but I am totally ...
1
vote
1answer
44 views

The number 1 evaluates inside HoldForm sometimes

If I run the following code: ...
1
vote
2answers
47 views

Evaluating part of an expression, but delaying the rest

Say I have an expression g = x^2 + y^3; I tried writing this H[x_, y_] := Eigenvalues[Evaluate[{{0, g}, {g, 0}}]]; The ...
0
votes
0answers
58 views

How does the parameters pass between functions? [duplicate]

In C++ , there are several ways to write a function: ...

1
2 3 4 5
26