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.


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 options Assumptions (see parenthetical remark in OP). $\endgroup$ – Natas Jul 16 '20 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 include Simplify or FullSimplify 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 to Solve, Reduce, FindInstance, or other functions that take constraints. $\endgroup$ – Bob Hanlon Jul 16 '20 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.