MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Is it a bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17700] Re: [mg17640] Re: Is it a bug?
  • From: David Withoff <withoff>
  • Date: Sun, 23 May 1999 02:25:23 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> Thanks to all who have told me that it is not a strange result.
>
> But now look at the online-help under "Cases - Further Examples". You can
> find the following lines:
>
> This finds all elements in the list that are integers.
> Cases[{.....}, _Integer]
>
> And now we test it:
>
>     x = Sqrt[I]-1/Sqrt[2](1+I);
>     Cases[{x, x//FullSimplify},_Integer]
> Out[]= {0}
> 
> It cannot be that a number becomes an integer by doing a "FullSimplify".
> Shouldn't the text in the online-help be changed to the following:
> 
> This finds s o m e elements in the list that are integers and when you are
> in doubt look at the FullForm!!
> 
> The statement "Cases[{...},_Integer]" is quite useless because often I want
> to know if elements are integers but seldom I want to know if the FullForm
> of an element is integer.

If you want to select expressions for which FullSimplify of the expression
give an integer you can use Select[{...}, IntegerQ[FullSimplify[#]]&], or
using Cases with the corresponding pattern.

In response to your question, no, the example should not be changed to
say that it finds "some" elements that are integers.  The term "integers"
in this context is a technical term that refers to expressions that
are explicitly integers.  With that definition, Cases[{...},_Integer]
finds all expressions that are integers.  

If you want to find all expressions for which there is some assortment
of transformations or identities that will convert the expression into an
integer, no computer program will do that.  It is always possible to come
up with expressions that are integers but for which the transformations
and identities necessary to demonstrate that fact are so complicated or
obscure that no computer program, not even something like FullSimplify,
is likely to be able to figure out that the expression is an integer.

Automatic simplifications in Mathematica will convert some expressions
that are integers into integers, Simplify and FullSimplify will do those
transformations for a much larger class of expressions.  If Mathematica
applied FullSimplify to everything automatically, it would be
prohibitively slow.  That basically answers your remaining questions:

> Why doesn't Mathematica do any calculation on the expression x =
> Sqrt[I]-1/Sqrt[2](1+I); ??
> If you have Cases[ { I I }, _Integer ] the expression is calculated to -1.
> Is the expression to complicated ??

Dave Withoff
Wolfram Research


  • Prev by Date: Re: Repost: Solve: same or new bug?
  • Next by Date: MatrixForm
  • Previous by thread: Re: Is it a bug?
  • Next by thread: Not a floating-point number message