Average Error: 29.2 → 0.1
Time: 14.7s
Precision: 64
Internal Precision: 128
\[\log \left(N + 1\right) - \log N\]
\[\begin{array}{l} \mathbf{if}\;N \le 8308.083087599556:\\ \;\;\;\;\log \left(\frac{1 + N}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{1}{N \cdot N}\right) \cdot \left(\frac{\frac{1}{3}}{N} - \frac{1}{2}\right) + \left(\frac{1}{N}\right))_*\\ \end{array}\]

Error

Bits error versus N

Derivation

  1. Split input into 2 regimes
  2. if N < 8308.083087599556

    1. Initial program 0.1

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

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

      \[\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)}\]

    if 8308.083087599556 < N

    1. Initial program 59.4

      \[\log \left(N + 1\right) - \log N\]
    2. Simplified59.4

      \[\leadsto \color{blue}{\log_* (1 + N) - \log N}\]
    3. Using strategy rm
    4. Applied log1p-udef59.4

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

      \[\leadsto \color{blue}{\log \left(\frac{1 + N}{N}\right)}\]
    6. 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}}}\]
    7. Simplified0.0

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

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

Reproduce

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

Details

Time bar (total: 14.1s)Debug log

sample138.0ms

Algorithm
intervals
Results
573×(pre true 80)
316×(body nan 80)
137×(body real 80)
60×(body real 1280)
39×(body real 640)
13×(body real 320)
(body real 160)

simplify8.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
8.0ms
(- (log (+ N 1)) (log N))

prune14.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.1b

localize18.0ms

Local error

Found 1 expressions with local error:

2.5b
(- (log1p N) (log N))

rewrite9.0ms

Algorithm
rewrite-expression-head
Rules
10×*-un-lft-identity
10×add-sqr-sqrt
prod-diff
add-cube-cbrt
fma-neg
add-log-exp
diff-log
difference-of-squares
distribute-lft-out--
flip--
log1p-expm1-u
add-exp-log
add-cbrt-cube
flip3--
sub-neg
log1p-udef
pow1
expm1-log1p-u
Counts
1 → 29
Calls
1 calls:
Slowest
8.0ms
(- (log1p N) (log N))

series73.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
73.0ms
(- (log1p N) (log N))

simplify815.0ms

Counts
28 → 32
Calls
28 calls:
Slowest
172.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
170.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
89.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))
37.0ms
(fma 1 (log1p N) (- (* (log N) 1)))
32.0ms
(fma (sqrt (log1p N)) (sqrt (log1p N)) (- (* (sqrt (log N)) (sqrt (log N)))))

prune311.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 2 expressions with local error:

2.3b
(log (/ (+ 1 N) N))
0.0b
(/ (+ 1 N) N)

rewrite8.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
*-un-lft-identity
log-prod
add-sqr-sqrt
associate-/l*
add-exp-log
pow1
associate-/l/
add-log-exp
div-inv
log1p-expm1-u
add-cbrt-cube
expm1-log1p-u
flip-+
log-pow
rem-log-exp
flip3-+
frac-2neg
clear-num
log-div
Counts
2 → 33
Calls
2 calls:
Slowest
5.0ms
(/ (+ 1 N) N)
2.0ms
(log (/ (+ 1 N) N))

series59.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
40.0ms
(log (/ (+ 1 N) N))
19.0ms
(/ (+ 1 N) N)

simplify530.0ms

Counts
16 → 39
Calls
16 calls:
Slowest
202.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
196.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
96.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))
6.0ms
(- (* 1 1) (* N N))
5.0ms
(+ (pow 1 3) (pow N 3))

prune260.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize31.0ms

Local error

Found 4 expressions with local error:

2.4b
(log (cbrt (/ (+ 1 N) N)))
2.3b
(log (* (cbrt (/ (+ 1 N) N)) (cbrt (/ (+ 1 N) N))))
0.3b
(cbrt (/ (+ 1 N) N))
0.3b
(cbrt (/ (+ 1 N) N))

rewrite17.0ms

Algorithm
rewrite-expression-head
Rules
12×cbrt-prod
11×pow1
log-pow
add-cube-cbrt
add-exp-log
*-un-lft-identity
log-prod
add-sqr-sqrt
pow1/3
cbrt-div
add-log-exp
log1p-expm1-u
add-cbrt-cube
log-div
expm1-log1p-u
div-inv
rem-log-exp
pow-prod-up
pow-prod-down
associate-*r/
prod-exp
associate-*l/
pow-plus
frac-times
pow2
Counts
4 → 72
Calls
4 calls:
Slowest
10.0ms
(log (* (cbrt (/ (+ 1 N) N)) (cbrt (/ (+ 1 N) N))))
3.0ms
(log (cbrt (/ (+ 1 N) N)))
1.0ms
(cbrt (/ (+ 1 N) N))
1.0ms
(cbrt (/ (+ 1 N) N))

