Average Error: 9.7 → 0.1
Time: 44.0s
Precision: 64
Internal Precision: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.7
Target0.3
Herbie0.1
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Initial program 9.7

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
  2. Using strategy rm
  3. Applied frac-sub25.3

    \[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 2}{\left(x + 1\right) \cdot x}} + \frac{1}{x - 1}\]
  4. Applied frac-add24.7

    \[\leadsto \color{blue}{\frac{\left(1 \cdot x - \left(x + 1\right) \cdot 2\right) \cdot \left(x - 1\right) + \left(\left(x + 1\right) \cdot x\right) \cdot 1}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}}\]
  5. Taylor expanded around inf 0.3

    \[\leadsto \frac{\color{blue}{2}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
  6. Using strategy rm
  7. Applied associate-/r*0.1

    \[\leadsto \color{blue}{\frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}}\]
  8. Final simplification0.1

    \[\leadsto \frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}\]

Reproduce

herbie shell --seed 2019010 
(FPCore (x)
  :name "3frac (problem 3.3.3)"

  :herbie-target
  (/ 2 (* x (- (* x x) 1)))

  (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))

Details

Time bar (total: 43.2s)Debug log

sample100.0ms

Algorithm
intervals

simplify81.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
80.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 10.0b

localize39.0ms

Local error

Found 4 expressions with local error:

2.6b
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
0.0b
(/ 1 (- x 1))
0.0b
(/ 1 (+ x 1))
0.0b
(- (/ 1 (+ x 1)) (/ 2 x))

rewrite61.0ms

Algorithm
rewrite-expression-head
Rules
20×*-un-lft-identity
11×add-log-exp
div-inv
add-sqr-sqrt
distribute-lft-out--
distribute-lft-out
add-cube-cbrt
add-exp-log
associate-/r*
pow1
associate-/r/
add-cbrt-cube
flip--
frac-add
flip3--
inv-pow
pow-flip
flip-+
frac-sub
diff-log
flip3-+
frac-2neg
sub-neg
sum-log
clear-num
associate-+l+
rec-exp
difference-of-squares
associate-+l-
+-commutative
Counts
4 → 76
Calls
4 calls:
Slowest
41.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
15.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
2.0ms
(/ 1 (- x 1))
2.0ms
(/ 1 (+ x 1))

series100.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
61.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
17.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
11.0ms
(/ 1 (+ x 1))
11.0ms
(/ 1 (- x 1))

simplify3.5s

Counts
48 → 88
Calls
48 calls:
Slowest
533.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
436.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
365.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
274.0ms
(* (* (+ x 1) x) (- x 1))
253.0ms
(+ (* (- (* (/ 1 (+ x 1)) (/ 1 (+ x 1))) (* (/ 2 x) (/ 2 x))) (- x 1)) (* (+ (/ 1 (+ x 1)) (/ 2 x)) 1))

prune766.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 4 expressions with local error:

2.6b
(+ (* 1 (- (/ 1 (+ x 1)) (/ 2 x))) (/ 1 (- x 1)))
0.0b
(/ 1 (- x 1))
0.0b
(/ 1 (+ x 1))
0.0b
(- (/ 1 (+ x 1)) (/ 2 x))

rewrite28.0ms

Algorithm
rewrite-expression-head
Rules
10×*-un-lft-identity
add-log-exp
add-sqr-sqrt
add-cube-cbrt
add-exp-log
associate-/r*
pow1
div-inv
associate-/r/
add-cbrt-cube
associate-+l+
flip--
associate-*r/
frac-add
flip3--
sub-neg
inv-pow
distribute-lft-out--
distribute-lft-out
pow-flip
flip-+
frac-sub
flip3-+
distribute-lft-in
frac-2neg
clear-num
rec-exp
distribute-rgt-in
difference-of-squares
diff-log
sum-log
+-commutative
Counts
4 → 72
Calls
4 calls:
Slowest
14.0ms
(+ (* 1 (- (/ 1 (+ x 1)) (/ 2 x))) (/ 1 (- x 1)))
10.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
2.0ms
(/ 1 (- x 1))
2.0ms
(/ 1 (+ x 1))

series103.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
63.0ms
(+ (* 1 (- (/ 1 (+ x 1)) (/ 2 x))) (/ 1 (- x 1)))
18.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
11.0ms
(/ 1 (- x 1))
11.0ms
(/ 1 (+ x 1))

simplify3.1s

Counts
44 → 84
Calls
44 calls:
Slowest
406.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
345.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
321.0ms
(+ (* (* 1 (- (* 1 x) (* (+ x 1) 2))) (- x 1)) (* (* (+ x 1) x) 1))
295.0ms
(+ (* (* 1 (- (* (/ 1 (+ x 1)) (/ 1 (+ x 1))) (* (/ 2 x) (/ 2 x)))) (- x 1)) (* (+ (/ 1 (+ x 1)) (/ 2 x)) 1))
279.0ms
(* (* (+ x 1) x) (- x 1))

prune658.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize33.0ms

Local error

Found 4 expressions with local error:

