Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [evaluation]

Questions about how Mathematica evaluates expressions, tracing evaluation (Trace*), handling expressions in unevaluated form (Hold*, Unevaluated), nonstandard evaluation, etc.

1
vote
1answer
56 views

Nested Do loops with externally defined iterators

I want to be able to define a set of iterators for nested Do loops, such as ...
5
votes
2answers
72 views

Converting prefix to infix

Is there a way in Mathematica to convert prefix to infix notation (where precedence order is preserved)? For example, how would I convert S[a, S[b, c]] to ...
2
votes
0answers
26 views

Using Min & Max of an Interval in a replacement [closed]

I want to use a replacement rule to transform a list of equations. The following works as expected: ...
2
votes
2answers
82 views

How to evaluate the “Domain” of a Parametric Function?

In a simple example I try to calculate the time the solution x[t] passes a second time x[t]==1. ...
2
votes
1answer
28 views

Reevaluating an expression when Assumptions have changed

Is there a way to make this work? THM = TensorDimensions[M]; Assuming[ Element[M, Vectors[n]], THM ] Which gives: ...
3
votes
2answers
92 views

Convert defined variables to rule list

I'd like to make a function that takes a list of variables and returns a corresponding rule list with the current values of the variables. E.g. ...
0
votes
1answer
29 views

Replacing non-adjacent variables [closed]

Suppose I have an expression of the form $exp=a\,b\,c\,d\,+\,e\,f\,g\,h$ where all the letters represent real numbers, and I want to replace $a\,c$ in the first term by $w\,x$ and $f\,h$ in the second ...
3
votes
3answers
196 views

Why is expression not evaluated completely? [closed]

I have a simple sum of complex numbers. In my example their sum is zero. sum = Total[{1 , E^(2*I/3*Pi) , E^((4*I)/3*Pi)}] Print[sum] Try it online! When ...
1
vote
0answers
38 views

Differentiating functions of Set expressions

There are so many things in Mathematica I think I will never understand. Perhaps today there will be one fewer... B'[y]/.B->Function[y,y^2] Outputs ...
1
vote
0answers
59 views

Calling a notebook from a different notebook

Basically I have a notebook (let's call it nb1) that when evaluated yields one number when I specify some parameter $\alpha$ (in nb1). I want to call nb1 in a different notebook (nb2) using for ...
3
votes
2answers
174 views

Maximum point of a rational function

Suppose I have the following rational function: ...
5
votes
0answers
31 views

Why does't 'Abort evaluation' properly work when NotebookEvaluate is executed

The following procedure can be easily aborted using Evaluation > Abort Evaluation menu item: Do[j + k, {j, 1, 10000}, {k, 1, 10000}] But it is not possible if <...
0
votes
0answers
24 views

Incorrect Function value and Derivative when expression in numerator yields zero

Recently I found that in special cases when the r.h.s. of a function definition is not simplified, and part of the expression in numerator yields zero, the value of the function is incorrectly zero as ...
5
votes
1answer
68 views

Does the position of a comment in a CompoundExpression matter for the result obtained with Out (%)?

I would like to understand what happens when we include a comment at the end of a line that ends with a semicolon. For example, if you execute ...
3
votes
1answer
89 views

HoldFirst being overridden by Activate [duplicate]

So here's the problem a=1;a=2 works because of the HoldFirst attribute of Set, so that it ...
0
votes
0answers
15 views

Evaluating part(s) of a function which outputs another function [duplicate]

I would like to define a function f(n) which outputs another function as follows: ...
1
vote
1answer
28 views

Evaluation of Extract and use the result in a Sum

I am experiencing a problem in the evaluation of a sum. I hope that someone can help me, I am not an expert Mathematica programmer. I'm posting just the portion of code that gives problems, I know ...
2
votes
1answer
43 views

Strange behaviour (or issue?) in using evaluation of held argument inside a table in Mathematica

I encountered a very strange behaviour on Mathematica using Evaluate on a held argument. Could anyone explain to me what is the subtlety (or is it a bug?) Here is the expression: ...
5
votes
2answers
88 views

How to prevent arguments UpValues from being used in selective functions

Ok, I know the simple answer is to set some form of Hold attribute to the function but bear with me for a bit while I explain my motivation and why that is not quite what I want. I have a collection ...
10
votes
3answers
177 views

Perform localized, evaluation-leak free replacements

Consider the following expression: expr = Hold[ { f[ {1, {Print@1}} ], g[ {{{Print@1}}} ] } ]; I'm looking for a way to ...
0
votes
1answer
31 views
1
vote
2answers
58 views

Getting thet derivative of a user defined function in terms of an auxiliary function

I'm currently struggling with evaluation control when getting the derivative of a function (I dont know if that's the correct term here. Sorry, beginner). My function is of the form ...
0
votes
2answers
40 views

How to find value of an expression if some cases are given>

I actually need to find the value of x which have 3 cases as follows: x=0, when x<=0 x=[x], when x>0 and is non-integral ...
9
votes
1answer
182 views

Force evaluation of user-defined function

Consider a function that sorts its arguments based on a function called order ...
1
vote
0answers
61 views

Why is my Mathematica notebook resetting all my previous computations after some hours?

I am using Mathematica 11.1. This morning I started some calculations in the hope that when I come back from work, they will be finished and I can get on with the rest of my project. Indeed, when I ...
0
votes
0answers
63 views

