MathGroup Archive 2007

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

Search the Archive

Re: Floor doesn't compute in some cases

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83314] Re: Floor doesn't compute in some cases
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 17 Nov 2007 05:24:38 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <fhjqkk$3gq$1@smc.vnet.net>

Valeri Astanoff wrote:

> Floor doesn't compute in some cases:
> 
> Floor[Log[31]/Log[2]]
> 
> 4
> 
> ok, but:
> 
> Floor[Log[32]/Log[2]]
> 
> Floor::meprec: Internal precision limit $MaxExtraPrecision = 50.`
> reached while evaluating Floor[Log[32]/Log[2]]. >>
> 
> Floor[Log[32]/Log[2]]
> 
> $Version
> 
> 6.0 for Microsoft Windows (32-bit) (June 19, 2007)
> 
> I don't see the reason why...

Looking at In/Out[1], we can see that Log[32]/Log[2] is not simplified 
to 5, and that we need to use FullSimplify or N to get this value. 
Obviously Floor does not call either functions and uses arbitrary 
precision arithmetic to compute its result. (And arbitrary precision 
fails, this is the meaning of the error message.)

In[1]:= {Identity[#], N[#], Simplify[#], FullSimplify[#], Floor[#]} &[
  Log[32]/Log[2]]

During evaluation of In[1]:= Floor::meprec: Internal precision limit \
$MaxExtraPrecision = 50.` reached while evaluating \
Floor[Log[32]/Log[2]]. >>

Out[1]= {Log[32]/Log[2], 5., Log[32]/Log[2], 5,
  Floor[Log[32]/Log[2]]}


So to get the expected result, we must force the evaluation or 
simplification of the logarithms before calling Floor. Note that even 
though N returns a machine-precision number, 5., the answer returned by 
Floor is still an exact (infinite-precision) number.

In[2]:= Floor[N[Log[32]/Log[2]]]

Out[2]= 5

In[3]:= Floor[FullSimplify[Log[32]/Log[2]]]

Out[3]= 5

Best regards,
-- 
Jean-Marc


  • Prev by Date: Re: Does ColorFunction-> have different meanings to Plot3D and
  • Next by Date: Re: memory release problem in mathematica6.0
  • Previous by thread: Re: Floor doesn't compute in some cases
  • Next by thread: Re: Floor doesn't compute in some cases