CONTINUED FRACTIONS

The continued fraction of log(N) and the powers of N
An interesting relation between powers of 2 and 3 was noted in L.E. Garner "On the Collatz 3n+1 algorithm", Proc. Am. Math. Soc. 82, 1981, 19-22.
Given the j-th power of 3, let p(j) be the largest power of 2 that is less than 3j. Therefore 2p(j) < 3j < 2p(j)+1 The author noticed that "the powers of 2 appear to be bounded away from the powers of 3 by an amount which grows almost as rapidly as the power of 3", and he defines

```      b(m) = maxj ≤ m [-log(1 - 2p(j)/3j)]
B(m) = maxj ≤ m [-log(2p(j)+1/3j - 1)]
```
Then the article presents a table of the values of m at which b(m) or B(m) increase. Here is the table with a few more columns:
• the index of the row, k
• the difference, dm, between m(k) and m(k-1)
• the value of p(m) or P(m)=p(m)+1, when b or B increases, respectively
• the difference, dp, between p or P at m and at m-1
• the number of rows with same dm
• whether b(m) or B(m) increases

```  k      m     dm    p/P     dp     nr  b(m) B(m)

1______1______1______2______1______1___*____+_____
2      2      1      3      2      1   +
3______3______1______5______2______2____ ___+_____
4      5      2      8      3               +
5______7______2_____11______3______2___+__________
6     12      5     19      8          +
7_____17______5_____27______8______3________+_____
8     29     12     46     19               +
9     41     12     65     19               +
10_____53_____12_____84_____19______1___+__________
11_____94_____41____149_____65______5________+_____
12    147     53    233     84               +
13    200     53    317     84               +
14    253     53    401     84               +
15    306     53    485     84               +
16____359_____53____569_____84______2___+__________
17    665    306   1054    485          +
18____971____306___1539____485_____23________+_____
19   1636    665   2593   1054               +
20   2301    665   3647   1054               +
...
40  15601    665  24727   1054               +
41__16266____665__25781___1054______2___+__________
42  31687  15601  50508  24727          +
...
```

The rows can be grouped into blocks. A block ends after a shift from increasing b(m) to increasing B(m), or viceversa.
The number nr(m) are the numbers of rows in the block.

The quotients in bold p(m)/m, or P(m)/m, are "the best" approximations to log2(3).

The coefficients of the continued fraction expansion of log2(3) is the sequence A028507 in the On-line Encyclopedia of Integer Sequences.

```1, 1, 1, 2, 2, 3, 1, 5, 2, 23, 2, 2, 1, 1, 55, 1, 4, 3, 1, 1, 15, 1,
9, 2, 5, 7, 1, 1, 4, 8, 1, 11, 1, 20, 2, 1, 10, 1, 4, 1, 1, 1, 1, 1,
37, 4, 55, 1, 1, 49, 1, 1, 1, 4, 1, 3, 2, 3, 3, 1, 5, 16, 2, 3, 1, 1,
1, 1, 1, 5, 2, 1, 2, 8, 7, 1, 1, 2, 1, 1, 3, 3, 1, 1, 1, 1, 5, 4, 2,
2, 2, 16, 8, 10, 1, 25, 2, ...
```

The convergents of this continued fraction are the "best approximations" fractions in the above table.

Prove that the numbers nr(j) are the terms of the sequence A028507.

Hint.
This is a general fact. It holds for any pair of numbers, not just 2 and 3.
Consider the differences |p(m)/m - log2(3)|.

Marco Corvi - 2016