MathGroup Archive 2014

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

Search the Archive

LeafCount and ByteCount Lie in Mathematica

  • To: mathgroup at
  • Subject: [mg132686] LeafCount and ByteCount Lie in Mathematica
  • From: Richard Fateman <fateman at>
  • Date: Sun, 4 May 2014 02:28:36 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:

Mathematica 9.0 .. on a 32 bit windows machine.

f[n_] := Block[{k = f[n - 1]}, {k, k}]

  LeafCount[f[k]]  for particular small integers k
returns  the number 2^(k+1)-1.   e.g. for k=3, it returns 15.

But it returns the same answer for k=30, 31, ....
  It returns 2147483647,  which, probably not coincidentally, is 2^31-1.

ByteCount has a similar problem in running out of bits in
its counter.

Anyway, ByteCount also lies in a different way...
  because it doesn't take into account the
sharing that (say) f[70] has.  Without the sharing
implicit in the formula above, I could not compute that --
it has 2.36 X 10^21 leaves. They are just not different leaves.

I would expect that a 64-bit system might work for k=31,
but would conk out somewhere else.

  • Prev by Date: Re: How to avoid repeated recalculation of the same function
  • Next by Date: Re: Version 9 export to PDF creates ridiculously large
  • Previous by thread: Period of numerically defined function and generality
  • Next by thread: mathscr fonts