series298.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
99.0ms
(log (cbrt (/ (+ 1 N) N)))
80.0ms
(log (* (cbrt (/ (+ 1 N) N)) (cbrt (/ (+ 1 N) N))))
59.0ms
(cbrt (/ (+ 1 N) N))
59.0ms
(cbrt (/ (+ 1 N) N))

simplify2.0s

Counts
40 → 84
Calls
40 calls:
Slowest
341.0ms
(- (+ (log (* (cbrt -1) (pow -1 1/3))) (* 1/3 (/ 1 N))) (* 1/6 (/ 1 (pow N 2))))
229.0ms
(- (+ (* (cbrt -1) (pow -1 1/3)) (* 1/3 (* (/ (cbrt -1) N) (pow -1 1/3)))) (* 1/9 (* (/ (cbrt -1) (pow N 2)) (pow -1 1/3))))
219.0ms
(- (+ (* 1/9 (/ 1 (pow N 3))) (* 1/3 (/ 1 N))) (* 1/6 (/ 1 (pow N 2))))
207.0ms
(- (+ (* 2/9 (/ 1 (pow N 3))) (* 2/3 (/ 1 N))) (* 1/3 (/ 1 (pow N 2))))
203.0ms
(- (+ (* 2/3 (/ 1 N)) (log (pow (cbrt -1) 2))) (* 1/3 (/ 1 (pow N 2))))

prune634.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 4 expressions with local error:

28.2b
(fma (* (cbrt (log1p N)) (cbrt (log1p N))) (cbrt (log1p N)) (- (log N)))
0.5b
(cbrt (log1p N))
0.5b
(cbrt (log1p N))
0.5b
(cbrt (log1p N))

rewrite4.0ms

Algorithm
rewrite-expression-head
Rules
cbrt-prod
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
pow1/3
fma-udef
Counts
4 → 49
Calls
4 calls:
Slowest
1.0ms
(cbrt (log1p N))
1.0ms
(cbrt (log1p N))
1.0ms
(cbrt (log1p N))
0.0ms
(fma (* (cbrt (log1p N)) (cbrt (log1p N))) (cbrt (log1p N)) (- (log N)))

series471.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
322.0ms
(fma (* (cbrt (log1p N)) (cbrt (log1p N))) (cbrt (log1p N)) (- (log N)))
57.0ms
(cbrt (log1p N))
46.0ms
(cbrt (log1p N))
46.0ms
(cbrt (log1p N))

simplify3.9s

Counts
21 → 61
Calls
21 calls:
Slowest
618.0ms
(- (+ (pow (- (log -1) (log (/ -1 N))) 1/3) (* 1/3 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 2)) 1/3) (/ 1 N)))) (+ (* 1/9 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 5)) 1/3) (/ 1 (pow N 2)))) (* 1/6 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 2)) 1/3) (/ 1 (pow N 2))))))
550.0ms
(- (+ (pow (- (log -1) (log (/ -1 N))) 1/3) (* 1/3 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 2)) 1/3) (/ 1 N)))) (+ (* 1/9 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 5)) 1/3) (/ 1 (pow N 2)))) (* 1/6 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 2)) 1/3) (/ 1 (pow N 2))))))
529.0ms
(- (+ (pow (- (log -1) (log (/ -1 N))) 1/3) (* 1/3 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 2)) 1/3) (/ 1 N)))) (+ (* 1/9 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 5)) 1/3) (/ 1 (pow N 2)))) (* 1/6 (* (pow (/ 1 (pow (- (log -1) (log (/ -1 N))) 2)) 1/3) (/ 1 (pow N 2))))))
434.0ms
(- (+ (pow (- (log (/ 1 N))) 1/3) (* 1/6 (* (pow (/ -1 (pow (log (/ 1 N)) 2)) 1/3) (/ 1 (pow N 2))))) (+ (* 1/9 (* (pow (/ -1 (pow (log (/ 1 N)) 5)) 1/3) (/ 1 (pow N 2)))) (* 1/3 (* (pow (/ -1 (pow (log (/ 1 N)) 2)) 1/3) (/ 1 N)))))
425.0ms
(- (+ (pow (- (log (/ 1 N))) 1/3) (* 1/6 (* (pow (/ -1 (pow (log (/ 1 N)) 2)) 1/3) (/ 1 (pow N 2))))) (+ (* 1/9 (* (pow (/ -1 (pow (log (/ 1 N)) 5)) 1/3) (/ 1 (pow N 2)))) (* 1/3 (* (pow (/ -1 (pow (log (/ 1 N)) 2)) 1/3) (/ 1 N)))))

prune814.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

regimes60.0ms

Accuracy

100% (0.0b remaining)

Error of 0.1b against oracle of 0.0b and baseline of 29.1b

bsearch37.0ms

end0.0ms

sample3.7s

Algorithm
intervals
Results
16094×(pre true 80)
8093×(body nan 80)
4114×(body real 80)
1765×(body real 1280)
1214×(body real 640)
612×(body real 320)
296×(body real 160)