$Assumption for multiple variables

五迷三道 提交于 2019-12-04 13:44:36

If all of your variables are going to be (for example) Real, then you can intercept the creation of new symbols and add that assumption to $Assumptions. E.g.

$Assumptions = True;
$NewSymbol = If[#2 === "Global`",
    Print["Created new Global` variable named ", #1, ". It is assumed to be real."];
    $Assumptions = $Assumptions && Element[Symbol[#2 <> #1], Reals],
    Null (* other, probably a system symbol is created *)] &;

Then if you create a new symbol that you don't want to be real, then you could follow up with something like $Assumptions = Most[$Assumptions].


Note: I don't necessarily claim that this approach is a good idea... It's probably best to just define the $Assumptions for the variables you are going to use. This can be done programmatically using Map, Table, etc.

user4315525

Globally define as follows

$Assumptions = b >= 0 && c >= 0 && {u11, u13, u14} \[Element] Reals

then use globally defined variables as follows

Simplify[expression  with global variables] 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!