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

    1. Initial program 0.1

      \[\log \left(N + 1\right) - \log N\]
    2. Using strategy rm
    3. Applied diff-log0.1

      \[\leadsto \color{blue}{\log \left(\frac{N + 1}{N}\right)}\]
    4. Taylor expanded around inf 0.1

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

    if 9043.685894874578 < N

    1. Initial program 59.5

      \[\log \left(N + 1\right) - \log N\]
    2. Using strategy rm
    3. Applied diff-log59.3

      \[\leadsto \color{blue}{\log \left(\frac{N + 1}{N}\right)}\]
    4. Taylor expanded around inf 59.3

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

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

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

Reproduce

herbie shell --seed 2019010 
(FPCore (N)
  :name "2log (problem 3.3.6)"
  (- (log (+ N 1)) (log N)))

Details

Time bar (total: 13.7s)Debug log

sample79.0ms

Algorithm
intervals

simplify5.0ms

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 25.5b

localize27.0ms

Local error

Found 2 expressions with local error:

2.8b
(- (log (+ N 1)) (log N))
2.7b
(log (+ N 1))

rewrite12.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
log-prod
add-sqr-sqrt
add-cube-cbrt
log-div
pow1
add-exp-log
associate--l+
add-log-exp
distribute-lft-out--
flip-+
log-pow
add-cbrt-cube
flip3-+
associate--l-
difference-of-squares
flip--
rem-log-exp
diff-log
flip3--
sub-neg
Counts
2 → 34
Calls
2 calls:
Slowest
10.0ms
(- (log (+ N 1)) (log N))
1.0ms
(log (+ N 1))

series126.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
88.0ms
(- (log (+ N 1)) (log N))
38.0ms
(log (+ N 1))

simplify960.0ms

Counts
22 → 40
Calls
22 calls:
Slowest
323.0ms
(- (+ (/ 1 N) (log -1)) (+ (* 1/2 (/ 1 (pow N 2))) (log (/ -1 N))))
169.0ms
(- (/ 1 N) (+ (* 1/2 (/ 1 (pow N 2))) (log (/ 1 N))))
130.0ms
(- (+ N (* 1/3 (pow N 3))) (* 1/2 (pow N 2)))
113.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
104.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))

prune364.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 2 expressions with local error:

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

rewrite6.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
add-cbrt-cube
flip-+
log-pow
rem-log-exp
flip3-+
frac-2neg
clear-num
log-div
Counts
2 → 29
Calls
2 calls:
Slowest
4.0ms
(/ (+ N 1) N)
2.0ms
(log (/ (+ N 1) N))

series73.0ms

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

simplify274.0ms

Counts
16 → 35
Calls
16 calls:
Slowest
96.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
86.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
53.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))
7.0ms
(- (* N N) (* 1 1))
5.0ms
(log (* (cbrt (/ (+ N 1) N)) (cbrt (/ (+ N 1) N))))

prune289.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize8.0ms

Local error

Found 1 expressions with local error:

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

rewrite2.0ms

Algorithm
rewrite-expression-head
Rules
log-prod
add-cube-cbrt
add-exp-log
*-un-lft-identity
log-div
pow1
add-sqr-sqrt
add-log-exp
flip-+
log-pow
rem-log-exp
add-cbrt-cube
flip3-+
Counts
1 → 14
Calls
1 calls:
Slowest
2.0ms
(log (+ (/ 1 N) 1))

series27.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
27.0ms
(log (+ (/ 1 N) 1))

simplify361.0ms

Counts
9 → 17
Calls
9 calls:
Slowest
134.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
109.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
47.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))
30.0ms
(log (+ (pow (/ 1 N) 3) (pow 1 3)))
30.0ms
(log (- (* (/ 1 N) (/ 1 N)) (* 1 1)))

prune162.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 4 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Rules
add-exp-log
pow1
add-log-exp
add-cube-cbrt
add-cbrt-cube
*-un-lft-identity
add-sqr-sqrt
flip--
frac-sub
flip3--
sub-neg
associate--r+
associate-*r/
associate-*l*
distribute-lft-in
frac-times
distribute-rgt-in
div-inv
associate-*r*
pow-flip
prod-exp
associate-*l/
frac-2neg
clear-num
rec-exp
inv-pow
cbrt-unprod
*-commutative
pow-prod-down
diff-log
associate-/r*
pow2
Counts
4 → 74
Calls
4 calls:
Slowest
8.0ms
(- (/ 1 N) (* (/ 1 (* N N)) (- 1/2 (/ 1/3 N))))
4.0ms
(* (/ 1 (* N N)) (- 1/2 (/ 1/3 N)))
1.0ms
(/ 1 (* N N))
0.0ms
(/ 1/3 N)

series70.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
39.0ms
(* (/ 1 (* N N)) (- 1/2 (/ 1/3 N)))
16.0ms
(- (/ 1 N) (* (/ 1 (* N N)) (- 1/2 (/ 1/3 N))))
8.0ms
(/ 1 (* N N))
7.0ms
(/ 1/3 N)

simplify6.8s

Counts
49 → 86
Calls
49 calls:
Slowest
522.0ms
(* (/ 1 (* N N)) (- (/ 1/3 N)))
487.0ms
(* (/ 1 (* N N)) (- (/ 1/3 N)))
454.0ms
(* (- (/ 1/3 N)) (/ 1 (* N N)))
407.0ms
(* (- (/ 1/3 N)) (/ 1 (* N N)))
384.0ms
(* (/ 1 (* N N)) (- (/ 1/3 N)))

prune662.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

regimes25.0ms

Accuracy

100% (0.0b remaining)

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

bsearch52.0ms

end0.0ms

sample3.3s

Algorithm
intervals