# Why a Precision problem for Floor of quotient of Logs?

This line returns a Precision problem:

Floor[Log[9]/Log[3]]


This one works fine:

Floor[Log[9]/Log[3]//N]


What I don't understand is why one works while the other doesn't because I assume that internally Mathematica would numerically evaluate the argument of Floor first anyway, so the two lines should be logically equivalent, the 2nd one just redundant. But clearly I was wrong. What did I misunderstand about how Floor works?

• Not an answer, but try Floor[Log[9]/Log[3]] // FullSimplify. -- Interesting, N also works: N[Floor[Log[9]/Log[3]]]. – Goofy Feb 21 '17 at 1:12
• Maybe after an initial estimate of 2, it tries to determine whether it is greater than or less than 2. This gives a similar error: N[Log[9]/Log[3] - 2, 30]. – Goofy Feb 21 '17 at 1:20
• Floor is discontinuous at the integers. Any attempt to use numeric methods on an exact example will have trouble there.That's what the message indicates. – Daniel Lichtblau Feb 21 '17 at 4:44
• @DanielLichtblau But what is happening differently in the two lines of code I presented? – Jerry Guern Feb 21 '17 at 7:54
• as an example Floor[ Log[36]/Log[6] // N ] (*1*) – george2079 Feb 21 '17 at 21:33

While the comments already contain a complete answer by Daniel Lichtblau, this behavior is also documented on ref/Floor, see the first example under 'Possible Issues':
Floor[π^2 + 2 π + 1 - (π + 1)^2]
$MaxExtraPrecision = 50. reached while evaluating Floor[1+2π+π^2-(1+π)^2]. *) (* Floor[1 + 2 π + π^2 - (1 + π)^2] *)  Even though 1 + 2 π + π^2 - (1 + π)^2 is in fact the exact integer 0, it is a "hidden zero" which cannot be unmasked using purely numerical methods. Unlike other functions like FullSimplify and PossibleZeroQ which may use symbolic algorithms, Floor is limited to numerical methods, see also this documentation note For exact numeric quantities, Floor internally uses numerical approximations to establish its result. and the numerical approximation will never yield an exact zero, no matter how much extra precision is allowed, e.g. Block[{$MaxExtraPrecision = 1000}, N[π^2 + 2 π + 1 - (π + 1)^2, 50]]

Similarly, Log[9]/Log[3] is a "hidden integer". Numerical approximation of the exact quantity Log[9]/Log[3] - 2 is difficult, while numerical approximation of the machine precision number N[Log[9]/Log[3]] - 2` is not.