Average Error: 9.9 → 0.1
Time: 39.6s
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.9
Target0.2
Herbie0.1
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Initial program 9.9

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

    \[\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-add25.0

    \[\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 0 0.2

    \[\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 2019018 
(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: 39.3s)Debug log

sample87.0ms

Algorithm
intervals
Results
36.0ms72×body640valid
16.0ms124×body80valid
11.0ms17×body1280valid
9.0ms25×body320valid
5.0ms18×body160valid

simplify50.0ms

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

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 14.2b

localize34.0ms

Local error

Found 2 expressions with local error:

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

rewrite27.0ms

Algorithm
rewrite-expression-head
Rules
16×*-un-lft-identity
add-log-exp
distribute-lft-out--
distribute-lft-out
div-inv
add-sqr-sqrt
frac-add
flip--
add-cube-cbrt
frac-sub
add-exp-log
diff-log
add-cbrt-cube
flip3--
sub-neg
sum-log
associate-+l+
pow1
difference-of-squares
flip-+
associate-+l-
flip3-+
+-commutative
Counts
2 → 40
Calls
2 calls:
Slowest
21.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
5.0ms
(- (/ 1 (+ x 1)) (/ 2 x))

series61.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
50.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
11.0ms
(- (/ 1 (+ x 1)) (/ 2 x))

simplify2.9s

Counts
30 → 46
Calls
30 calls:
Slowest
471.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
380.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
289.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
241.0ms
(* (+ (* (/ 1 (+ x 1)) (/ 1 (+ x 1))) (+ (* (/ 2 x) (/ 2 x)) (* (/ 1 (+ x 1)) (/ 2 x)))) (- x 1))
230.0ms
(* (* (+ x 1) x) (- x 1))

prune407.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

localize5.0ms

Local error

Found 2 expressions with local error:

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

rewrite21.0ms

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

series67.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
57.0ms
(+ (* 1 (- (/ 1 (+ x 1)) (/ 2 x))) (/ 1 (- x 1)))
11.0ms
(- (/ 1 (+ x 1)) (/ 2 x))

simplify2.9s

Counts
26 → 42
Calls
26 calls:
Slowest
542.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
436.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
306.0ms
(+ (* (* 1 (- (* 1 x) (* (+ x 1) 2))) (- x 1)) (* (* (+ x 1) x) 1))
258.0ms
(+ (* (* 1 (- (* (/ 1 (+ x 1)) (/ 1 (+ x 1))) (* (/ 2 x) (/ 2 x)))) (- x 1)) (* (+ (/ 1 (+ x 1)) (/ 2 x)) 1))
212.0ms
(* (* (+ x 1) x) (- x 1))

prune356.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize37.0ms

Local error

Found 4 expressions with local error:

14.7b
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
0.1b
(* (* (+ x 1) x) (- x 1))
0.0b
(* (- (* 1 x) (* (+ x 1) 2)) (- x 1))
0.0b
(/ (+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1)) (* (* (+ x 1) x) (- x 1)))

rewrite104.0ms

Algorithm
rewrite-expression-head
Rules
90×associate-*l/
36×flip--
36×flip3--
32×frac-add
28×frac-times
24×flip-+
24×flip3-+
18×associate-/l/
14×associate-*r/
13×add-exp-log
13×add-cbrt-cube
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
associate-/r/
pow1
add-log-exp
associate-*r*
distribute-lft-in
sub-neg
distribute-rgt-in
associate-*l*
associate-+l+
associate-/l*
cbrt-unprod
prod-exp
times-frac
*-commutative
pow-prod-down
div-exp
cbrt-undiv
div-inv
frac-2neg
sum-log
associate-/r*
clear-num
+-commutative
Counts
4 → 134
Calls
4 calls:
Slowest
56.0ms
(/ (+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1)) (* (* (+ x 1) x) (- x 1)))
16.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
14.0ms
(* (* (+ x 1) x) (- x 1))
12.0ms
(* (- (* 1 x) (* (+ x 1) 2)) (- x 1))

series126.0ms

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

simplify26.0s

Counts
135 → 146
Calls
135 calls:
Slowest
911.0ms
(+ (* (* (- (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)))
723.0ms
(+ (* (* (- (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)))
687.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)))
678.0ms
(* (+ (* 1 x) (* (+ x 1) 2)) (+ (* x x) (+ (* 1 1) (* x 1))))
606.0ms
(* (* (- (* x x) (* 1 1)) x) (- x 1))

prune1.2s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize3.0ms

Local error

Found 2 expressions with local error:

0.3b
(/ 2 (* (* (+ x 1) x) (- x 1)))
0.1b
(* (* (+ x 1) x) (- x 1))

rewrite11.0ms

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

series58.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
36.0ms
(* (* (+ x 1) x) (- x 1))
22.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))

simplify3.0s

Counts
38 → 52
Calls
38 calls:
Slowest
316.0ms
(* (* (- (* x x) (* 1 1)) x) (- (pow x 3) (pow 1 3)))
264.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
226.0ms
(* (* (- (* x x) (* 1 1)) x) (- x 1))
206.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (* x x) (* 1 1)))
181.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (pow x 3) (pow 1 3)))

prune259.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

regimes21.0ms

Accuracy

0% (0.1b remaining)

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

bsearch1.0ms

end0.0ms

sample1.7s

Algorithm
intervals
Results
560.0ms1848×body640valid
346.0ms4196×body80valid
219.0ms941×body320valid
211.0ms531×body1280valid
61.0ms488×body160valid