14.3b
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
0.0b
(* (* (+ x 1) x) (- x 1))
0.0b
(- (* 1 x) (* (+ x 1) 2))
0.0b
(/ (+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1)) (* (* (+ x 1) x) (- x 1)))

rewrite51.0ms

Algorithm
rewrite-expression-head
Rules
88×associate-*l/
32×frac-add
31×flip--
31×flip3--
24×flip-+
24×flip3-+
24×frac-times
18×associate-/l/
12×associate-*r/
11×add-exp-log
11×add-cbrt-cube
add-log-exp
associate-/r/
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
pow1
sub-neg
distribute-lft-in
associate-+l+
distribute-rgt-in
associate-/l*
associate-*r*
times-frac
cbrt-unprod
prod-exp
div-exp
cbrt-undiv
div-inv
*-commutative
pow-prod-down
associate-*l*
diff-log
frac-2neg
sum-log
associate-/r*
clear-num
+-commutative
Counts
4 → 117
Calls
4 calls:
Slowest
31.0ms
(/ (+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1)) (* (* (+ x 1) x) (- x 1)))
8.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
7.0ms
(* (* (+ x 1) x) (- x 1))
2.0ms
(- (* 1 x) (* (+ x 1) 2))

series78.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
36.0ms
(* (* (+ x 1) x) (- x 1))
29.0ms
(/ (+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1)) (* (* (+ x 1) x) (- x 1)))
11.0ms
(- (* 1 x) (* (+ x 1) 2))
2.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))

simplify24.8s

Counts
112 → 129
Calls
112 calls:
Slowest
1.1s
(+ (* (* (- (pow (* 1 x) 3) (pow (* (+ x 1) 2) 3)) (- (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (* (+ (* (* 1 x) (* 1 x)) (+ (* (* (+ x 1) 2) (* (+ x 1) 2)) (* (* 1 x) (* (+ x 1) 2)))) (+ (* x x) (+ (* 1 1) (* x 1)))) (* (* (+ (pow x 3) (pow 1 3)) x) 1)))
1.0s
(+ (* (* (- (pow (* 1 x) 3) (pow (* (+ x 1) 2) 3)) (- (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (* (+ (* (* 1 x) (* 1 x)) (+ (* (* (+ x 1) 2) (* (+ x 1) 2)) (* (* 1 x) (* (+ x 1) 2)))) (+ (* x x) (+ (* 1 1) (* x 1)))) (* (* (+ (pow x 3) (pow 1 3)) x) 1)))
874.0ms
(+ (* (* (- (pow (* 1 x) 3) (pow (* (+ x 1) 2) 3)) (- (pow x 3) (pow 1 3))) (- x 1)) (* (* (+ (* (* 1 x) (* 1 x)) (+ (* (* (+ x 1) 2) (* (+ x 1) 2)) (* (* 1 x) (* (+ x 1) 2)))) (+ (* x x) (+ (* 1 1) (* x 1)))) (* (* (- (* x x) (* 1 1)) x) 1)))
750.0ms
(+ (* (* (- (pow (* 1 x) 3) (pow (* (+ x 1) 2) 3)) (- (pow x 3) (pow 1 3))) (- x 1)) (* (* (+ (* (* 1 x) (* 1 x)) (+ (* (* (+ x 1) 2) (* (+ x 1) 2)) (* (* 1 x) (* (+ x 1) 2)))) (+ (* x x) (+ (* 1 1) (* x 1)))) (* (* (- (* x x) (* 1 1)) x) 1)))
684.0ms
(+ (pow (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) 3) (pow (* (* (+ x 1) x) 1) 3))

prune1.6s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize7.0ms

Local error

Found 3 expressions with local error:

0.2b
(/ 2 (* (* (+ x 1) x) (- x 1)))
0.0b
(* (* (+ x 1) x) (- x 1))
0.0b
(* (+ x 1) x)

rewrite16.0ms

Algorithm
rewrite-expression-head
Rules
18×associate-*l/
associate-/r/
frac-times
flip-+
flip3-+
flip--
flip3--
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
associate-*r/
associate-*l*
add-log-exp
associate-*r*
*-commutative
distribute-lft-in
sub-neg
distribute-rgt-in
div-inv
cbrt-unprod
prod-exp
pow-prod-down
frac-2neg
associate-/r*
clear-num
Counts
3 → 59
Calls
3 calls:
Slowest
9.0ms
(* (* (+ x 1) x) (- x 1))
3.0ms
(* (+ x 1) x)
3.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))

series95.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
52.0ms
(* (* (+ x 1) x) (- x 1))
24.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
19.0ms
(* (+ x 1) x)

simplify4.9s

Counts
45 → 68
Calls
45 calls:
Slowest
541.0ms
(* (+ (* x x) (- (* 1 1) (* x 1))) (+ (* x x) (+ (* 1 1) (* x 1))))
496.0ms
(* (* (- (* x x) (* 1 1)) x) (- (pow x 3) (pow 1 3)))
423.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
348.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (* x x) (* 1 1)))
297.0ms
(* (* (+ x 1) x) (- x 1))

prune495.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

regimes38.0ms

Accuracy

0% (0.0b remaining)

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

bsearch2.0ms

end0.0ms

sample2.5s

Algorithm
intervals