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

Create local alias for variable

I have a function whose parameters are passed "by reference" Clear[foo] SetAttributes[foo, HoldFirst] foo[t_] := t = 10 Is it possible to create an alias for <...
13
votes
1answer
204 views

Safe alternatives to ToExpression

Background Conversion from string/boxes to expression is quite common. Very often the goal would be a simple switch from "1" to ...
2
votes
2answers
60 views

Table and evaluation order

I thought Table should not evaluate the inner code until it inserts the value. I'm confused by test1[3]="a"; test2[4]="b"; Table[DownValues[i],{i,{test1,test2}}] ...
1
vote
0answers
30 views

Computational discrepancy for plugging in equivalent forms into an expression

When the following 9th root of unity is raised to the 6th power a 3rd root of unity is returned. (Power[-(1/2) + (I Sqrt[3])/2, (3)^-1])^6 // N -0.5 - 0.866025 I ...
1
vote
2answers
147 views

Why is Mathematica not able to give out a simple integration result? [closed]

I am testing Mathematica to evaluate an innocuous integral - It is a straightforward integration but just involves a lot of constants. I do not understand - "why the computation has exceeded the ...
5
votes
1answer
464 views

How can I create a “Run all code” button in a notebook?

How can I create the "Run all code" button (at the top right corner) in Mathematica notebook? The current method I have is to save the .nb file into .wls (i.e. Wolfram Language Script), and then open ...
0
votes
1answer
50 views

Using List of Variables to construct Control[] within Manipulate[]

How can I use a list of variable names within Symbol[] inside a Manipulate[], specifically using ...
0
votes
0answers
32 views

Tracking System function (Get) calls, and Stack[_]

Consider the following attempt and variations thereof to track (nested) calls to Get (reasoning of this approach below): ...
0
votes
1answer
54 views

How to get a single evaluation of RandomReal in a Block

I want to generate (and eventually sample) a sine wave with a random frequency in the range [½, 1] (i.e. capture somewhere between half and one period of the waveform over the domain [0,1]). The two ...
0
votes
1answer
50 views

Parallelization of function evaluations

