Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3209

Re: Why doesn't TrueQ return True here?

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Why doesn't TrueQ return True here?
Date 2011-06-21 09:53 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <itppm4$kdc$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 6/20/11 at 7:37 PM, walkeystalkey@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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Why doesn't TrueQ return True here? Bill Rowe <readnews@sbcglobal.net> - 2011-06-21 09:53 +0000

csiph-web