       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

=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, where I've used t1 and t2, is different from Out, where
>I've used the undeclared variables s1 and s2.

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 and Out, 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:= \$Assumptions = Element[{t1, t2}, Reals]
>Out= (t1 | t2) \[Element] Reals

>In:= FullSimplify[Sqrt[(t2 - t1)^2]]
>Out= Abs[t1 - t2]

>In:= FullSimplify[Sqrt[(s2 - s1)^2]]
>Out= Sqrt[(s1 - s2)^2]

>In:= \$Assumptions = t2 > t1
>Out= t2 > t1

>In:= FullSimplify[Sqrt[(t2 - t1)^2]]
>Out= -t1 + t2

```

• Prev by Date: Re: Meshshading
• Next by Date: Re: Why doesn't TrueQ return True here?
• Previous by thread: Re: Why doesn't TrueQ return True here?
• Next by thread: Re: Why doesn't TrueQ return True here?