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

Problem with base 2 logs and Floor

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73001] Problem with base 2 logs and Floor
  • From: neillclift at msn.com
  • Date: Sun, 28 Jan 2007 01:11:55 -0500 (EST)

Hi,

When I use an expression like this:

r - Floor[Log[2, r]] - 1 /. r -> 4

I get precision errors in Mathematica 5.2. If I use an expression like 
this:

N[r - Floor[Log[2, r]] - 1] /. r -> 4

I get a correct result of 1 and no errors. If I use an expression like 
this I get the same result:

N[r - Ceiling[Log[2, r]] - 1] /. r -> 4

This is to be expected as Floor[Log[2, r]]  = Ceiling[Log[2, r]]  when 
r is a power of two.
Unfortunatly the expessions diverge for r=8:

N[r - Floor[Log[2, r]] - 1] /. r -> 8 gives 5
N[r - Ceiling[Log[2, r]] - 1] /. r -> 8 gives 4

How can I get exacts results for expessions like this?
Thanks.
Neill.


  • Prev by Date: Re: Changing Defaults
  • Next by Date: Re: Changing Defaults
  • Previous by thread: Re: Schlegel diagram
  • Next by thread: Re: Problem with base 2 logs and Floor