Re: A harmless and amusing bug

*To*: mathgroup at smc.vnet.net*Subject*: [mg76337] Re: [mg76215] A harmless and amusing bug*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Sun, 20 May 2007 02:22:08 -0400 (EDT)*References*: <200705181002.GAA12592@smc.vnet.net>

There is a simpler way to demonstrate essentially the same phenomonon wihtout any copying and pasting. First define a by evaluating a=Rational[1,2]& Now define b as follows. We use the same definition b=Rational[1,2]& but before evaluating it we convert it to StandardForm by selecting the cell bracket and using the Convert To menu. After converting the cell we evaluate it. Now a === b False Just as in your example, a and b have different FullForm. I don't know whether to call this a bug or not as it seems to me a more or less inevitable consequence of the way atoms with head Rational are formated. But it's certainly strange and unintuitive. Andrzej Kozlowski On 18 May 2007, at 19:02, Fred Simons wrote: > I found this example in a very old notebook of mine and I do not > remember if this has already been discussed in this group. > > The following seems to be a harmless and amusing bug. It happens > both in > Mathematica 5 and in Mathematica 6 under Windows. > > Execute the following command: > > y = x /. DSolve[x''[t]+ 2 x'[t]+ x[t]==Sin[t], x, t][[1]] > > Copy the result, paste it in the following command and execute. > > z =pasted result > > Obviously, y equals z. However, > > SameQ[y,z] --> False > > So here we have an example of two different Mathematica expressions > with > the property that on level 1 all subexpressions are equal: > > And @@ Table[y[[i]] === z[[i]], {i, 0,2}] --> True > > It also is an example of two different expressions that convert to the > same string: > > Equal[ToString /@ {y,z}] --> True > > The expression y has more leaves than can be found at level -1, and > anyway less than the number of leaves of the expression z: > > {LeafCount[#], Length[Level[#, {-1}, Heads->True]]}& /@ {y,z} --> > {{27,25},{29,29}} > > Fred Simons > Eindhoven University of Technology >

**References**:**A harmless and amusing bug***From:*Fred Simons <f.h.simons@tue.nl>