How do you handle the floor and ceiling function in an equation?

Solution 1:

You can replace $\lfloor x \rfloor$ with $x - \theta$, where $\theta \in [0,1)$ is some unknown quantity. Similarly, $\lceil x \rceil = x + \theta$ (a different $\theta$ within the same range).

Another helpful identity is $\lfloor x \rfloor + n = \lfloor x + n \rfloor$ for any integer $n$.

Solution 2:

Your final expression gives you the number you want.

According to your blog post, you're looking for the smallest integer $n$ (i.e., the "first Fibonacci number with 1000 digits") that satisfies $$G(n) = \left\lfloor n \log \varphi - \frac{\log 5}{2} \right\rfloor + 1.$$ There may, of course, be more than one integer $n$ for which this is true.

By definition of the floor function, the values of $n$ that satisfy this are the values that satisfy $$G(n) - 1 \leq n \log \varphi - \frac{\log 5}{2} < G(n),$$ which, since $\log \phi > 0$, are the values that satisfy $$\frac{G(n) + \frac{\log 5}{2}}{\log \varphi} - \frac{1}{\log \varphi} \leq n < \frac{G(n) + \frac{\log 5}{2}}{\log \varphi}.$$

Since $\frac{1}{\log \varphi} \approx 4.78$, there are either four or five integers in this interval. But the smallest one is obtained by taking the ceiling of the lower endpoint of the interval; i.e., $$\left\lceil\frac{G(n) + \frac{\log 5}{2} - 1}{\log \varphi}\right\rceil.$$

Incidentally, this argument also apparently shows that there are either four or five Fibonacci numbers that have a given number of digits. (Except in the single-digit case, where there are six (not counting 0). But your formula for $G(n)$ doesn't hold when $n=1$, so we shouldn't expect this calculation to be true in the single-digit case anyway.)

Solution 3:

Observe that \begin{eqnarray} G(n) = \left \lfloor n \log \varphi - \log \sqrt{5} \right \rfloor + 1 = \left \lceil n \log \varphi - \log \sqrt{5} \right \rceil \end{eqnarray} and write \begin{eqnarray} \left \lceil \frac{G(n)}{\log \varphi} + \log_{\varphi} \sqrt{5} \right \rceil & = & \left \lceil \tfrac{1}{\log \varphi} \left \lceil n \log \varphi - \log \sqrt{5} \right \rceil + \log_{\varphi} \sqrt{5} \right \rceil = n. \end{eqnarray}