Average Error: 29.3 → 0.0
Time: 10.8s
Precision: 64
Internal Precision: 128
\[\log \left(N + 1\right) - \log N\]
\[\begin{array}{l} \mathbf{if}\;N \le 9955.673000070075:\\ \;\;\;\;\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 < 9955.673000070075

    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 9955.673000070075 < N

    1. Initial program 59.5

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

      \[\leadsto \color{blue}{\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}}}\]
    4. 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.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;N \le 9955.673000070075:\\ \;\;\;\;\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 2019007 +o rules:numerics
(FPCore (N)
  :name "2log (problem 3.3.6)"
  (- (log (+ N 1)) (log N)))

Details

Time bar (total: 10.0s)Debug log

sample125.0ms

Algorithm
intervals

simplify6.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

6.0ms
(- (log (+ N 1)) (log N))

prune19.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.0b

localize10.0ms

Local error

Found 1 expressions with local error:

2.9b
(- (log1p N) (log N))

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
1 → 29
Calls

1 calls. Slowest were:

4.0ms
(- (log1p N) (log N))

series87.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

87.0ms
(- (log1p N) (log N))

simplify1.1s

Counts
28 → 32
Calls

28 calls. Slowest were:

564.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
156.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
73.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))

prune196.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize26.0ms

Local error

Found 4 expressions with local error:

0.4b
(/ 1 (* N N))
0.4b
(/ 1/3 N)
0.0b
(fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N))
0.0b
(- (/ 1/3 N) 1/2)

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

3.0ms
(- (/ 1/3 N) 1/2)
1.0ms
(/ 1 (* N N))
0.0ms
(/ 1/3 N)

series47.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

15.0ms
(fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N))
15.0ms
(- (/ 1/3 N) 1/2)
8.0ms
(/ 1 (* N N))
8.0ms
(/ 1/3 N)

simplify616.0ms

Counts
16 → 68
Calls

16 calls. Slowest were:

236.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
185.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
126.0ms
(- (+ (/ 1 N) (* 1/3 (/ 1 (pow N 3)))) (* 1/2 (/ 1 (pow N 2))))

prune568.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize8.0ms

Local error

Found 2 expressions with local error:

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

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 33
Calls

2 calls. Slowest were:

2.0ms
(/ (+ 1 N) N)
1.0ms
(log (/ (+ 1 N) N))

series69.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

38.0ms
(log (/ (+ 1 N) N))
31.0ms
(/ (+ 1 N) N)

simplify507.0ms

Counts
16 → 39
Calls

16 calls. Slowest were:

226.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
149.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
71.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))

prune254.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize20.0ms

Local error

Found 4 expressions with local error:

3.3b
(log (/ (+ 1 N) N))
3.3b
(log (/ (+ 1 N) N))
3.3b
(log (/ (+ 1 N) N))
0.3b
(* (cbrt (log (/ (+ 1 N) N))) (cbrt (log (/ (+ 1 N) N))))

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
4 → 80
Calls

4 calls. Slowest were:

12.0ms
(* (cbrt (log (/ (+ 1 N) N))) (cbrt (log (/ (+ 1 N) N))))
2.0ms
(log (/ (+ 1 N) N))
2.0ms
(log (/ (+ 1 N) N))

series225.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

64.0ms
(log (/ (+ 1 N) N))
61.0ms
(* (cbrt (log (/ (+ 1 N) N))) (cbrt (log (/ (+ 1 N) N))))
59.0ms
(log (/ (+ 1 N) N))
40.0ms
(log (/ (+ 1 N) N))

simplify2.2s

Counts
52 → 92
Calls

52 calls. Slowest were:

235.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
224.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
205.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))

prune831.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

regimes62.0ms

Accuracy

100% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 31.0b

bsearch41.0ms

end0.0ms

sample3.0s

Algorithm
intervals