I am aware of the use of 'Assumptions' or 'Assuming' to attach to certain operations (e.g. integrals) to aid Mathematica. Is there a way of listing asssumptions at the beginning of a piece of code such that every evaluation thereafter makes use of them, rather than writing the assumptions in every evaluation? Thanks in advance for any help.
1 Answer
$\begingroup$
$\endgroup$
2
You can check if using
Block[{$Assumptions =...}, ...]
will do the trick for you.
$Assumptions
is a global variable, so the Block
construct just plays the the role of localising the effect of changing it -- thanks @Natas in comments.
Sorry, I'm a newbie here so don't know how to refer to the comment
-
1$\begingroup$ Perhaps you should also point out that
$Assumptions
can be set outside of block? I think OP is referring to the optionsAssumptions
(see parenthetical remark in OP). $\endgroup$– NatasCommented Jul 16, 2020 at 12:14 -
$\begingroup$ @Chris - Note that "such that every evaluation thereafter makes use of them" will in general not be achieved since assumptions only affect functions that make use of the
Assumptions
option. Consequently almost "every evaluation" would need to includeSimplify
orFullSimplify
to ensure that the assumptions were used. This could significantly impact performance. Further, you would still need to explicitly include the assumptions in the system of equalities and inequalities given toSolve
,Reduce
,FindInstance
, or other functions that take constraints. $\endgroup$ Commented Jul 16, 2020 at 14:45