Evaluate higher order derivative at some point under some assumptions

I need to evaluate the $k^{\rm th}$ order derivative D[w[t] w'[t], {t, k}] which is actually equal to ...
0
votes
0answers
33 views

How to perform delayed evaluation containing function with Mathematica

I was wondering whether there is a way in Mathematica to evaluate an expression in the most simple form, without any simplifying. For example if we define: ...
1
vote
2answers
43 views

Parametric function with reference at a central point

Would anyone have any idea how to delete the xy andxyz steps? I tried using the Evaluate ...
1
vote
0answers
35 views

How to use Evaluate inside function definitions? [duplicate]

How to use Evaluate inside function definition so that is acts as Evaluate only whet function is called? This is toy exampl, where I want to define function inside another function: ...
1
vote
1answer
63 views

Why the difference in outputs in different cores?

Executing the code r = RegionIntersection[Region[Ball[3]], Region[Ball[{1/2, 1/3, 5/6}, 1]]]; Region[r] in version 11.3.0.0 on Windows 10 32-bit, I don't ...
5
votes
3answers
346 views

What is the the proper way to define a function from an expression?

Say after some long computation we get an expression expr=x^2 We do not know what the value of expr beforehand. Now we want ...
1
vote
1answer
66 views

Is there any built-in way to loop over a column/lines?

I have a file as following: cat data.m 1 2 3 x+y 2 x + 3 y So it contains rows containing numeric numbers or expressions, which at this stage is not ...
2
votes
0answers
53 views

Integrating over colors

I'm trying to compute the following integral: $$\int_{380 \, \mathrm{nm}}^{700 \, \mathrm{nm}}\mathbf{RGB}(\mathrm{Hue}(\lambda))\frac{\mathrm{d}\lambda}{\lambda^4}$$ where $\mathbf{RBG}$ takes in ...
0
votes
0answers
19 views

Find value of expression based on variable equality instead of assignment

I have certain relations or equalities which determine how different variables are related to each other. These relations are meant to be used to further calculate the value of some other expression. ...
1
vote
0answers
22 views

Cell wierdly auto evaluated when mouse-selecting code through VNC viewer

I have Mathematica 11.3 installed on a Mac. I connect to it from a Windows machine via VNC viewer. Very strangely, whenever I select any piece of code in a cell by clicking and holding my mouse button,...
2
votes
1answer
106 views

Does Mathematica understand dummy variables?

I encountered this problem and was unpleasantly surprised. Let us define a function: g[x_]:=Sum[x^k,{k,0,2}]; k is supposed ...
0
votes
3answers
30 views

Low precision from function returning matrix

Got a function depending on single parameter "t" defined below which returns a 2 by 2 matrix ...
2
votes
0answers
42 views

Evaluate notebook without opening cell groups

I have a notebook with grouped cells, where the input cells are hidden and only output cells open. Is it possible in an easy way to evaluate the whole notebook and preventing opening all groups, ...
0
votes
0answers
43 views

How to stop evaluation of Zeta with even arguments

It could be a duplicate question. However I could not find much after a huge searching. I have a huge expression in mathematica involving many Zetas. I want not to evaluate the even Zetas which ...
8
votes
3answers
236 views

HoldForm: Display exactly as entered?

Sometimes, Mathematica's internal representation of expressions can give somewhat surprising results. Specifically, I noticed this when I tried to preserve products of fractions for display. E.g. ...
0
votes
1answer
48 views

Why isn't my function evaluating to an explicit number?

I'm just wondering why my function is not evaluating as I think it should. I put in the following: ...
3
votes
1answer
31 views

How to evaluate limit of a user-defined function

Limit[(k/(k - 1)), k -> Infinity] Gives correctly: 1 But, ...
0
votes
2answers
39 views

Evaluation control - Hold (?) argument name not argument values

I wanted to produce a list of statistics labelled with the statistic name, for exchange with a database. I defined ...
5
votes
1answer
158 views

Inactivate all occurrences of a symbol

I would like to inactivate all occurrences of a symbol to prevent it from evaluating, regardless where in the evaluation process it appears. A minimal example: ...
3
votes
4answers
245 views

Basic substitution

I am relatively new to Mathematica, so I am sure this is basic, but I lack the basic terminology to be able to google it. How can I make this command work? ...
0
votes
0answers
11 views

Trouble with evaluation and Dynamic [duplicate]

I would like to evaluate the gradient of a certain function at position (x0,y0,z0) where x0, y0, z0 are global variables which can get altered in real-time later in the worksheet. The only way I know ...
6
votes
4answers
417 views

partial numerical evaluation

Context The following is an issue I have come across many times and still do not have a satisfactory solution for. The context of it is this. Let's say we have an equation, a linear ODE for the ...
2
votes
0answers
52 views

non listable plus and times [duplicate]

I am trying to create my own Plus and Times functions, which are identical to the built in ones with the exception that they are ...
0
votes
0answers
60 views

Problem with NIntegrate: it gets stuck when evaluating zero value

I have an integral with complicated function evaluated by MonteCarlo method (please find a folder with two files by the link below). Namely, a function ...
4
votes
1answer
49 views

Is it possible to write an expression A such that Evaluate[Evaluate[A]] is different from Evaluate[A]?

Mathematica is cool for all sorts of "magic tricks", but I'm trying to get an idea on how the core term-rewriting system works. Is it possible to make a term such that the output of its evaluation can ...