Average Error: 29.8 → 0.1
Time: 23.6s
Precision: 64
Internal Precision: 1600
\[\log \left(N + 1\right) - \log N\]
\[\begin{array}{l} \mathbf{if}\;\log \left(1 + N\right) - \log N \le 8.96628332219472 \cdot 10^{-07}:\\ \;\;\;\;(\left(\frac{\frac{1}{3}}{N} - \frac{1}{2}\right) \cdot \left(\frac{1}{N \cdot N}\right) + \left(\frac{1}{N}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{1 + N}\right) + \left(\log \left(\sqrt{1 + N}\right) - \log N\right)\\ \end{array}\]

Error

Bits error versus N

Derivation

  1. Split input into 2 regimes
  2. if (- (log (+ N 1)) (log N)) < 8.96628332219472e-07

    1. Initial program 59.9

      \[\log \left(N + 1\right) - \log N\]
    2. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{3} \cdot \frac{1}{{N}^{3}} + \frac{1}{N}\right) - \frac{1}{2} \cdot \frac{1}{{N}^{2}}}\]
    3. Simplified0.0

      \[\leadsto \color{blue}{(\left(\frac{\frac{1}{3}}{N} - \frac{1}{2}\right) \cdot \left(\frac{1}{N \cdot N}\right) + \left(\frac{1}{N}\right))_*}\]

    if 8.96628332219472e-07 < (- (log (+ N 1)) (log N))

    1. Initial program 0.2

      \[\log \left(N + 1\right) - \log N\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.2

      \[\leadsto \log \color{blue}{\left(\sqrt{N + 1} \cdot \sqrt{N + 1}\right)} - \log N\]
    4. Applied log-prod0.2

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{N + 1}\right) + \log \left(\sqrt{N + 1}\right)\right)} - \log N\]
    5. Applied associate--l+0.2

      \[\leadsto \color{blue}{\log \left(\sqrt{N + 1}\right) + \left(\log \left(\sqrt{N + 1}\right) - \log N\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\log \left(1 + N\right) - \log N \le 8.96628332219472 \cdot 10^{-07}:\\ \;\;\;\;(\left(\frac{\frac{1}{3}}{N} - \frac{1}{2}\right) \cdot \left(\frac{1}{N \cdot N}\right) + \left(\frac{1}{N}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{1 + N}\right) + \left(\log \left(\sqrt{1 + N}\right) - \log N\right)\\ \end{array}\]

Runtime

Time bar (total: 23.6s)Debug logProfile

herbie shell --seed 2018217 +o rules:numerics
(FPCore (N)
  :name "2log (problem 3.3.6)"
  (- (log (+ N 1)) (log N)))