Re: Why doesn't TrueQ return True here?
- To: mathgroup at smc.vnet.net
- Subject: [mg119767] Re: Why doesn't TrueQ return True here?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Tue, 21 Jun 2011 05:52:42 -0400 (EDT)
On 6/20/11 at 7:37 PM, walkeystalkey at gmail.com (Jacare Omoplata) wrote: >So, if I wanted Mathematica to work on t1 and t2 like real numbers I >should use "$Assumptions = Element[{t1,t2},Reals]" ? This would be one way. But setting $Assumptions in this manner affects *all* usages of t1 and t2 and *all* built-in functions that make use of $Assumptions. That is this is a global assignment that may have undesired consequences latter on in your Mathematica session. =46or myself, I much prefer using the Assuming syntax which locally modifies the assumptions being used, i.e., doing Assuming[t2>t1, Simplify[t2-t1>0]] This avoids any possibility of impacting things you did not intend to modify. >It does SOMETHING, according to the following output, because >Out[3], where I've used t1 and t2, is different from Out[4], where >I've used the undeclared variables s1 and s2. The previous comments about doing nothing applied to doing Element[{t1,t2},Reals] in a cell by itself. Your code below modifies $Assumptions. The function Element only does something useful when used as an argument to Assuming or when assigned to $Assumptions. >But it still doesn't give t2-t1 as the answer, but gives Abs[t1-t2] >instead. But I get t2-t1 as the answer in Out[6] and Out[7], where I >have declared that t2>t1 beforehand. Right. First you only declared t1 and t2 to be real. Consider the difference between say Abs[-4 - 2] = 6 and Abs[4 - 2] = 2 You have say more about t1 and t2 then simply being real for Mathematica to simplify Abs[t2-t1]. When you changed $Assumptions to be t2>t1 you gave enough information for Mathematica to simplify Abs[t2-t1]. Further, since t2>t1 cannot be evaluated for complex t1,t2, you are implicitly restricting t2 and t1 to be real. >-----------output-below------------- >In[1]:= $Assumptions = Element[{t1, t2}, Reals] >Out[1]= (t1 | t2) \[Element] Reals >In[3]:= FullSimplify[Sqrt[(t2 - t1)^2]] >Out[3]= Abs[t1 - t2] >In[4]:= FullSimplify[Sqrt[(s2 - s1)^2]] >Out[4]= Sqrt[(s1 - s2)^2] >In[5]:= $Assumptions = t2 > t1 >Out[5]= t2 > t1 >In[6]:= FullSimplify[Sqrt[(t2 - t1)^2]] >Out[6]= -t1 + t2