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

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

    if 11887.051868903589 < N

    1. Initial program 59.6

      \[\log \left(N + 1\right) - \log N\]
    2. 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}}}\]
    3. 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 11887.051868903589:\\ \;\;\;\;\log \left(\frac{1 + N}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{N} - \frac{1}{N \cdot N} \cdot \left(\frac{1}{2} - \frac{\frac{1}{3}}{N}\right)\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 15.4s)Debug log

sample79.0ms

Algorithm
intervals
Results
25.0ms51×body1280valid
14.0ms270×body80nan
14.0ms43×body640valid
10.0ms126×body80valid
5.0ms22×body320valid
2.0ms14×body160valid

simplify4.0ms

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.2b

localize23.0ms

Local error

Found 2 expressions with local error:

3.9b
(- (log (+ N 1)) (log N))
2.6b
(log (+ N 1))

rewrite33.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
30.0ms
(- (log (+ N 1)) (log N))
2.0ms
(log (+ N 1))

series89.0ms

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

simplify821.0ms

Counts
22 → 40
Calls
22 calls:
Slowest
251.0ms
(- (+ (/ 1 N) (log -1)) (+ (* 1/2 (/ 1 (pow N 2))) (log (/ -1 N))))
146.0ms
(- (/ 1 N) (+ (* 1/2 (/ 1 (pow N 2))) (log (/ 1 N))))
104.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
102.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
101.0ms
(- (+ N (* 1/3 (pow N 3))) (* 1/2 (pow N 2)))

prune282.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.1b

localize35.0ms

Local error

Found 4 expressions with local error:

0.5b
(/ 1 (* N N))
0.4b
(/ 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))))

rewrite22.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
10.0ms
(- (/ 1 N) (* (/ 1 (* N N)) (- 1/2 (/ 1/3 N))))
9.0ms
(* (/ 1 (* N N)) (- 1/2 (/ 1/3 N)))
1.0ms
(/ 1 (* N N))
0.0ms
(/ 1/3 N)

series83.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
43.0ms
(* (/ 1 (* N N)) (- 1/2 (/ 1/3 N)))
16.0ms
(- (/ 1 N) (* (/ 1 (* N N)) (- 1/2 (/ 1/3 N))))
13.0ms
(/ 1 (* N N))
12.0ms
(/ 1/3 N)

simplify7.0s

Counts
49 → 86
Calls
49 calls:
Slowest
551.0ms
(* (/ 1 (* N N)) (- (/ 1/3 N)))
449.0ms
(* (/ 1 (* N N)) (- (/ 1/3 N)))
446.0ms
(* (/ 1 (* N N)) (- (/ 1/3 N)))
423.0ms
(* (- (/ 1/3 N)) (/ 1 (* N N)))
416.0ms
(* (- (/ 1/3 N)) (/ 1 (* N N)))

prune668.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.1b

localize53.0ms

Local error

Found 4 expressions with local error:

0.5b
(- (+ (/ 1/3 N) 1/2) (/ 1/4 N))
0.4b
(/ 1/3 N)
0.3b
(/ -1/9 N)
0.2b
(* (/ -1/9 N) (/ 1 N))

rewrite35.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
add-sqr-sqrt
add-log-exp
add-cube-cbrt
add-exp-log
add-cbrt-cube
pow1
div-inv
associate-*l*
associate-*r*
frac-sub
frac-2neg
clear-num
difference-of-squares
distribute-lft-out--
flip--
flip-+
cbrt-unprod
*-commutative
un-div-inv
associate-*r/
associate--l+
prod-exp
associate-*l/
pow-prod-down
diff-log
flip3--
flip3-+
sub-neg
frac-times
Counts
4 → 60
Calls
4 calls:
Slowest
28.0ms
(- (+ (/ 1/3 N) 1/2) (/ 1/4 N))
6.0ms
(* (/ -1/9 N) (/ 1 N))
0.0ms
(/ 1/3 N)
0.0ms
(/ -1/9 N)

series67.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
24.0ms
(- (+ (/ 1/3 N) 1/2) (/ 1/4 N))
19.0ms
(* (/ -1/9 N) (/ 1 N))
12.0ms
(/ 1/3 N)
12.0ms
(/ -1/9 N)

simplify1.4s

Counts
33 → 72
Calls
33 calls:
Slowest
434.0ms
(* (* (* (/ -1/9 N) (/ -1/9 N)) (/ -1/9 N)) (* (* (/ 1 N) (/ 1 N)) (/ 1 N)))
371.0ms
(* (+ (* (/ 1/3 N) (/ 1/3 N)) (- (* 1/2 1/2) (* (/ 1/3 N) 1/2))) N)
171.0ms
(- (* (+ (pow (/ 1/3 N) 3) (pow 1/2 3)) N) (* (+ (* (/ 1/3 N) (/ 1/3 N)) (- (* 1/2 1/2) (* (/ 1/3 N) 1/2))) 1/4))
107.0ms
(- (* (- (* (/ 1/3 N) (/ 1/3 N)) (* 1/2 1/2)) N) (* (- (/ 1/3 N) 1/2) 1/4))
79.0ms
(/ (exp (+ (/ 1/3 N) 1/2)) (exp (/ 1/4 N)))

prune707.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.1b

localize5.0ms

Local error

Found 2 expressions with local error:

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

rewrite5.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
3.0ms
(/ (+ N 1) N)
1.0ms
(log (/ (+ N 1) N))

series72.0ms

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

simplify364.0ms

Counts
16 → 35
Calls
16 calls:
Slowest
131.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
113.0ms
(- (+ (* 1/3 (/ 1 (pow N 3))) (/ 1 N)) (* 1/2 (/ 1 (pow N 2))))
57.0ms
(- N (+ (log N) (* 1/2 (pow N 2))))
14.0ms
(- (* N N) (* 1 1))
7.0ms
(+ (pow N 3) (pow 1 3))

prune237.0ms

Pruning

6 alts after pruning (3 fresh and 3 done)

Merged error: 0.1b

regimes74.0ms

Accuracy

99.9% (0.0b remaining)

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

bsearch34.0ms

end0.0ms

sample3.2s

Algorithm
intervals
Results
972.0ms1755×body1280valid
816.0ms4059×body80valid
628.0ms8004×body80nan
399.0ms1213×body640valid
190.0ms648×body320valid
47.0ms325×body160valid