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
34 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
109 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
30 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 ...
2
votes
1answer
39 views

How to Evaluate a Cell written in code and store the result in a variable

Consider the following command. CellPrint[Cell["[1,2,3]", "ExternalLanguage"]] It creates a python cell with command [1,2,3]. ...
3
votes
3answers
309 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
43 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 ...
2
votes
0answers
75 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
176 views

Maximum point of a rational function

Suppose I have the following rational function: ...
10
votes
1answer
129 views

Why doesn'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
39 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
74 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
94 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
33 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
45 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
104 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
180 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
34 views

Why aren't my variables evaluated in this function?

Consider this code : ...
1
vote
2answers
81 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
42 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
227 views

Force evaluation of user-defined function

Consider a function that sorts its arguments based on a function called order ...
1
vote
0answers
93 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
65 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
46 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: ...
3
votes
2answers
53 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
44 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
70 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 ...
7
votes
5answers
421 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
67 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 ...
4
votes
1answer
91 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
22 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
25 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
173 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
33 views

Low precision from function returning matrix

Got a function depending on single parameter "t" defined below which returns a 2 by 2 matrix ...
3
votes
1answer
117 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, ...
1
vote
1answer
84 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 ...
9
votes
3answers
258 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
51 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
45 views

How to evaluate limit of a user-defined function

Limit[(k/(k - 1)), k -> Infinity] Gives correctly: 1 But, ...
0
votes
2answers
55 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
279 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
13 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
479 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
53 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
106 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
53 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 ...
4
votes
3answers
187 views

Handling expression differently for display vs. calculation?

I have a function I wrap a lot of my numbers with to factor them and display them out a certain way. Usually I do this at the last step of a calculation, but sometimes it would be nice if I could ...
4
votes
1answer
78 views

Subtle order-of-evaluation issues when pattern-matching with attributes

Related question concerning unrolling the tests that are shown below: Big and Little surprises when unrolling tests of pattern-matching and attributes Questions researched before posting this one: ...
4
votes
3answers
43 views

Controlling HoldForm while mapping

If I execute A = {Sin, Cos, Tan} B = {ArcSin, ArcCos, ArcTan} #[[1]]@#[[2]]@x & /@ Transpose[{A, B}] the output is ...