Problem I have an expression that calculates the coefficients of a 2x2 matrix which depend on other three independent expressions, i.e, $K_{l l^\prime} = ( k_{l l^\prime}^{(1)} + k_{l l^\prime}^{(2)}...
0
votes
1answer
174 views

Importing and evaluating notebook from plain text

I have a computer-generated plain text file with some Wolfram Language definitions separated by newline characters - imagine it is the code you would type to a single cell: ...
4
votes
0answers
80 views

ScheduledTask DateObject pattern to evaluate at same time everyday

I would like to create a ScheduledTask that evaluates at the same time everyday. Such as, evaluate function at 1:00 am everyday. The "Daily" timespec in ScheduledTask doesn't allow me to control the ...
1
vote
0answers
164 views

Return unevaluated expression from function

Is there any way (except using upvalues) to make a function that returns it's input Unevaluated? What I mean by that: Take the following example: ...
1
vote
1answer
57 views

Weird Behavior of Table and Sequence

I'm writing a function that constructs a multidimensional array (that is, nested lists) using Table. The dimension of the array varies according to the argument to ...
4
votes
2answers
417 views

How do I know the calculation time of an equation solving?

Solve[ Sqrt[Abs[x]^2+Abs[-5+y]^2]+Sqrt[Abs[-5+x]^2+Abs[y]^2] +Sqrt[Abs[5+x]^2+Abs[y]^2]+Sqrt[Abs[x]^2+Abs[5+y]^2]==24 && -6 < x < 6, y] ...
1
vote
1answer
295 views

Why do I see Null in the output from my function? [closed]

I've seen some comments relating to this topic but I am new and they are not really helpful. Please look at the following two outputs. One has an ...
0
votes
3answers
101 views

How to factor out and cut off a parameter

In an exemplary expression expr = -6 3^(1/3) c1 kL^4 L^2 (δ^3/L^3)^(1/3) all parameters are real, especially L > 0. ...
0
votes
3answers
57 views

Is it possible to evaluate this algebraic expression ?

a +b == Subscript[q,1]n + Subscript[r,1] b + c == Subscript[q,2]n + Subscript[r,2] Subscript[r,1] + c == Subscript[q, 3]n + Subscript[r,3] Expand[a+b+c] I want to ...
8
votes
1answer
229 views

How use Iconize object assigned to a variable (Mathematica 11.3)?

In Mathematica 11.3 we have the new Iconize function. Say I create an iconized image grabbed from the web, like this: ...
2
votes
1answer
109 views

ToExpression and RowBox — orderings

With: ToExpression[RowBox[{"c", ToBoxes[Plot[Sin[x], {x, -2, 2}]], "a"}]] I get the three elements of the array, but with "a" and then "c" at the beginning. I ...
0
votes
0answers
28 views

Defining functions while evaluating a module

This might be a very basic question, so apologies in advance, but I couldn't find a direct solution. Suppose I have a module that takes function(s) and expression(s) as its arguments. For the sake ...
5
votes
1answer
85 views

A more transparent highlighting with Defer and evaluate-in-place?

I’m using Highlighted[Defer[…]] on expressions and evaluate-in-place to highlight parts of queries for a book project. Works well usually, but I notice it leaves out the quotations, see image - those ...
0
votes
3answers
85 views

How to get a function within ConstantArray to evaluate for each list element?

Here is my code example: ConstantArray[RandomInteger[{1, 5}], 10] However as my output I get something like ...
2
votes
1answer
88 views

Converting strings to expressions in a package

I have a function that generates an equation in the form of a String. I want to be able to turn that string into an Expression, and evaluate it in another function. For example: ...
1
vote
1answer
82 views

Cases with condition vs Select inside Manipulate

I tried to plot integer points that fall into a 2D region that's dynamically changed. So I resort to Cases and Select, but ...
6
votes
2answers
227 views

How can I check if a function remains unevaluated?

I am trying to check if a function remains unevaluated. For example $$\int \ln ^5(3 x) \sec (3 x) \, dx$$ remains unevaluated in Mathematica, instead $$\int \sec (3 x) \, dx$$ doesn't. What I ...
0
votes
1answer
155 views

Incomplete plot problem

I have this code: ...
0
votes
2answers
69 views

Change order of evaluation in Plot[] nested with NDSolve[]

I noticed that in Plot the function is evaluated at each sample point Plot[func@x,{x,rStart1,rEnd1}] which is fine for a ...
3
votes
1answer
46 views

TensorProduct of square

TensorProduct shows a behavior I don't understand when giving as an argument the square of a variable. Example: TensorProduct[a,b] a\[TensorProduct]b But for ...
2
votes
1answer
63 views

Strange behaviour of ValueQ inside loops

TL;DR: I have a series of variables $x_1, x_2, x_3, \dots$ which to which I assign values inside a loop. However, when I use ValueQ to determine which values I've ...
9
votes
1answer
149 views

Peculiar timing result with Blend function

First, we load some colorbar data and define val for testing ...
0
votes
1answer
136 views

Return analytic expression

I would like to evaluate this summation: \begin{align} \sum_{j=1}^{NM}\left[(u_{j_x} + u_{j_y})^2 - 2(1-\rho) u_{j_x} u_{j_y}\right], \end{align} where $NM$ is some number greater than or equal to $...
3
votes
1answer
46 views

Recover result after “Set” error

I have a function someFunction[] that takes a long time to evaluate. I would like to run ...
4
votes
1answer
79 views

Listable function behaving in an unexpected way

For example, if I define a function like this: SetAttributes[func,Listable]; func@{{1,2},{3,4}} it gives the result like: ...
3
votes
1answer
76 views

Detecting transformation rules and removing them

Is it possible to detect the non-standard transformation rules (DownValues, UpValues, etc) that activate in an evaluation (and ...
9
votes
0answers
94 views

Possible bug in Refresh[x, None] on the very first x = val

Bug introduced in 8 or earlier and persisting through 11.3 [CASE:3995912] From Refresh docs: Refresh[expr,None] ...
1
vote
1answer
148 views

Suppressing the automatic newline in Print

Print automatically generates a newline at the end of the expression that is being printed. How do you suppress this automatic newline?
5
votes
2answers
61 views

OwnValues for Set and SetDelayed

I am unclear about the OwnValues for Set and SetDelayed. ...
4
votes
2answers
106 views

Replacements in Manipulate [duplicate]

I would like to understand why this is not working: replacement = {a[t] -> r}; Manipulate[Plot[a[t] /. replacement, {r, 0, 1}], {t, 1, 2}] But this does: <...
1
vote
1answer
140 views

Print generates a cell with style “Print”

The Wolfram documentation for "Print" says the following: In a notebook, Print generates a cell with style "Print". What does it mean by style "Print" since ...
1
vote
2answers
397 views

How to evaluate the trace of a product of sums of gamma matrices

I have a large expression of a sum of gamma matrices which resulted from using Casimir's Trick. It is quite tedious to evaluate so I thought about using Mathematica. However, I have no idea how, ...
1
vote
1answer
66 views

Compute and evaluate function of a function and keep the result a function

Let's assume I have a various functions for signal amplitudes, e.g. pulse[t_] = Sech[t]^2 and pulse2[t_]L = Exp[-2t^2]. What I'...
2
votes
1answer
140 views

Why does this system of PDEs take a long time to evaluate?

I am trying to simulate the growth of cell populations through a system of coupled PDEs. There are six equations in total but Mathematica takes a long time to solve the system (+6 hours running) and ...
0
votes
2answers
288 views

How to evaluate a notebook several times with distinct parameters?

I have a code, which is quite large. There, I consider parameters that are used inside series of procedures and numerically solved differential equations. At the end I plot the solution for those ...
2
votes
1answer
50 views

Delete Part of Deferred Expression

Szabolcs provided an elegant answer to my previous question about printing executable code that uses Defer: ...
0
votes
0answers
70 views

Calculation time for a limit, is my calculation still calculating?

I am calculating the limit of an eighth order derivative with ~700 terms. The notebook has been in the 'running' phase for a few days now. If it says it is still running, does this necessarily mean ...
1
vote
0answers
37 views

Reading out Manipulate controls dynamically generated in a list

I've been trying to dynamically generate Manipulate controls in a list, like so: ...
17
votes
5answers
617 views

Is it possible to construct a fullform trace function

Is it possible to construct a FullFormTrace function that takes an arbitrary expression and prints a sequence (or returns a list) of the evaluation steps in full ...
11
votes
1answer
156 views

TextString evaluation leak

Bug introduced in 10.4 or earlier and persisting through 11.3 [...] I checked and reproduced your issue, and have passed along a report to our developers on the same [...] CASE:3972929 ...
0
votes
0answers
60 views

Manipulate syntax error: Table::nliter [duplicate]

Manipulate[Table[Orange, n], {n, 1, 5, 1}] works well, but Manipulate @@ {Table[Orange, n], {n, 1, 5, 1}} raise ...