MathGroup Archive 2009

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

Search the Archive

Re: Marbles.nb [was Re: CellChangeTimes?]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105847] Re: [mg105836] Marbles.nb [was Re: CellChangeTimes?]
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Mon, 21 Dec 2009 06:55:15 -0500 (EST)
  • Reply-to: jfultz at wolfram.com

On Mon, 21 Dec 2009 03:31:10 -0500 (EST), AES wrote:
> In article <hgl3e5$14p$1 at smc.vnet.net>, magma <maderri2 at gmail.com>
> wrote:
>
>> I am more interested in knowing why you seem to be using Show
>> Expression so often that this feature bothers you? I personally use it
>> veeery rarely . . . Show Expression has a very complex output and
>> IMO should only be used by "hackers" and not regular Mathematica users
>> . . . going so low level is not too time efficient for regular users.
>>
>> If one wants to discover something
>> very special, it is faster to ask here in MathGroup.
>> If you want to see how things work internally (up to a certain level),
>> FullForm should be enough for regular Mathematica users
>> (that is anybody who is not a computer scientist).
>>
>> So: why do you use Show Expression so often to be bothered by
>> CellChangeTimes ?
>>
> Shown below are the entire contents of a notebook Marbles.com:  two
> "identical" Input cells; two mathematically but definitely not
> symbolically identical Output cells:
>
> In[1]:= -(b-a)  I
>
> Out[1]= I (a-b)
>
> In[2]:= -(b-a) I
>
> Out[2]= -I (-a+b)
>
> (The notebook itself can be downloaded from
> <http://www.stanford.edu/~siegman/Marbles.nb>.)
>
> I'm not playing tricks or games here.  The two Input cells are the only
> contents of Marble.nb.  The first Input cell was routinely copied and
> pasted into Marbles.nb from another notebook, which is long gone.  The
> second Input cell was typed in after noting a typographic oddity: the
> character spacing of the  -(b-a) portion is much more tightly spaced in
> the first cell than in the second.
>
> Also, there's the further result that if you append /. {I->-I} to these
> two "identical" (or anyway, identical-seeming) Input cells, you get
> *opposite* results -- something which it seems to me should definitely
> not happen!  (or not without a warning at least)
>
> So, following many stern instructions from this group in earlier
> discussions to use FullForm[],  I wrapped FullForm[ ] around both of
> these Input cells, producing results which matched the differently
> appearing Outputs shown above.
>
> This application of FullForm perhaps also explains or excuses the
> different results obtained using the   I -> -I  substitution -- in some
> people's minds, at least, though not in mine.
>
> Anyway, hoping to gain further understand, I then tried Show Expression
> on these Input cells, and got the results appended below:  (With very
> lengthy CellChangeTimes strings stripped out, of course)
>
> Cell[BoxData[
> RowBox[{
> RowBox[{"-",
> RowBox[{"(",
> RowBox[{"b", "-", "a"}], ")"}]}], "  ", "I"}]], "Input"]
>
> Cell["-(b-a) I", "Input"]
>
> which I think tells me something -- though I'm not sure what.
>
> If anyone from Wolfram wants to know how I got to this aberrant first
> cell, I can try to reconstruct this (it may have something to do with my
> earlier messing around with a modified Default stylesheet).
>
> But in any case:  Should these two Input cells really produce
> *different* results in response to a simple rule?  If the character "I"
> in two Input cells and the rule were replaced by characters "x" or "z"
> or anything other symbol, would one ever get different results?

The first form is the StandardForm version.  Nothing aberrant here...this is
what you get by default when you type an Input cell into Mathematica.  It's a 
structured format for representing typeset input.  The second form is the raw 
InputForm version, which was the default many years ago and can still be used in 
current versions.  Raw InputForm is also what's used when you run the kernel
standalone.  You can switch back and forth between the two forms by using the 
Cell->Convert To submenu.

The difference is caused by the inputs being interpreted differently.  It's not 
enough to just use FullForm.  You have to use FullForm in combination with Hold 
to see this.

In[12]:= FullForm[Hold[-(b-a) I]] (* box form *)

Out[12]//FullForm= Hold[Times[Times[-1,Plus[b,Times[-1,a]]],\[ImaginaryI]]]

In[13]:= FullForm[Hold[-(b - a) I]] (* InputForm form *)

Out[13]//FullForm= Hold[Times[-1,Plus[b,Times[-1,a]],\[ImaginaryI]]]

I.e., the InputForm version treats the multiplication of -1 as being flat with 
the surrounding multiplication, while the StandardForm version scopes the 
multiplication of -1 to the term immediately following.  For reasons which are 
outside of my expertise and I won't comment on further, these differing inputs 
lead to different outputs.  It is basically the difference between these two
inputs...

(-1 (b - a)) I
-1*(b - a)*I

The documentation page tutorial/OperatorInputForms suggests to me that the 
StandardForm version is interpreting correctly while the InputForm version is 
not.  I.e., the prefix operator - should be binding more tightly than other
multiplication operations.

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.




  • Prev by Date: Re: hyperlink back button
  • Next by Date: Re: vector and matrix valued functions
  • Previous by thread: Marbles.nb [was Re: CellChangeTimes?]
  • Next by thread: Re: Marbles.nb [was Re: CellChangeTimes?]