MathGroup Archive 2005

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

Search the Archive

Re: Re: Re: Bug Report - Two numerical values for a same variable

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54341] Re: [mg54300] Re: [mg54271] Re: Bug Report - Two numerical values for a same variable
  • From: DrBob <drbob at bigfoot.com>
  • Date: Sat, 19 Feb 2005 02:31:41 -0500 (EST)
  • References: <00ed01c512b0$2f242850$6400a8c0@Main> <curpbn$r28$1@smc.vnet.net> <200502150438.XAA29728@smc.vnet.net> <200502161936.OAA19223@smc.vnet.net> <d3d3aacf7f18939828890ce85676bd26@mimuw.edu.pl>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

Your "structure" argument is too vague to be useful.

ls={3+2*I,3+E*I,3.+E*I,Pi+2.*I,Pi+2*I,Pi+E*I};
AtomQ/@ls

{True,False,True,True,False,False}

Length/@ls

{0,2,0,0,2,2}

Map[g, ls, -1]
{g[3 + 2*I],
   g[g[3] + g[g[I]*g[E]]],
   g[3. + 2.718281828459045*I],
   g[3.141592653589793 + 2.*I],
   g[g[2*I] + g[Pi]],
   g[g[Pi] + g[g[I]*g[E]]]}

Map[NumericQ, ls, -1]
{True, False, True, True, False, False}

Map[NumericQ, ls, 1]
{True, True, True, True, True, True}

NumericQ[Pi + E*I]
NumericQ[Complex[Pi, E]]
True
False

The last result, at least, seems unambiguously wrong.

Bobby

On Thu, 17 Feb 2005 08:37:48 +0100, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:

> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> The reasons why Rational[2,3] or Complex[2,3] are atoms are nor really
> mathematical but come from considering the structure of expressions in
> the Mathematica language and way expressions are transformed by various
> structured operations. To see what I mean consider the following list
>
> ls = {1, 2, 3/4, 5 + 6*I, Rational[a, b]};
>
>
> Note that 3/4 evaluates to the atom Rational[3,4] but Rational[a,b] is
> not an atom and is actually meaningless.
> I think most people would agree that we would like all the numbers
> 1.2,3/4 and 5+6I to be treated "in the same way" by various structured
> operations that accept level specifications, such as like Map, Apply
> etc. This is indeed the case. Consider
>
> In[2]:=
> Map[g, ls, -1]
>
> Out[2]=
> {g[1], g[2], g[3/4], g[5 + 6*I], g[Rational[g[a], g[b]]]}
>
> You can see the difference between the treatment of the atomic
> Rational[3,4] (or Complex[5,6]) and non-atomic Rational[a,b]. This and
> similar reasons justify treating Rational[3,4] and Complex[5,6] as
> atoms. This is a quite different issue from the one whether  rationals
> or complex numbers are in some mathematical sense "atoms" or not. A
> case can be made both for the "yes" and the "no" answer, but it has
> nothing to do with the reason why in Mathematica Rational[2,3] and
> Complex[5,6] are atoms.
>
> Andrzej Kozlowski
>
>
> On 16 Feb 2005, at 20:36, Murray Eisenberg wrote:
>
>> The manipulations below are precisely what's so confusing about
>> Rational
>> objects (and Complex objects) being atoms.  If
>>
>>    1/2 /. Rational[x_, 2] -> Rational[x, 7]
>>
>> works, then why not the following?
>>
>>    Part[Rational[1, 2], 2]
>>
>> I can "believe" that integers and reals (and maybe strings) are atoms;
>> but believing that rationals and complex numbers are atoms is a hard
>> thing to swallow!
>>
>> This has always bothered me -- and hence given me trouble trying to,
>> um,
>> rationalize this to students when I've taught Mathematica.
>>
>>
>> Scott Hemphill wrote:
>>> DrBob <drbob at bigfoot.com> writes:
>>>
>>>
>>>> That explains it, but only in the sense that "things fall down" is a
>>>> theory of gravity. Why should Rationals be atomic, for goodness
>>>> sake? And how did I use Mathematica all this time without hearing
>>>> about it?
>>>>
>>>> Sigh...
>>>
>>>
>>>
>>> In[1]:= FullForm[1/2]
>>>
>>> Out[1]//FullForm= Rational[1, 2]
>>>
>>> In[2]:= 1/2 /. Rational[x_,2] -> Rational[x,7]
>>>
>>>         1
>>> Out[2]= -
>>>         7
>>>
>>> Scott
>>
>> --
>> Murray Eisenberg                     murray at math.umass.edu
>> Mathematics & Statistics Dept.
>> Lederle Graduate Research Tower      phone 413 549-1020 (H)
>> University of Massachusetts                413 545-2859 (W)
>> 710 North Pleasant Street            fax   413 545-1801
>> Amherst, MA 01003-9305
>>
>>
>
>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • Prev by Date: Re: error mesages
  • Next by Date: Re: Re: Re: Bug Report - Two numerical values for a same variable
  • Previous by thread: Re: Re: Re: Bug Report - Two numerical values for a same variable
  • Next by thread: Re: Re: Re: Bug Report - Two numerical values for a same variable