Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

A harmless and amusing bug

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76215] A harmless and amusing bug
  • From: Fred Simons <f.h.simons at tue.nl>
  • Date: Fri, 18 May 2007 06:02:28 -0400 (EDT)

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


  • Prev by Date: Re: All permutations of a sequence
  • Next by Date: Re: Mathematica 6.0 and MatrixManipulations
  • Previous by thread: Re: Help in changing the vertical axis tick label format
  • Next by thread: Re: A harmless and amusing bug