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

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 9.8

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

    \[\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.4

    \[\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. Using strategy rm
  9. Applied *-un-lft-identity0.1

    \[\leadsto \frac{\frac{2}{\left(x + 1\right) \cdot x}}{\color{blue}{1 \cdot \left(x - 1\right)}}\]
  10. Applied flip-+0.1

    \[\leadsto \frac{\frac{2}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}} \cdot x}}{1 \cdot \left(x - 1\right)}\]
  11. Applied associate-*l/0.3

    \[\leadsto \frac{\frac{2}{\color{blue}{\frac{\left(x \cdot x - 1 \cdot 1\right) \cdot x}{x - 1}}}}{1 \cdot \left(x - 1\right)}\]
  12. Applied associate-/r/0.3

    \[\leadsto \frac{\color{blue}{\frac{2}{\left(x \cdot x - 1 \cdot 1\right) \cdot x} \cdot \left(x - 1\right)}}{1 \cdot \left(x - 1\right)}\]
  13. Applied times-frac0.3

    \[\leadsto \color{blue}{\frac{\frac{2}{\left(x \cdot x - 1 \cdot 1\right) \cdot x}}{1} \cdot \frac{x - 1}{x - 1}}\]
  14. Simplified0.1

    \[\leadsto \color{blue}{\frac{\frac{2}{x}}{-1 + x \cdot x}} \cdot \frac{x - 1}{x - 1}\]
  15. Simplified0.1

    \[\leadsto \frac{\frac{2}{x}}{-1 + x \cdot x} \cdot \color{blue}{1}\]
  16. Final simplification0.1

    \[\leadsto \frac{\frac{2}{x}}{-1 + x \cdot x}\]

Reproduce

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

sample69.0ms

Algorithm
intervals
Results
256×(pre true 80)
130×(body real 80)
49×(body real 640)
28×(body real 320)
27×(body real 160)
22×(body real 1280)

simplify60.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
60.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

localize40.0ms

Local error

Found 4 expressions with local error:

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

rewrite39.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
24.0ms
(+ (- (/ 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))

series83.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
59.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
11.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
7.0ms
(/ 1 (- x 1))
6.0ms
(/ 1 (+ x 1))

simplify3.2s

Counts
48 → 88
Calls
48 calls:
Slowest
435.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
422.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
304.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
275.0ms
(* (+ (* (/ 1 (+ x 1)) (/ 1 (+ x 1))) (+ (* (/ 2 x) (/ 2 x)) (* (/ 1 (+ x 1)) (/ 2 x)))) (- x 1))
260.0ms
(* (* (+ x 1) x) (- x 1))

prune712.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize39.0ms

Local error

Found 4 expressions with local error:

16.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))

rewrite39.0ms

Algorithm
rewrite-expression-head
Rules
46×associate-*l/
22×flip--
22×flip3--
16×frac-add
16×frac-times
12×flip-+
12×flip3-+
add-log-exp
add-exp-log
associate-*r/
add-cbrt-cube
pow1
add-cube-cbrt
*-un-lft-identity
sub-neg
add-sqr-sqrt
associate-*r*
distribute-lft-in
distribute-rgt-in
associate-*l*
associate-+l+
cbrt-unprod
*-commutative
prod-exp
pow-prod-down
diff-log
sum-log
+-commutative
Counts
4 → 99
Calls
4 calls:
Slowest
22.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
7.0ms
(* (* (+ x 1) x) (- x 1))
6.0ms
(* (- (* 1 x) (* (+ x 1) 2)) (- x 1))
2.0ms
(- (* 1 x) (* (+ x 1) 2))

series80.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
49.0ms
(* (* (+ x 1) x) (- x 1))
15.0ms
(* (- (* 1 x) (* (+ x 1) 2)) (- x 1))
14.0ms
(- (* 1 x) (* (+ x 1) 2))
2.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))

simplify19.0s

Counts
97 → 111
Calls
97 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)))
971.0ms
(* (* (- (* x x) (* 1 1)) x) (- (pow x 3) (pow 1 3)))
711.0ms
(+ (* (* (- (* (* 1 x) (* 1 x)) (* (* (+ x 1) 2) (* (+ x 1) 2))) (- (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (* (+ (* 1 x) (* (+ x 1) 2)) (+ (* x x) (+ (* 1 1) (* x 1)))) (* (* (+ (pow x 3) (pow 1 3)) x) 1)))
702.0ms
(* (+ (* 1 x) (* (+ x 1) 2)) (+ (* x x) (+ (* 1 1) (* x 1))))
683.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)))

prune1.3s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 3 expressions with local error:

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

rewrite26.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
15.0ms
(* (* (+ x 1) x) (- x 1))
5.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
5.0ms
(* (+ x 1) x)

series117.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
53.0ms
(* (* (+ x 1) x) (- x 1))
44.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
20.0ms
(* (+ x 1) x)

simplify4.7s

Counts
45 → 68
Calls
45 calls:
Slowest
429.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
400.0ms
(* (* (- (* x x) (* 1 1)) x) (- (pow x 3) (pow 1 3)))
361.0ms
(* (* (- (* x x) (* 1 1)) x) (- x 1))
335.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (* x x) (* 1 1)))
314.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (pow x 3) (pow 1 3)))

prune502.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

localize6.0ms

Local error

Found 3 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Rules
18×times-frac
15×add-cube-cbrt
15×*-un-lft-identity
15×add-sqr-sqrt
12×associate-/r/
12×associate-*l/
associate-/l*
div-inv
flip-+
flip3-+
add-exp-log
add-cbrt-cube
associate-/r*
add-log-exp
associate-*l*
pow1
frac-2neg
clear-num
associate-/l/
flip--
*-commutative
div-exp
flip3--
cbrt-undiv
Counts
3 → 68
Calls
3 calls:
Slowest
5.0ms
(/ (/ 2 (* (+ x 1) x)) (- x 1))
2.0ms
(* (+ x 1) x)
1.0ms
(/ 2 (* (+ x 1) x))

series78.0ms

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

simplify4.2s

Counts
62 → 77
Calls
62 calls:
Slowest
328.0ms
(/ (/ 2 (* (+ (pow x 3) (pow 1 3)) x)) (sqrt (- x 1)))
264.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))) (* 2 (/ 1 (pow x 3))))
261.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
235.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))) (* 2 (/ 1 (pow x 3))))
231.0ms
(/ (/ 2 (* (+ (pow x 3) (pow 1 3)) x)) (* (cbrt (- x 1)) (cbrt (- x 1))))

prune386.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

regimes22.0ms

Accuracy

0% (0.0b remaining)

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

bsearch1.0ms

end0.0ms

sample2.0s

Algorithm
intervals
Results
8004×(pre true 80)
4141×(body real 80)
1874×(body real 640)
914×(body real 320)
544×(body real 1280)
531×(body real 160)