Questions tagged [evaluation]
Questions about how Mathematica evaluates expressions, tracing evaluation (Trace*), handling expressions in unevaluated form (Hold*, Unevaluated), nonstandard evaluation, etc.
1,304
questions
2
votes
2answers
177 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 ...
5
votes
1answer
142 views
0
votes
1answer
46 views
How to instruct internal function to evaluate arguments only after numerical values are plugged in?
For convenience, let me start with a simple example. The following code calculates the sorted eigenvalues of a 4x4 Hermitian matrix with a parameter x
...
1
vote
1answer
51 views
function within function
delFunc[funcform_, lstofparams_,lstoferrs_] := √Total[Table[(D[funcform, lstofparams[[i]]]*lstoferrs[[i]])^2, {i,Length[lstofparams]}]]
...
0
votes
0answers
33 views
Simplifying expression involving Boson operators
I want to do calculations involving Boson operators $a(k), a^{\dagger}(k)$, e.g $(x + a(k))(y+a^{\dagger}(k))$. My code is:
...
3
votes
1answer
47 views
How to force Mathematica to output a function using its alternate pretty form when using Apply? [closed]
By default, Bra is an undefined function.
Let's say I have defined Bra,
Bra[a___]:=...
such ...
0
votes
1answer
43 views
Symbolic evaluation expressions containing a user-defined function [closed]
I have a function
F[r] = (-1)^(r + 1) Binomial[n, r]/r
I would like to evaluate F[x+1]/F[x] for some arbitrary ...
3
votes
2answers
123 views
Change the color of sub-expression when the whole expression evaluates to a different expression
I found it's tricky to colorize a sub-expression of an expression that changes to a different expression when it is evaluated.
For example, if I replace s with ...
1
vote
2answers
72 views
2
votes
2answers
62 views
Print function value at specified coordinate
Below is the code to evaluate the function.
I am trying to print the function values at a specified coordinate as shown in ActCoor.
...
0
votes
1answer
54 views
Mathematica 12.1 is treating all my cells as raw texts by default
I was once using Mathematica 11 it all works fine - when I create new Notebook (.nb) input like 1+1 and press shift+...
1
vote
1answer
44 views
How to inline a variable in function definition
I need to compile a function g that calls an external function f. f and ...
0
votes
1answer
185 views
Elliptical Integration
I have an integral which can be decomposed into three complete elliptical integrals. I want to know the method by which I can achieve this. The integration is the following:
(4 (-1 + y)^2)/(c Sqrt[y (-...
0
votes
1answer
71 views
Evaluate analytic solution of the function [closed]
Here, i have plotted a function and i would like to print the y coordinate values from the plot for the x-coordinate given below.
Coordinates in the sequence that every fourth y-coordinate should be ...
2
votes
1answer
29 views
How to conveniently evaluate a function at several points when there are way too many points
Say I define a function as follows:
pos[n_] := If[Cos[288 ((n Pi)/233)] > 0 && Sin[288 ((n Pi)/233)] > 0, 1, 0]
Then I want to evaluate at this ...
6
votes
0answers
98 views
Difference between the infinite rewriting behavior of evaluation and ReplaceRepeated
In the documentation tutorial/Evaluation it's said that:
Every time the expression changes, the Wolfram Language effectively starts the evaluation sequence over ...
0
votes
1answer
23 views
How to keep a variable unevaluated when used as parameter for `Sum`?
Let's say I have assigned the follow value to s by
s = Floor[Log[n]]
Then I want to compute
...
0
votes
1answer
29 views
Solving a large system of equations for the smallest integer values
I'm trying to find the smallest possible non-negative integer solutions to hundreds of fairly large equations systems . An average example would be the following:
...
0
votes
1answer
30 views
Errors within code to change the intersection of two Log Functions
I have been asked to produce a "parametric log-log plot of s=f(y) as a function of t=g(y), where
...
2
votes
1answer
56 views
Function does not take many inputs, and cannot plot correctly using Listplot
I am a beginner with Mathematica.
I have a function which is defined as follows:
$h(x) = \begin{cases}
\hfill \frac{1}{x}\sin(x) & \text{if $x\neq 0$}\\
1 & \text{...
0
votes
0answers
22 views
Different results when using ReplaceAll
Here's a riddle. I have a matrix QQsimple with some algebraic expressions. For example:
QQsimple[[36, 22]]
evaluates to:
...
2
votes
0answers
36 views
What are key differences between InputNotebook and EvaluationNotebook?
I am still new to Mathematica but advancing to a point of programming notebook and cell manipulations using native commands. Sometimes they call for specifying ...
2
votes
0answers
80 views
Is there any way to change the box-formatting behavior thoroughly?
Background
The box-formmating behavior is affected by the downvalues of the symbol MakeBoxes. But the formatting behavior is not exactly ...
2
votes
1answer
63 views
Trouble evaluating this definite integral, either directly or with indefinite + limits
I have the function
$$
\Sigma(x) = \frac{\sqrt{R^2-x^2}(\left| R\right| -1)}{\left(R^2-1\right) \left(x^2-1\right)}+\frac{\tan ^{-1}\left(\frac{\sqrt{R^2-x^2}}{\sqrt{R^2 \left(1-x^2\right)}}\right)-\...
2
votes
1answer
30 views
Keep a log of evaluated expressions
Sometimes I perform some calculations, export the results and a week later I notice something odd with one of the exported files. I still keep the notebooks with the calculations but sometimes certain ...
4
votes
3answers
126 views
The symbolic result does not give a proper answer when inputs are specified
Define F by
F[m_, k_, i_, j_] := (-1)^(m+k)/(m!*k!)*2^m*Binomial[m, i]*Binomial[k+1,j]
I am trying to find this sum:
...
1
vote
1answer
68 views
i need to simulate a roulette table where a perosn bets $10 on red 1 time, 5 times,20 times, 100 times and 10,000 times
I need to simulate a roulette table where a perosn bets $10 on red 1 time, 5 times,20 times, 100 times and 10,000 times, i then need to find out how much the person wins or loses once they play 10,000 ...
0
votes
1answer
55 views
How to programmatically Evaluate Notebook (all cells in an open notebook) rather than from Evaluation menu? [duplicate]
I am working on a DockedCells toolbar for common tasks like Save, ClearAll, scrolling, etc., ...
0
votes
0answers
55 views
Running .m file from Mathematica notebook
I have use the following command to save a table called "matrix_name" as a .m file named "matrix.m":
...
1
vote
1answer
46 views
EntityValue evaluation behaviour
I'm puzzled by a behaviour of EntityValue, where I find it being unevaluated. Here is a minimal example. Consider the following custom ...
1
vote
1answer
56 views
Solve a ODE with specific conditions
I am trying to find (some) functions h(x,t) such that A h(b,t)+B h_x(b,t)=g(t), where A,B,b are constants and g(t) is a given function of time (h_x is the partial derivative w.r.t. the first component ...
0
votes
1answer
30 views
Why does DifferenceRoot evaluate only in this table?
I would like to use a complicated function containing DifferenceRoot as a replacement rule, but somehow it evaluates only in ...
0
votes
3answers
60 views
Assign value to the symbol returned by function
Ok, so here is example code:
Clear[p, flag, k];
p = 2;
k = 1;
flag = True;
If[flag, p, k] = 0;
p
After that I get the message
...
2
votes
1answer
39 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 ...
3
votes
2answers
167 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
76 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
1answer
32 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
103 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 ...
0
votes
1answer
61 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
83 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
29 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
43 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
114 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
226 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
43 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
124 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
53 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
58 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
37 views
Why are nested anonymous pure functions shielded from evaluation?
I tried the following code (ignoring the warning messages):
...