Average Error: 29.2 → 0.1
Time: 10.3s
Precision: 64
Internal Precision: 128
\[\log \left(N + 1\right) - \log N\]
\[\begin{array}{l} \mathbf{if}\;N \le 7836.516550508435:\\ \;\;\;\;\log \left(\left(1 + N\right) \cdot \frac{1}{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 < 7836.516550508435

    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)}\]
    6. Using strategy rm
    7. Applied div-inv0.1

      \[\leadsto \log \color{blue}{\left(\left(1 + N\right) \cdot \frac{1}{N}\right)}\]

    if 7836.516550508435 < 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. 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.1

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

Details

Time bar (total: 9.9s)Debug log

sample145.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.5b

localize9.0ms

Local error

Found 1 expressions with local error:

2.2b
(- (log1p N) (log N))

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
1 → 29
Calls

1 calls. Slowest were:

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

series63.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

63.0ms
(- (log1p N) (log N))

simplify763.0ms

Counts
28 → 32
Calls

28 calls. Slowest were:

239.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
164.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
104.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))

prune248.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.1b

localize30.0ms

Local error

Found 3 expressions with local error:

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

rewrite3.0ms

Algorithm
rewrite-expression-head
Counts
3 → 39
Calls

3 calls. Slowest were:

2.0ms
(/ 1 (* N N))
0.0ms
(/ 1/3 N)
0.0ms
(fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N))

series52.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

20.0ms
(fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N))
20.0ms
(/ 1 (* N N))
12.0ms
(/ 1/3 N)

simplify568.0ms

Counts
11 → 48
Calls

11 calls. Slowest were:

196.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
178.0ms
(- (+ (/ 1 N) (* 1/3 (/ 1 (pow N 3)))) (* 1/2 (/ 1 (pow N 2))))
158.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))

prune381.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

9.1b
(sqrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))
9.1b
(sqrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))
0.6b
(/ 1 (* N N))
0.6b
(/ 1 (* N N))

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

2.0ms
(sqrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))
2.0ms
(sqrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))
1.0ms
(/ 1 (* N N))

series90.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

32.0ms
(sqrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))
32.0ms
(sqrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))
13.0ms
(/ 1 (* N N))
13.0ms
(/ 1 (* N N))

simplify2.4s

Counts
24 → 74
Calls

24 calls. Slowest were:

495.0ms
(sqrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))
411.0ms
(sqrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))
400.0ms
(sqrt (* (cbrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N))) (cbrt (fma (/ 1 (* N N)) (- (/ 1/3 N) 1/2) (/ 1 N)))))

prune753.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize8.0ms

Local error

Found 2 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
2 → 33
Calls

2 calls. Slowest were:

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

series89.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

62.0ms
(log (/ (+ 1 N) N))
27.0ms
(/ (+ 1 N) N)

simplify471.0ms

Counts
16 → 39
Calls

16 calls. Slowest were:

204.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
154.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
75.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))

prune272.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

regimes38.0ms

Accuracy

100% (0.0b remaining)

Error of 0.1b against oracle of 0.1b and baseline of 31.1b

bsearch41.0ms

end0.0ms

sample3.4s

Algorithm
intervals