Re: Equality question

• To: mathgroup at smc.vnet.net
• Subject: [mg29541] Re: [mg29539] Equality question
• From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
• Date: Sun, 24 Jun 2001 02:00:56 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```on 6/23/01 2:47 PM, gleam at flashmail.com at gleam at flashmail.com wrote:

> Hi, I'm new to this mailing list, and rather new to Mathematica.
>
> Why doesn't Mathematica 4.1 yield True for this expression:
>
> TrueQ[(n - 1)^2 + n == n^2 - n + 1]
>
>
>
The way to check if such an expression is True or False is:

In[5]:=
Simplify[(n - 1)^2 + n == n^2 - n + 1]

Out[5]=
True

The Predicate TrueQ is not meant for such purposes.It does not in itself
invoke any simplifications because if it did it would be inconvenient to use
it programs where you want the expression TrueQ[x] to remain unevaluated.
Also for programming reasons all Mathematica predicates which do not return
True return False (even though that might look like a false answer!). In the
case of very simple expresion Mathematica will perform simplifications
without the use of Simplify, and in such cases applying TrueQ will yield
True because in any case the  result of the evaluation was True before TrueQ
was applied, e.g:

In[8]:=
TrueQ[n + 1 + 1 == n + 2]

Out[8]=
True

because

In[9]:=
n + 1 + 1 == n + 2

Out[9]=
True

On the other hand in your case:

In[10]:=
(n - 1)^2 + n == n^2 - n + 1

Out[10]=
2                 2
(-1 + n)  + n == 1 - n + n

Mathematica does not simplify this expression (without applying Simplify),
so TrueQ, which must return True or False has to return False. It does look
strange, but that is because Mathematica's predicates are not meant to serve
the purpose of "answering a question", which beginners sometimes assume them
to be for
e.g.

In[14]:=
IntegerQ[(1 + Sqrt[2])^2 - 1 - 2*Sqrt[2]]

Out[14]=
False

but are intended for writing fucntions of the kind

If[IntegerQ[x], ....]

and so on.

I hope this is clear enough.

--
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/~andrzej/

```

• Prev by Date: Re: Fitting data
• Next by Date: Re: RE: Originality
• Previous by thread: Re: Equality question
• Next by thread: Re: Equality question