Average Error: 9.9 → 0.1
Time: 54.3s
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.3
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 *-un-lft-identity9.9

    \[\leadsto \color{blue}{1 \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right)} + \frac{1}{x - 1}\]
  4. Using strategy rm
  5. Applied frac-sub25.6

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

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

    \[\leadsto \color{blue}{\frac{\left(1 \cdot \left(1 \cdot x - \left(x + 1\right) \cdot 2\right)\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)}}\]
  8. Simplified24.9

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

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

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

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

Reproduce

herbie shell --seed 2019021 
(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: 53.9s)Debug log

sample63.0ms

Algorithm
intervals
Results
23.0ms65×body640valid
12.0ms134×body80valid
10.0ms19×body1280valid
8.0ms31×body320valid
1.0msbody160valid

simplify60.0ms

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

prune25.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 8.9b

localize21.0ms

Local error

Found 4 expressions with local error:

1.7b
(+ (- (/ 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))

rewrite40.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
27.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
9.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
66.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
16.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
11.0ms
(/ 1 (- x 1))
10.0ms
(/ 1 (+ x 1))

simplify3.1s

Counts
48 → 88
Calls
48 calls:
Slowest
443.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
324.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
283.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
272.0ms
(* (* (+ x 1) x) (- x 1))
243.0ms
(* (+ (* (/ 1 (+ x 1)) (/ 1 (+ x 1))) (+ (* (/ 2 x) (/ 2 x)) (* (/ 1 (+ x 1)) (/ 2 x)))) (- x 1))

prune674.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

localize10.0ms

Local error

Found 4 expressions with local error:

1.7b
(+ (* 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))

rewrite16.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
7.0ms
(+ (* 1 (- (/ 1 (+ x 1)) (/ 2 x))) (/ 1 (- x 1)))
5.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
3.0ms
(/ 1 (- x 1))
1.0ms
(/ 1 (+ x 1))

series99.0ms

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

simplify3.2s

Counts
44 → 84
Calls
44 calls:
Slowest
473.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
374.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
286.0ms
(+ (* (* 1 (- (* (/ 1 (+ x 1)) (/ 1 (+ x 1))) (* (/ 2 x) (/ 2 x)))) (- x 1)) (* (+ (/ 1 (+ x 1)) (/ 2 x)) 1))
280.0ms
(* (* (+ x 1) x) (- x 1))
243.0ms
(+ (* (* 1 (- (* 1 x) (* (+ x 1) 2))) (- x 1)) (* (* (+ x 1) x) 1))

prune705.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize30.0ms

Local error

Found 4 expressions with local error:

16.5b
(+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2))
3.6b
(+ (+ x 1) (+ x -1))
0.0b
(* (* (+ x 1) x) (- x 1))
0.0b
(* (+ x -1) (- -1 x))

rewrite34.0ms

Algorithm
rewrite-expression-head
Rules
84×frac-add
70×flip-+
70×associate-*l/
70×flip3-+
64×associate-*r/
32×frac-times
24×flip--
24×flip3--
*-un-lft-identity
add-log-exp
add-exp-log
add-cbrt-cube
pow1
add-cube-cbrt
add-sqr-sqrt
associate-*r*
distribute-lft-in
distribute-rgt-in
associate-*l*
sub-neg
associate-+l+
cbrt-unprod
*-commutative
prod-exp
pow-prod-down
sum-log
+-commutative
distribute-lft-out
associate-+r+
Counts
4 → 135
Calls
4 calls:
Slowest
9.0ms
(+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2))
8.0ms
(* (+ x -1) (- -1 x))
8.0ms
(* (* (+ x 1) x) (- x 1))
3.0ms
(+ (+ x 1) (+ x -1))

series134.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
62.0ms
(* (* (+ x 1) x) (- x 1))
51.0ms
(* (+ x -1) (- -1 x))
17.0ms
(+ (+ x 1) (+ x -1))
3.0ms
(+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2))

simplify39.6s

Counts
168 → 147
Calls
168 calls:
Slowest
1.8s
(+ (* (* x (+ (* (- (* x x) (* 1 1)) (- x -1)) (* (- x 1) (- (* x x) (* -1 -1))))) (+ -1 x)) (* (* (- x 1) (- x -1)) (* (* (+ x -1) (- (* -1 -1) (* x x))) 2)))
1.4s
(* (+ (* (+ x 1) (+ x 1)) (- (* (+ x -1) (+ x -1)) (* (+ x 1) (+ x -1)))) (- x -1))
1.3s
(+ (* (* x (+ (* (+ (pow x 3) (pow 1 3)) (+ (* x x) (- (* -1 -1) (* x -1)))) (* (+ (* x x) (- (* 1 1) (* x 1))) (+ (pow x 3) (pow -1 3))))) (* (+ (* x x) (- (* -1 -1) (* x -1))) (+ -1 x))) (* (* (+ (* x x) (- (* 1 1) (* x 1))) (+ (* x x) (- (* -1 -1) (* x -1)))) (* (* (+ (pow x 3) (pow -1 3)) (- (* -1 -1) (* x x))) 2)))
1.0s
(+ (* (* x (- (* (+ x 1) (+ x 1)) (* (+ x -1) (+ x -1)))) (* (+ (* x x) (- (* -1 -1) (* x -1))) (+ -1 x))) (* (- (+ x 1) (+ x -1)) (* (* (+ (pow x 3) (pow -1 3)) (- (* -1 -1) (* x x))) 2)))
834.0ms
(+ (* (* x (- (* (+ x 1) (+ x 1)) (* (+ x -1) (+ x -1)))) (* (- x -1) (+ -1 x))) (* (- (+ x 1) (+ x -1)) (* (* (- (* x x) (* -1 -1)) (- (* -1 -1) (* x x))) 2)))

prune1.1s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize3.0ms

Local error

Found 3 expressions with local error:

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

rewrite12.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
7.0ms
(* (* (+ x 1) x) (- x 1))
2.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
2.0ms
(* (+ x 1) x)

series72.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
34.0ms
(* (* (+ x 1) x) (- x 1))
21.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
16.0ms
(* (+ x 1) x)

simplify2.8s

Counts
45 → 68
Calls
45 calls:
Slowest
290.0ms
(* (* (- (* x x) (* 1 1)) x) (- (pow x 3) (pow 1 3)))
241.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
208.0ms
(* (* (- (* x x) (* 1 1)) x) (- x 1))
188.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (* x x) (* 1 1)))
167.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (pow x 3) (pow 1 3)))

prune299.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

regimes20.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
603.0ms4230×body80valid
536.0ms1822×body640valid
223.0ms992×body320valid
185.0ms522×body1280valid
74.0ms438×body160valid