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

*To*: mathgroup at smc.vnet.net*Subject*: [mg54519] Re: [mg54411] Re: [mg54350] Re: [mg54300] Re: [mg54271] Re: Bug Report - Two numerical values for a same variable*From*: Daniel Lichtblau <danl at wolfram.com>*Date*: Tue, 22 Feb 2005 04:23:33 -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> <opsmcn3rqciz9bcq@monster> <07c9f53bde86ce72650298f7c2a6ccbc@mimuw.edu.pl> <opsmcqckt8iz9bcq@monster> <200502190731.CAA06012@smc.vnet.net> <200502200508.AAA20041@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Murray Eisenberg wrote: >I understand everything you say. Here's the crux, I think, of my not >being able to "rationalize" Mathematica's definition of what is or is >not an atom: > >Why is FullForm[2 + 3 I] not Plus[2, Times[3, I]]? > >Why is FullForm[2/3] not Times[2, Power[3, -1]] ? > >My suspicion is that this was simply a design decision made for reasons >of efficiency, and that therefore not much more can be said about it. >That's what makes it hard for me to swallow and explain to others. > >P.S. Unlike some others, I have no difficulty with Mathematica counting >such things as Complex[E, Pi] as meaningless (although syntactically >correct). > > >[...] > These would entail excessive burdens that would be difficult to support (and for questionable gain). Let me indicate a few of the issues. First, it is important to have the ability to recognize a NumberQ object. Having dedicated heads such as Integer, Real, Rational, and Complex, along with internal flagging, is what allows the Mathematica evaluator to do that. This would need to be extended to heads Plus, Times, and Power for which generic expressions are not NumberQ. Next, consider what happens when one works with a sum of "terms" (products of powers). Among other things, terms that agree up to the NumberQ coefficient are grouped together. In[5]:= FullForm[a + I*a] Out[5]//FullForm= Times[Complex[1, 1], a] This would become problematic were e.g. Complex to be replaced by a Plus object. Moreover it becomes even to define what Expand should do. If it gives a true sum of products then we would have to depart from the above grouping in order to support something like Plus[a, Times[I,a]]. If instead we retain the collection of terms that agree up to NumberQ coefficient, then we would destroy the sum-of-products in supporting an Expand'd form of Times[Plus[1,I],a]. I think there would be very real efficiency issues lurking also in basic arithmetic. Having dedicated forms for the NumberQ types can go a long way to rapid dispatching of arithmetic. You can decide for yourself whether you think this is a compelling issue (I do). But the issues involving sums of terms have real ramifications that go beyond efficiency and into the language semantics. Daniel Lichtblau Wolfram Research

**References**:**Re: Bug Report - Two numerical values for a same variable***From:*Scott Hemphill <hemphill@hemphills.net>

**Re: Re: Bug Report - Two numerical values for a same variable***From:*Murray Eisenberg <murray@math.umass.edu>

**Re: Re: Re: Bug Report - Two numerical values for a same variable***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>

**Re: Re: Re: Re: Bug Report - Two numerical values for a same variable***From:*Murray Eisenberg <murray@math.umass.edu>