Average Error: 29.6 → 0.1
Time: 1.6m
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 1.8311825175768015 \cdot 10^{-05}:\\ \;\;\;\;\left(\frac{1}{N} + \frac{1}{3} \cdot \frac{1}{{N}^{3}}\right) - \frac{1}{2} \cdot \frac{1}{{N}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{1 + N}{N}\right)\\ \end{array}\]

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    1. Initial program 59.7

      \[\log \left(N + 1\right) - \log N\]
    2. Initial simplification59.7

      \[\leadsto \log_* (1 + N) - \log N\]
    3. 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}}}\]

    if 1.8311825175768015e-05 < (- (log (+ N 1)) (log N))

    1. Initial program 0.2

      \[\log \left(N + 1\right) - \log N\]
    2. Initial simplification0.2

      \[\leadsto \log_* (1 + N) - \log N\]
    3. Using strategy rm
    4. Applied log1p-udef0.2

      \[\leadsto \color{blue}{\log \left(1 + N\right)} - \log N\]
    5. Applied diff-log0.1

      \[\leadsto \color{blue}{\log \left(\frac{1 + N}{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 1.8311825175768015 \cdot 10^{-05}:\\ \;\;\;\;\left(\frac{1}{N} + \frac{1}{3} \cdot \frac{1}{{N}^{3}}\right) - \frac{1}{2} \cdot \frac{1}{{N}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{1 + N}{N}\right)\\ \end{array}\]

Runtime

Time bar (total: 1.6m)Debug logProfile

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